summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2019-11-11 15:44:12 -0400
committerJoey Hess2019-11-11 15:44:12 -0400
commit3632a07142dca7422c3343e98de33f2abec629aa (patch)
treecd07a6d58c9d0edaad1a1cd8196c3183cf5d1ba3
parent596bfcd2e26d6120e190519fca1946b613e002ec (diff)
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)
-rw-r--r--debian/changelog4
-rw-r--r--src/Propellor/Property/Chroot.hs11
-rw-r--r--src/Propellor/Types/Info.hs1
3 files changed, 13 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 3031d05a..da528717 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,10 @@ propellor (5.10.1) UNRELEASED; urgency=medium
* Localdir.hasOriginUrl: Type changed from UnixLike to DebianLike
because Git.installed is not implemented for other unixes.
(API change)
+ * 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.)
+ (API change)
-- Joey Hess <id@joeyh.name> Thu, 08 Aug 2019 11:33:37 -0400
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)