From f173da0c9e7e7221aa77cfa3247ebfb941204e05 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 15 Jul 2017 09:13:08 -0700 Subject: sbuild properties set up an apt cache or use existing apt proxy --- src/Propellor/Property/Sbuild.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/Propellor') diff --git a/src/Propellor/Property/Sbuild.hs b/src/Propellor/Property/Sbuild.hs index 12720592..08246d27 100644 --- a/src/Propellor/Property/Sbuild.hs +++ b/src/Propellor/Property/Sbuild.hs @@ -84,6 +84,7 @@ module Propellor.Property.Sbuild ( ) where import Propellor.Base +import Propellor.Types.Info import Propellor.Property.Debootstrap (extractSuite) import Propellor.Property.Chroot.Util import qualified Propellor.Property.Apt as Apt @@ -177,6 +178,8 @@ built s@(SbuildSchroot suite arch) mirror cc = enhancedConf = combineProperties ("enhanced schroot conf for " ++ val s) $ props & aliasesLine + -- set up an apt proxy/cacher + & proxyCacher -- enable ccache and eatmydata for speed & ConfFile.containsIniSetting (schrootConf s) ( val s ++ "-sbuild" @@ -184,6 +187,21 @@ built s@(SbuildSchroot suite arch) mirror cc = , intercalate "," commandPrefix ) + 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 s "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. -- cgit v1.2.3