From e73f67c381d41c65f33fb94dccdcbb7b120ad9a8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Oct 2015 13:57:03 -0400 Subject: propellor spin --- config-joey.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index 7d0f3c05..3fcf2289 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -85,7 +85,7 @@ darkstar = host "darkstar.kitenet.net" [ partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag , partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 -- , swapPartition (MegaBytes 256) - ] noFinalization -- (grubBooted PC) + ] (grubBooted PC) -- (grubBooted PC) where c d = Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty d & Apt.installed ["linux-image-amd64"] -- cgit v1.3-2-g0d8e From cc8fbeda82774f6c9a223a87187408496fcd0d2b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Oct 2015 14:10:52 -0400 Subject: avoid grub install failure in chroot --- config-joey.hs | 2 +- src/Propellor/Property/DiskImage.hs | 7 ++++++- src/Propellor/Property/Grub.hs | 19 ++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index 3fcf2289..815fe798 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -85,7 +85,7 @@ darkstar = host "darkstar.kitenet.net" [ partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag , partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 -- , swapPartition (MegaBytes 256) - ] (grubBooted PC) -- (grubBooted PC) + ] (grubBooted PC) where c d = Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty d & Apt.installed ["linux-image-amd64"] diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index 8d503e28..3c2b2200 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -292,7 +292,12 @@ type Finalization = (Property NoInfo, Property NoInfo) -- | Makes grub be the boot loader of the disk image. -- TODO not implemented grubBooted :: Grub.BIOS -> Finalization -grubBooted bios = (Grub.installed bios, undefined) +grubBooted bios = (inchroot, inimg) + where + -- Need to set up device.map manually before running update-grub. + inchroot = Grub.installed' bios + + inimg = undefined noFinalization :: Finalization noFinalization = (doNothing, doNothing) diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs index 6b763d08..ea54295b 100644 --- a/src/Propellor/Property/Grub.hs +++ b/src/Propellor/Property/Grub.hs @@ -18,14 +18,19 @@ data BIOS = PC | EFI64 | EFI32 | Coreboot | Xen -- | Installs the grub package. This does not make grub be used as the -- bootloader. -- --- This includes running update-grub, so that the grub boot menu is --- created. It will be automatically updated when kernel packages are --- installed. +-- This includes running update-grub. installed :: BIOS -> Property NoInfo -installed bios = - Apt.installed [pkg] `describe` "grub package installed" - `before` - cmdProperty "update-grub" [] +installed bios = installed' bios `before` mkConfig + +-- Run update-grub, to generate the grub boot menu. It will be +-- automatically updated when kernel packages are +-- -- installed. +mkConfig :: Property NoInfo +mkConfig = cmdProperty "update-grub" [] + +-- | Installs grub; does not run update-grub. +installed' :: BIOS -> Property NoInfo +installed' bios = Apt.installed [pkg] `describe` "grub package installed" where pkg = case bios of PC -> "grub-pc" -- cgit v1.3-2-g0d8e From 8a651b97777225b4d5b5b21950e92816bb226e4e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Oct 2015 15:03:55 -0400 Subject: propellor spin --- config-joey.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index 815fe798..c995f1ec 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -81,7 +81,7 @@ darkstar = host "darkstar.kitenet.net" & JoeySites.postfixClientRelay (Context "darkstar.kitenet.net") & JoeySites.dkimMilter - & imageBuilt "/tmp/img" c MSDOS + & imageBuilt "/tmp/img" c GPT [ partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag , partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 -- , swapPartition (MegaBytes 256) -- cgit v1.3-2-g0d8e From e411dba08924e9471e1af660d8126b2c3b095b90 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Oct 2015 15:06:46 -0400 Subject: propellor spin --- config-joey.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index c995f1ec..815fe798 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -81,7 +81,7 @@ darkstar = host "darkstar.kitenet.net" & JoeySites.postfixClientRelay (Context "darkstar.kitenet.net") & JoeySites.dkimMilter - & imageBuilt "/tmp/img" c GPT + & imageBuilt "/tmp/img" c MSDOS [ partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag , partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 -- , swapPartition (MegaBytes 256) -- cgit v1.3-2-g0d8e From d18f1e9e49eff5ca8d43845e2b9ce6483d219ffc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Oct 2015 15:35:08 -0400 Subject: propellor spin --- config-joey.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index 815fe798..24c3843a 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -82,8 +82,9 @@ darkstar = host "darkstar.kitenet.net" & JoeySites.dkimMilter & imageBuilt "/tmp/img" c MSDOS - [ partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag - , partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 + [ + -- partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag + partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 -- , swapPartition (MegaBytes 256) ] (grubBooted PC) where -- cgit v1.3-2-g0d8e From 123264e11659d455608c142ccecf320a116ad128 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Oct 2015 20:26:53 -0400 Subject: propellor spin --- config-joey.hs | 1 + debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index 24c3843a..cc1a9687 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -85,6 +85,7 @@ darkstar = host "darkstar.kitenet.net" [ -- partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 + `setFlag` BootFlag -- , swapPartition (MegaBytes 256) ] (grubBooted PC) where diff --git a/debian/changelog b/debian/changelog index 49c866bc..60a6f6a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +propellor (2.11.1) UNRELEASED; urgency=medium + + * The DiskImage module can now make bootable images using grub. + + -- Joey Hess Thu, 22 Oct 2015 20:24:18 -0400 + propellor (2.11.0) unstable; urgency=medium * Rewrote Propellor.Property.ControlHeir one more time, renaming it to -- cgit v1.3-2-g0d8e From 5db5d8418e27e187502e0807c3cbb7554dbbbcd1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Oct 2015 20:52:11 -0400 Subject: propellor spin --- config-joey.hs | 11 +++++------ src/Propellor/Property/DiskImage.hs | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'config-joey.hs') diff --git a/config-joey.hs b/config-joey.hs index cc1a9687..21d7194f 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -81,13 +81,12 @@ darkstar = host "darkstar.kitenet.net" & JoeySites.postfixClientRelay (Context "darkstar.kitenet.net") & JoeySites.dkimMilter - & imageBuilt "/tmp/img" c MSDOS - [ - -- partition EXT2 `mountedAt` "/boot" `setFlag` BootFlag - partition EXT4 `mountedAt` "/" `addFreeSpace` MegaBytes 100 + & imageBuilt "/tmp/img" c MSDOS (grubBooted PC) + [ partition EXT4 `mountedAt` "/" + `addFreeSpace` MegaBytes 100 `setFlag` BootFlag - -- , swapPartition (MegaBytes 256) - ] (grubBooted PC) + , swapPartition (MegaBytes 256) + ] where c d = Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty d & Apt.installed ["linux-image-amd64"] diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index dcd522a3..1e3a5407 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -69,25 +69,26 @@ type DiskImage = FilePath -- > let chroot d = Chroot.debootstrapped (System (Debian Unstable) "amd64") mempty d -- > & Apt.installed ["linux-image-amd64"] -- > & ... --- > in imageBuilt "/srv/images/foo.img" chroot MSDOS +-- > in imageBuilt "/srv/images/foo.img" chroot +-- > MSDOS (grubBooted PC) -- > [ partition EXT2 `mountedAt` "/boot" -- > `setFlag` BootFlag -- > , partition EXT4 `mountedAt` "/" -- > `addFreeSpace` MegaBytes 100 -- > , swapPartition (MegaBytes 256) --- > ] (grubBooted PC) -imageBuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> [PartSpec] -> Finalization -> RevertableProperty +-- > ] +imageBuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> Finalization -> [PartSpec] -> RevertableProperty imageBuilt = imageBuilt' 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. -imageRebuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> [PartSpec] -> Finalization -> RevertableProperty +imageRebuilt :: DiskImage -> (FilePath -> Chroot) -> TableType -> Finalization -> [PartSpec] -> RevertableProperty imageRebuilt = imageBuilt' True -imageBuilt' :: Bool -> DiskImage -> (FilePath -> Chroot) -> TableType -> [PartSpec] -> Finalization -> RevertableProperty -imageBuilt' rebuild img mkchroot tabletype partspec final = - imageBuiltFrom img chrootdir tabletype partspec final +imageBuilt' :: Bool -> DiskImage -> (FilePath -> Chroot) -> TableType -> Finalization -> [PartSpec] -> RevertableProperty +imageBuilt' rebuild img mkchroot tabletype final partspec = + imageBuiltFrom img chrootdir tabletype final partspec `requires` Chroot.provisioned chroot `requires` (cleanrebuild doNothing) `describe` desc @@ -106,8 +107,8 @@ imageBuilt' rebuild img mkchroot tabletype partspec final = & Apt.cacheCleaned -- | Builds a disk image from the contents of a chroot. -imageBuiltFrom :: DiskImage -> FilePath -> TableType -> [PartSpec] -> Finalization -> RevertableProperty -imageBuiltFrom img chrootdir tabletype partspec final = mkimg rmimg +imageBuiltFrom :: DiskImage -> FilePath -> TableType -> Finalization -> [PartSpec] -> RevertableProperty +imageBuiltFrom img chrootdir tabletype final partspec = mkimg rmimg where desc = img ++ " built from " ++ chrootdir mkimg = property desc $ do -- cgit v1.3-2-g0d8e