From e7e94a8f57dd6a54213cbc1365928110e95f8947 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 12 Nov 2019 14:55:43 -0700 Subject: move Sbuild.useHostProxy -> Chroot.useHostProxy Now that the apt proxy is respected by Chroot.debootstrapped, users will probably want to apply useHostProxy to more chroots than just sbuild schroots. Unfortunately, we can't have a corresponding Chroot.useHostMirror property, because the only sensible way to set the chroot's apt mirror is to use the Apt.mirror pure info property, but we can't ensure properties with info. Suggested-by: Joey Hess Signed-off-by: Sean Whitton --- src/Propellor/Property/Chroot.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/Propellor/Property/Chroot.hs') diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs index ddb7f884..971fd8ba 100644 --- a/src/Propellor/Property/Chroot.hs +++ b/src/Propellor/Property/Chroot.hs @@ -10,6 +10,7 @@ module Propellor.Property.Chroot ( Debootstrapped(..), ChrootTarball(..), exposeTrueLocaldir, + useHostProxy, -- * Internal use provisioned', propagateChrootInfo, @@ -333,3 +334,18 @@ propagateHostChrootInfo :: Host -> InfoPropagator propagateHostChrootInfo h c pinfo p = propagateContainer (hostName h) c pinfo $ p `setInfoProperty` chrootInfo c + +-- | Ensure that a chroot uses the host's Apt proxy. +-- +-- This property is often used for 'Sbuild.built' chroots, when the host has +-- 'Apt.useLocalCacher'. +useHostProxy :: Host -> Property DebianLike +useHostProxy h = property' "use host's apt proxy" $ \w -> + -- Note that we can't look at getProxyInfo outside the property, + -- as that would loop, but it's ok to look at it inside the + -- property. Thus the slightly strange construction here. + case getProxyInfo of + Just (Apt.HostAptProxy u) -> ensureProperty w (Apt.proxy' u) + Nothing -> noChange + where + getProxyInfo = fromInfoVal . fromInfo . hostInfo $ h -- cgit v1.2.3