summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Apt.hs
diff options
context:
space:
mode:
authorJoey Hess2017-07-28 20:13:57 -0400
committerJoey Hess2017-07-28 20:13:57 -0400
commit4b2eb5f267769ddb9f0d21201418ed14d126e99e (patch)
tree11e884206936db4db559702e0a616e4d556942ed /src/Propellor/Property/Apt.hs
parent9b9cc6f4465056338d86a866bfe3b51307ffb6b2 (diff)
parent56fda8c3ae6af1241ce4836a6122393871fca151 (diff)
Merge remote-tracking branch 'spwhitton/apt-cacher-ng'
Diffstat (limited to 'src/Propellor/Property/Apt.hs')
-rw-r--r--src/Propellor/Property/Apt.hs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs
index 686ddb6c..5630d83a 100644
--- a/src/Propellor/Property/Apt.hs
+++ b/src/Propellor/Property/Apt.hs
@@ -20,7 +20,10 @@ import Propellor.Types.Info
data HostMirror = HostMirror Url
deriving (Eq, Show, Typeable)
--- | Indicate host's preferred apt mirror (e.g. an apt cacher on the host's LAN)
+data HostAptProxy = HostAptProxy Url
+ deriving (Eq, Show, Typeable)
+
+-- | Indicate host's preferred apt mirror
mirror :: Url -> Property (HasInfo + UnixLike)
mirror u = pureInfoProperty (u ++ " apt mirror selected")
(InfoVal (HostMirror u))
@@ -493,3 +496,19 @@ suitePinBlock p suite pin =
dpkgStatus :: FilePath
dpkgStatus = "/var/lib/dpkg/status"
+
+-- | Set apt's proxy
+proxy :: Url -> Property (HasInfo + DebianLike)
+proxy u = tightenTargets $
+ proxyInfo `before` proxyConfig `describe` desc
+ where
+ proxyInfo = pureInfoProperty desc (InfoVal (HostAptProxy u))
+ proxyConfig = "/etc/apt/apt.conf.d/20proxy" `File.hasContent`
+ [ "Acquire::HTTP::Proxy \"" ++ u ++ "\";" ]
+ desc = (u ++ " apt proxy selected")
+
+-- | Cause apt to proxy downloads via an apt cacher on localhost
+useLocalCacher :: Property (HasInfo + DebianLike)
+useLocalCacher = proxy "http://localhost:3142"
+ `requires` serviceInstalledRunning "apt-cacher-ng"
+ `describe` "apt uses local apt cacher"