From 50986da33afb5b170a5336e4714e79130959b6c9 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 4 Feb 2017 11:46:07 -0700 Subject: Apt.pinnedTo takes a list of suites and pin priorities --- src/Propellor/Property/Apt.hs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/Propellor/Property/Apt.hs') 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 -- cgit v1.2.3