From eae8fe777c141b34ec586e9af5bde278a33cc0c3 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 4 Feb 2017 11:30:28 -0700 Subject: rm superfluous TODO --- src/Propellor/Property/Apt.hs | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index 218c7197..fef4a700 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -290,8 +290,6 @@ pinnedTo' p (suite, pin) = prefFile = "/etc/apt/preferences.d/10propellor_" ++ File.configFileName p <.> "pref" --- TODO should be RevertableProperty Debian Debian - -- | Package installation may fail becuse the archive has changed. -- Run an update in that case and retry. robustly :: Property DebianLike -> Property DebianLike -- cgit v1.2.3 From 3829c41dc936b742be6aaae885f771b560f3a96f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 4 Feb 2017 11:32:34 -0700 Subject: factor out suitePinBlock --- src/Propellor/Property/Apt.hs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index fef4a700..61596914 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -116,12 +116,7 @@ suiteAvailablePinned s pin = available unavailable where available :: Property Debian available = tightenTargets $ combineProperties (desc True) $ props - & File.hasContent prefFile - [ "Explanation: This file added by propellor" - , "Package: *" - , "Pin: release " ++ suitePin s - , "Pin-Priority: " ++ show pin - ] + & File.hasContent prefFile (suitePinBlock "*" s pin) & setSourcesFile unavailable :: Property Debian @@ -281,12 +276,7 @@ pinnedTo' p (suite, pin) = (tightenTargets $ prefFile `File.hasContent` prefs) (tightenTargets $ File.notPresent prefFile) where - prefs = - [ "Explanation: This file added by propellor" - , "Package: " ++ p - , "Pin: release " ++ suitePin suite - , "Pin-Priority: " ++ show pin - ] + prefs = suitePinBlock p suite pin prefFile = "/etc/apt/preferences.d/10propellor_" ++ File.configFileName p <.> "pref" @@ -454,5 +444,13 @@ suitePin s = prefix s ++ showSuite s prefix (Stable _) = "n=" prefix _ = "a=" +suitePinBlock :: AptPrefPackage -> DebianSuite -> PinPriority +suitePinBlock p suite pin = + [ "Explanation: This file added by propellor" + , "Package: " ++ p + , "Pin: release " ++ suitePin suite + , "Pin-Priority: " ++ show pin + ] + dpkgStatus :: FilePath dpkgStatus = "/var/lib/dpkg/status" -- cgit v1.2.3 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') 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 From 8638b56b36b8abf06cbb6d107a4bd058bd915437 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 4 Feb 2017 11:52:43 -0700 Subject: AptPrefPackage -> AptPackagePref This reads much better: it's an "apt package preference". --- src/Propellor/Property/Apt.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index d0f25e81..724f6d05 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -248,7 +248,7 @@ buildDepIn dir = cmdPropertyEnv "sh" ["-c", cmd] noninteractiveEnv -- | The name of a package, a glob to match the names of packages, or a regexp -- surrounded by slashes to match the names of packages. See -- apt_preferences(5), "Regular expressions and glob(7) syntax" -type AptPrefPackage = String +type AptPackagePref = String -- | Pins a list of packages, package wildcards and/or regular expressions to a -- list of suites and corresponding pin priorities (see apt_preferences(5)). @@ -268,7 +268,7 @@ type AptPrefPackage = String -- > & Apt.suiteAvailablePinned Unstable (-10) -- > & ["elpa-*"] `Apt.pinnedTo` [(Testing, 100), (Unstable, 50)] pinnedTo - :: [AptPrefPackage] + :: [AptPackagePref] -> [(DebianSuite, PinPriority)] -> RevertableProperty Debian Debian pinnedTo ps pins = (\p -> pinnedTo' p pins) `applyToList` ps @@ -277,7 +277,7 @@ pinnedTo ps pins = (\p -> pinnedTo' p pins) `applyToList` ps showSuites = intercalate "," $ showSuite . fst <$> pins pinnedTo' - :: AptPrefPackage + :: AptPackagePref -> [(DebianSuite, PinPriority)] -> RevertableProperty Debian Debian pinnedTo' p pins = @@ -453,7 +453,7 @@ suitePin s = prefix s ++ showSuite s prefix (Stable _) = "n=" prefix _ = "a=" -suitePinBlock :: AptPrefPackage -> DebianSuite -> PinPriority -> [Line] +suitePinBlock :: AptPackagePref -> DebianSuite -> PinPriority -> [Line] suitePinBlock p suite pin = [ "Explanation: This file added by propellor" , "Package: " ++ p -- cgit v1.2.3