summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorSean Whitton2017-07-15 08:12:42 -0700
committerSean Whitton2017-07-15 08:53:25 -0700
commitbb10fdfb30948fe096f746fa1b8c1020ab306fe9 (patch)
tree60b2db8dc1305466138a96f1611be4a505fe5d0e /src/Propellor
parent8ffd10be9715643cb7474a3d96b69a828537aa4a (diff)
add Apt.proxy, Apt.useLocalCacher
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/Apt.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs
index 686ddb6c..07164df6 100644
--- a/src/Propellor/Property/Apt.hs
+++ b/src/Propellor/Property/Apt.hs
@@ -20,6 +20,9 @@ import Propellor.Types.Info
data HostMirror = HostMirror Url
deriving (Eq, Show, Typeable)
+data HostAptProxy = HostAptProxy Url
+ deriving (Eq, Show, Typeable)
+
-- | Indicate host's preferred apt mirror (e.g. an apt cacher on the host's LAN)
mirror :: Url -> Property (HasInfo + UnixLike)
mirror u = pureInfoProperty (u ++ " apt mirror selected")
@@ -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"
+