From 89dec139eef3d409c06877d5e8fd1dc1085465d1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Aug 2015 11:21:29 -0700 Subject: wip --- src/Propellor/Property/DiskImage.hs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index de8bdd56..cb373c94 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -2,6 +2,7 @@ module Propellor.Property.DiskImage ( built, + rebuilt, DiskImageConfig(..), DiskImageFinalization, grubBooted, @@ -9,32 +10,40 @@ module Propellor.Property.DiskImage ( import Propellor import Propellor.Property.Chroot -import Utility.DataUnits +import Propellor.Property.Parted -- | Creates a bootable disk image. -- --- First the specified Chroot is set up, then a disk image is created, --- large enough to fit the chroot, which is copied into it. Finally, the --- DiskImageFinalization property is satisfied to make the disk image --- bootable. +-- First the specified Chroot is set up, and its properties are satisfied. +-- Then a disk image is created, large enough to fit the chroot, which +-- is copied into it. Finally, the DiskImageFinalization property is +-- satisfied to make the disk image bootable. -- --- > let chroot d = Chroot.debootstrapped (System (Debian Unstable) "amd64") Debootstrap.DefaultConfig d +-- > let chroot d = Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty d -- > & Apt.installed ["openssh-server"] -- > & Grub.installed Grub.PC -- > & ... -- > in DiskImage.built mempty chroot DiskImage.grubBooted built :: DiskImageConfig -> (FilePath -> Chroot) -> DiskImageFinalization -> RevertableProperty -built c = undefined +built = built' False + +-- | Like 'built', but the chroot is deleted and rebuilt from scratch each +-- time. This is more expensive, but useful to ensure reproducible results +-- when the properties of the chroot have been changed. +rebuilt :: DiskImageConfig -> (FilePath -> Chroot) -> DiskImageFinalization -> RevertableProperty +rebuilt = built' True + +built' :: Bool -> DiskImageConfig -> (FilePath -> Chroot) -> DiskImageFinalization -> RevertableProperty +built' rebuild c mkchroot final = undefined data DiskImageConfig = DiskImageConfig - { freeSpace :: ByteSize -- ^ A disk image is sized to fit the system installed in it. This adds some extra free space. + { freeSpace :: MegaBytes -- ^ A disk image is sized to fit the system installed in it. This adds some extra free space. (mempty default: 256 Megabytes) } instance Monoid DiskImageConfig where - -- | Default value is 256 mb freeSpace. - mempty = DiskImageConfig (1024 * 1024 * 256) + mempty = DiskImageConfig (MegaBytes 256) mappend a b = a - { freeSpace = freeSpace a + freeSpace b + { freeSpace = freeSpace a <> freeSpace b } -- | This is a property that is run, chrooted into the disk image. It's -- cgit v1.2.3