From 15dd3205dda4ffb389333f6d6fa84b9ad583d315 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 18 Nov 2017 10:32:42 -0700 Subject: stop automatically setting up a proxy in the sbuild chroot Instead, provide a property to let the user tell propellor to propagate the host's proxy into the chroot. This makes it easy to toggle on and off and lets the user explicitly specify how they want the chroot's proxy setup to work. --- src/Propellor/Property/Sbuild.hs | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/Propellor/Property/Sbuild.hs b/src/Propellor/Property/Sbuild.hs index 326d6506..619adb23 100644 --- a/src/Propellor/Property/Sbuild.hs +++ b/src/Propellor/Property/Sbuild.hs @@ -21,9 +21,11 @@ stretch, which older sbuild can't handle. Suggested usage in @config.hs@: -- TODO can we use '$' here or do we require more brackets? +> & Apt.useLocalCacher > & Sbuild.built Sbuild.UseCcache $ props > & osDebian Unstable X86_32 > & Sbuild.update `period` Weekly 1 +> & Sbuild.useHostProxy > & Sbuild.usableBy (User "spwhitton") > & Schroot.overlaysInTmpfs @@ -120,7 +122,6 @@ built' cc (Props ps) suite arch = provisioned deleted & preReqsInstalled & ccacheMaybePrepared cc & Chroot.provisioned schroot - & proxyCacher & conf suite arch where desc = "built sbuild schroot for " ++ suiteArch @@ -159,31 +160,6 @@ built' cc (Props ps) suite arch = provisioned deleted ("/etc/sbuild/chroot" suiteArch ++ "-sbuild") (File.LinkTarget schrootRoot) - -- set the apt proxy inside the chroot. If the host has an apt proxy - -- set, assume that it does some sort of caching. Otherwise, set up a - -- local apt-cacher-ng instance - -- - -- (if we didn't assume that the apt proxy does some sort of caching, - -- we'd need to complicate the Apt.HostAptProxy type to indicate whether - -- the proxy caches, and if it doesn't, set up apt-cacher-ng as an - -- intermediary proxy between the chroot's apt and the Apt.HostAptProxy - -- proxy. This complexity is more likely to cause problems than help - -- anyone) - proxyCacher :: Property DebianLike - proxyCacher = property' "set schroot apt proxy" $ \w -> do - proxyInfo <- getProxyInfo - ensureProperty w $ case proxyInfo of - Just (Apt.HostAptProxy u) -> setChrootProxy u - Nothing -> (Apt.serviceInstalledRunning "apt-cacher-ng" - `before` setChrootProxy "http://localhost:3142") - where - getProxyInfo :: Propellor (Maybe Apt.HostAptProxy) - getProxyInfo = fromInfoVal <$> askInfo - setChrootProxy :: Apt.Url -> Property DebianLike - setChrootProxy u = tightenTargets $ File.hasContent - (schrootRoot "etc/apt/apt.conf.d/20proxy") - [ "Acquire::HTTP::Proxy \"" ++ u ++ "\";" ] - -- if we're building a sid chroot, add useful aliases -- In order to avoid more than one schroot getting the same aliases, we -- only do this if the arch of the chroot equals the host arch. @@ -267,6 +243,12 @@ built' cc (Props ps) suite arch = provisioned deleted update :: Property DebianLike update = Apt.update `before` Apt.upgrade `before` Apt.autoRemove +-- | Ensure that an sbuild schroot uses the host's Apt proxy. +-- +-- This property is standardly used when the host has 'Apt.useLocalCacher'. +useHostProxy :: Property (HasInfo + DebianLike) +useHostProxy = undefined + aptCacheLine :: String aptCacheLine = "/var/cache/apt/archives /var/cache/apt/archives none rw,bind 0 0" -- cgit v1.2.3