From 3632a07142dca7422c3343e98de33f2abec629aa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 11 Nov 2019 15:44:12 -0400 Subject: Changed the ChrootBootstrapper type class's buildchroot method to take a Info parameter, instead of Maybe System. The System can be extracted from the Info; this also allows the chroot's Info to be introspected for eg, the apt mirror. (API change) --- src/Propellor/Property/Chroot.hs | 11 ++++++++--- src/Propellor/Types/Info.hs | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs index 48d96dcf..5be39bd6 100644 --- a/src/Propellor/Property/Chroot.hs +++ b/src/Propellor/Property/Chroot.hs @@ -60,7 +60,11 @@ class ChrootBootstrapper b where -- | Do initial bootstrapping of an operating system in a chroot. -- If the operating System is not supported, return -- Left error message. - buildchroot :: b -> Maybe System -> FilePath -> Either String (Property Linux) + buildchroot + :: b + -> Info -- ^ info of the Properties of the chroot + -> FilePath -- ^ where to bootstrap the chroot + -> Either String (Property Linux) -- | Use this to bootstrap a chroot by extracting a tarball. -- @@ -91,7 +95,7 @@ extractTarball target src = check (isUnpopulated target) $ data Debootstrapped = Debootstrapped Debootstrap.DebootstrapConfig instance ChrootBootstrapper Debootstrapped where - buildchroot (Debootstrapped cf) system loc = case system of + buildchroot (Debootstrapped cf) info loc = case system of (Just s@(System (Debian _ _) _)) -> Right $ debootstrap s (Just s@(System (Buntish _) _)) -> Right $ debootstrap s (Just (System ArchLinux _)) -> Left "Arch Linux not supported by debootstrap." @@ -99,6 +103,7 @@ instance ChrootBootstrapper Debootstrapped where Nothing -> Left "Cannot debootstrap; OS not specified" where debootstrap s = Debootstrap.built loc s cf + system = fromInfoVal (fromInfo info) -- | Defines a Chroot at the given location, built with debootstrap. -- @@ -143,7 +148,7 @@ provisioned' c@(Chroot loc bootstrapper infopropigator _) systemdonly caps = setup = propellChroot c (inChrootProcess (not systemdonly) c) systemdonly caps `requires` built - built = case buildchroot bootstrapper (chrootSystem c) loc of + built = case buildchroot bootstrapper (containerInfo c) loc of Right p -> p Left e -> cantbuild e diff --git a/src/Propellor/Types/Info.hs b/src/Propellor/Types/Info.hs index b941cc8f..27633712 100644 --- a/src/Propellor/Types/Info.hs +++ b/src/Propellor/Types/Info.hs @@ -63,6 +63,7 @@ addInfo (Info l) v = Info (l++[InfoEntry v]) toInfo :: IsInfo v => v -> Info toInfo = addInfo mempty +-- | Extracts a value from an Info. fromInfo :: IsInfo v => Info -> v fromInfo (Info l) = mconcat (mapMaybe extractInfoEntry l) -- cgit v1.2.3