summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorSean Whitton2017-02-04 11:46:07 -0700
committerSean Whitton2017-02-04 11:46:07 -0700
commit50986da33afb5b170a5336e4714e79130959b6c9 (patch)
tree978a8726e371394aeece719e272adbf3d5303a38 /src/Propellor
parent3829c41dc936b742be6aaae885f771b560f3a96f (diff)
Apt.pinnedTo takes a list of suites and pin priorities
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/Apt.hs35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs
index 61596914..d0f25e81 100644
--- a/src/Propellor/Property/Apt.hs
+++ b/src/Propellor/Property/Apt.hs
@@ -251,32 +251,41 @@ buildDepIn dir = cmdPropertyEnv "sh" ["-c", cmd] noninteractiveEnv
type AptPrefPackage = String
-- | Pins a list of packages, package wildcards and/or regular expressions to a
--- given suite with a given pin priority (see apt_preferences(5)). Revert to
--- unpin.
+-- list of suites and corresponding pin priorities (see apt_preferences(5)).
+-- Revert to unpin.
--
--- Note that this will have no effect unless there is an apt source for the
--- suite. One way to add an apt source is 'Apt.suiteAvailablePinned'.
+-- Each package, package wildcard or regular expression will be pinned to all of
+-- the specified suites.
--
--- For example, to obtain all Emacs Lisp addon packages from sid, you could use
+-- Note that this will have no effect unless there is an apt source for each of
+-- the suites. One way to add an apt source is 'Apt.suiteAvailablePinned'.
--
+-- For example, to obtain Emacs Lisp addon packages not present in your release
+-- of Debian from testing, falling back to sid if they're not available in
+-- testing, you could use
+--
+-- > & Apt.suiteAvailablePinned Testing (-10)
-- > & Apt.suiteAvailablePinned Unstable (-10)
--- > & ["elpa-*"] `Apt.pinnedTo` (Unstable, 990)
+-- > & ["elpa-*"] `Apt.pinnedTo` [(Testing, 100), (Unstable, 50)]
pinnedTo
:: [AptPrefPackage]
- -> (DebianSuite, PinPriority)
+ -> [(DebianSuite, PinPriority)]
-> RevertableProperty Debian Debian
-pinnedTo ps (suite, pin) = (\p -> pinnedTo' p (suite, pin)) `applyToList` ps
- `describe` unwords (("pinned to " ++ showSuite suite):ps)
+pinnedTo ps pins = (\p -> pinnedTo' p pins) `applyToList` ps
+ `describe` unwords (("pinned to " ++ showSuites):ps)
+ where
+ showSuites = intercalate "," $ showSuite . fst <$> pins
pinnedTo'
:: AptPrefPackage
- -> (DebianSuite, PinPriority)
+ -> [(DebianSuite, PinPriority)]
-> RevertableProperty Debian Debian
-pinnedTo' p (suite, pin) =
+pinnedTo' p pins =
(tightenTargets $ prefFile `File.hasContent` prefs)
<!> (tightenTargets $ File.notPresent prefFile)
where
- prefs = suitePinBlock p suite pin
+ prefs = foldr step [] pins
+ step (suite, pin) ls = ls ++ suitePinBlock p suite pin ++ [""]
prefFile = "/etc/apt/preferences.d/10propellor_"
++ File.configFileName p <.> "pref"
@@ -444,7 +453,7 @@ suitePin s = prefix s ++ showSuite s
prefix (Stable _) = "n="
prefix _ = "a="
-suitePinBlock :: AptPrefPackage -> DebianSuite -> PinPriority
+suitePinBlock :: AptPrefPackage -> DebianSuite -> PinPriority -> [Line]
suitePinBlock p suite pin =
[ "Explanation: This file added by propellor"
, "Package: " ++ p