diff options
Diffstat (limited to 'src/Propellor/Property/Chroot.hs')
| -rw-r--r-- | src/Propellor/Property/Chroot.hs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs index 3da8b0d6..e56cb6ed 100644 --- a/src/Propellor/Property/Chroot.hs +++ b/src/Propellor/Property/Chroot.hs @@ -1,5 +1,8 @@ +{-# LANGUAGE FlexibleContexts #-} + module Propellor.Property.Chroot ( Chroot(..), + BuilderConf(..), debootstrapped, provisioned, -- * Internal use @@ -10,6 +13,7 @@ module Propellor.Property.Chroot ( ) where import Propellor +import Propellor.Types.CmdLine import Propellor.Types.Chroot import Propellor.Property.Chroot.Util import qualified Propellor.Property.Debootstrap as Debootstrap @@ -28,10 +32,10 @@ data BuilderConf = UsingDeboostrap Debootstrap.DebootstrapConfig deriving (Show) -instance Hostlike Chroot where +instance PropAccum Chroot where (Chroot l s c h) & p = Chroot l s c (h & p) (Chroot l s c h) &^ p = Chroot l s c (h &^ p) - getHost (Chroot _ _ _ h) = h + getProperties (Chroot _ _ _ h) = hostProperties h -- | Defines a Chroot at the given location, built with debootstrap. -- @@ -57,12 +61,13 @@ debootstrapped system conf location = case system of provisioned :: Chroot -> RevertableProperty provisioned c = provisioned' (propigateChrootInfo c) c False -provisioned' :: (Property -> Property) -> Chroot -> Bool -> RevertableProperty -provisioned' propigator c@(Chroot loc system builderconf _) systemdonly = RevertableProperty +provisioned' :: (Property HasInfo -> Property HasInfo) -> Chroot -> Bool -> RevertableProperty +provisioned' propigator c@(Chroot loc system builderconf _) systemdonly = (propigator $ go "exists" setup) + <!> (go "removed" teardown) where - go desc a = property (chrootDesc c desc) $ ensureProperties [a] + go desc a = propertyList (chrootDesc c desc) [a] setup = propellChroot c (inChrootProcess c) systemdonly `requires` toProp built @@ -75,15 +80,21 @@ provisioned' propigator c@(Chroot loc system builderconf _) systemdonly = Revert teardown = toProp (revert built) -propigateChrootInfo :: Chroot -> Property -> Property -propigateChrootInfo c p = propigateInfo c p (<> chrootInfo c) +propigateChrootInfo :: (IsProp (Property i)) => Chroot -> Property i -> Property HasInfo +propigateChrootInfo c p = propigateContainer c p' + where + p' = infoProperty + (propertyDesc p) + (propertySatisfy p) + (propertyInfo p <> chrootInfo c) + (propertyChildren p) chrootInfo :: Chroot -> Info chrootInfo (Chroot loc _ _ h) = mempty { _chrootinfo = mempty { _chroots = M.singleton loc h } } -- | Propellor is run inside the chroot to provision it. -propellChroot :: Chroot -> ([String] -> CreateProcess) -> Bool -> Property +propellChroot :: Chroot -> ([String] -> CreateProcess) -> Bool -> Property NoInfo propellChroot c@(Chroot loc _ _ _) mkproc systemdonly = property (chrootDesc c "provisioned") $ do let d = localdir </> shimdir c let me = localdir </> "propellor" @@ -140,7 +151,8 @@ chain hostlist (ChrootChain hn loc systemdonly onconsole) = r <- runPropellor h $ ensureProperties $ if systemdonly then [Systemd.installed] - else hostProperties h + else map ignoreInfo $ + hostProperties h putStrLn $ "\n" ++ show r chain _ _ = errorMessage "bad chain command" |
