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/Propellor/Property/Apt.hs') 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