summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2018-10-14 12:31:00 -0400
committerJoey Hess2018-10-14 12:31:00 -0400
commitb23ca0e8aeb4839bc2b886b925dfeeacb1bfcb55 (patch)
treed222a19e58213ba5ead389acedd7934da551d8dc
parent3c2ef6ef55edeefbbb086539e1a55797d1980246 (diff)
Added Apt.backportInstalledMin.
This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
-rw-r--r--debian/changelog1
-rw-r--r--doc/forum/Apt.backportInstalledMin___63__/comment_1_4e5e6b479e478897eea3337b9468db15._comment11
-rw-r--r--src/Propellor/Property/Apt.hs19
3 files changed, 25 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index b0f7121b..5b283861 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,7 @@ propellor (5.5.0) UNRELEASED; urgency=medium
* Borg: Added UsesEnvVar.
* Added DiskImage.noBootloader, useful for eg, direct booting with
qemu. Thanks, David Bremner.
+ * Added Apt.backportInstalledMin.
-- Joey Hess <id@joeyh.name> Thu, 09 Aug 2018 10:54:41 -0400
diff --git a/doc/forum/Apt.backportInstalledMin___63__/comment_1_4e5e6b479e478897eea3337b9468db15._comment b/doc/forum/Apt.backportInstalledMin___63__/comment_1_4e5e6b479e478897eea3337b9468db15._comment
new file mode 100644
index 00000000..83b976d2
--- /dev/null
+++ b/doc/forum/Apt.backportInstalledMin___63__/comment_1_4e5e6b479e478897eea3337b9468db15._comment
@@ -0,0 +1,11 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2018-10-14T16:28:46Z"
+ content="""
+Indeed, that's the kind of improvement I will gladly
+accept any time, and should be very easy to add. So don't hesitate to add
+properties like that and send patches.
+
+(In this case I had 5 minutes so I implemented it already.)
+"""]]
diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs
index 064221f9..6d7fc4d6 100644
--- a/src/Propellor/Property/Apt.hs
+++ b/src/Propellor/Property/Apt.hs
@@ -241,6 +241,10 @@ type Package = String
installed :: [Package] -> Property DebianLike
installed = installed' ["-y"]
+-- | Minimal install of package, without recommends.
+installedMin :: [Package] -> Property DebianLike
+installedMin = installed' ["--no-install-recommends", "-y"]
+
installed' :: [String] -> [Package] -> Property DebianLike
installed' params ps = robustly $ check (not <$> isInstalled' ps) go
`describe` unwords ("apt installed":ps)
@@ -253,20 +257,23 @@ installed' params ps = robustly $ check (not <$> isInstalled' ps) go
-- dependencies from stable-backports too, you will need to include those
-- dependencies in the list of packages passed to this function.
backportInstalled :: [Package] -> Property Debian
-backportInstalled ps = withOS desc $ \w o -> case o of
+backportInstalled = backportInstalled' ["-y"]
+
+-- | Minimal install from the stable-backports suite, without recommends.
+backportInstalledMin :: [Package] -> Property Debian
+backportInstalledMin = backportInstalled' ["--no-install-recommends", "-y"]
+
+backportInstalled' :: [String] -> [Package] -> Property Debian
+backportInstalled' params ps = withOS desc $ \w o -> case o of
(Just (System (Debian _ suite) _)) -> case backportSuite suite of
Nothing -> unsupportedOS'
Just bs -> ensureProperty w $
- runApt (["install", "-y"] ++ ((++ '/':bs) <$> ps))
+ runApt (("install":params) ++ ((++ '/':bs) <$> ps))
`changesFile` dpkgStatus
_ -> unsupportedOS'
where
desc = unwords ("apt installed backport":ps)
--- | Minimal install of package, without recommends.
-installedMin :: [Package] -> Property DebianLike
-installedMin = installed' ["--no-install-recommends", "-y"]
-
removed :: [Package] -> Property DebianLike
removed ps = check (any (== IsInstalled) <$> getInstallStatus ps)
(runApt (["-y", "remove"] ++ ps))