diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-08-26 11:23:42 -0700 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-08-26 11:23:42 -0700 |
| commit | a4ac16ab9432a9f6e180e9e416e95de8433ed016 (patch) | |
| tree | 8e5dc34c025109ff544c76e43a987c773fe2ac89 /src/Propellor/Property/DiskImage.hs | |
| parent | 01d1cbb8361d1fada638bd4c554f3ea9fe7b8c76 (diff) | |
| parent | 89dec139eef3d409c06877d5e8fd1dc1085465d1 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/DiskImage.hs')
| -rw-r--r-- | src/Propellor/Property/DiskImage.hs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs new file mode 100644 index 00000000..cb373c94 --- /dev/null +++ b/src/Propellor/Property/DiskImage.hs @@ -0,0 +1,58 @@ +{-# LANGUAGE FlexibleContexts #-} + +module Propellor.Property.DiskImage ( + built, + rebuilt, + DiskImageConfig(..), + DiskImageFinalization, + grubBooted, +) where + +import Propellor +import Propellor.Property.Chroot +import Propellor.Property.Parted + +-- | Creates a bootable disk image. +-- +-- 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") mempty d +-- > & Apt.installed ["openssh-server"] +-- > & Grub.installed Grub.PC +-- > & ... +-- > in DiskImage.built mempty chroot DiskImage.grubBooted +built :: DiskImageConfig -> (FilePath -> Chroot) -> DiskImageFinalization -> RevertableProperty +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 :: 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 + mempty = DiskImageConfig (MegaBytes 256) + mappend a b = a + { freeSpace = freeSpace a <> freeSpace b + } + +-- | This is a property that is run, chrooted into the disk image. It's +-- typically only used to set up the boot loader. +type DiskImageFinalization = Property NoInfo + +-- | Makes grub be the boot loader of the disk image. +-- +-- This does not cause grub to be installed. Use `Grub.installed` when +-- setting up the Chroot to do that. +grubBooted :: DiskImageFinalization +grubBooted = undefined |
