From 733ff94298a1efda158b5f587e49de7c4cc692f1 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 30 Jan 2017 17:10:12 -0700 Subject: pin property prototypes --- src/Propellor/Property/Apt.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/Propellor/Property/Apt.hs') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index c0d4ac82..b3391866 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -100,6 +100,16 @@ stdSourcesList' suite more = tightenTargets $ setSourcesList where generators = [debCdn, kernelOrg, securityUpdates] ++ more +type PinPriority = Int + +-- | Adds an apt source for a suite, and pins that suite to a given pin value +-- (see apt_preferences(5)). Revert to drop the source and unpin the suite. +-- +-- If the requested suite is the host's OS suite, this property does nothing. +-- That apt source should already be available, or you can use a property like +-- 'Apt.stdSourcesList'. +suiteAvailablePinned :: DebianSuite -> PinPriority -> RevertableProperty Debian + setSourcesList :: [Line] -> Property DebianLike setSourcesList ls = sourcesList `File.hasContent` ls `onChange` update @@ -196,6 +206,18 @@ buildDepIn dir = cmdPropertyEnv "sh" ["-c", cmd] noninteractiveEnv where cmd = "cd '" ++ dir ++ "' && mk-build-deps debian/control --install --tool 'apt-get -y --no-install-recommends' --remove" +-- | Pins a list of packages and/or package wildcards to a given suite with a +-- given pin priority (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'. +-- +-- For example, to obtain all Emacs Lisp addon packages from sid, you could use +-- +-- > & Apt.suiteAvailablePinned Unstable +-- > & ["elpa-*"] `Apt.pinnedTo` Unstable 990 +pinnedTo :: [String] -> DebianSuite -> PinPriority -> RevertableProperty Debian + -- | Package installation may fail becuse the archive has changed. -- Run an update in that case and retry. robustly :: Property DebianLike -> Property DebianLike @@ -354,5 +376,11 @@ noPDiffs :: Property DebianLike noPDiffs = tightenTargets $ "/etc/apt/apt.conf.d/20pdiffs" `File.hasContent` [ "Acquire::PDiffs \"false\";" ] +suitePin :: DebianSuite -> String +suitePin s = prefix s ++ showSuite s + where + prefix (Stable _) = "n=" + prefix _ = "a=" + dpkgStatus :: FilePath dpkgStatus = "/var/lib/dpkg/status" -- cgit v1.2.3