diff options
| -rw-r--r-- | joeyconfig.hs | 8 | ||||
| -rw-r--r-- | src/Propellor/Property/DiskImage.hs | 24 | ||||
| -rw-r--r-- | src/Propellor/Property/FlashKernel.hs | 36 |
3 files changed, 57 insertions, 11 deletions
diff --git a/joeyconfig.hs b/joeyconfig.hs index 0a018826..48eff2ec 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -6,6 +6,7 @@ import Propellor import Propellor.Property.Scheduled import Propellor.Property.DiskImage import Propellor.Property.Chroot +import Propellor.Property.Machine import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Network as Network @@ -24,7 +25,6 @@ import qualified Propellor.Property.Postfix as Postfix import qualified Propellor.Property.Apache as Apache import qualified Propellor.Property.LetsEncrypt as LetsEncrypt import qualified Propellor.Property.Grub as Grub -import qualified Propellor.Property.Machine as Machine import qualified Propellor.Property.Borg as Borg import qualified Propellor.Property.Gpg as Gpg import qualified Propellor.Property.Systemd as Systemd @@ -109,12 +109,12 @@ darkstar = host "darkstar.kitenet.net" $ props sheevaplug :: Host sheevaplug = host "sheevaplug.kitenet.net" $ props & osDebian Unstable ARMEL - & Machine.marvell_SheevaPlug Machine.Marvell_SheevaPlug_SDCard + & marvell_SheevaPlug Marvell_SheevaPlug_SDCard lime :: Host lime = host "lime.kitenet.net" $ props & osDebian Unstable ARMHF - & Machine.olimex_A10_OLinuXino_LIME + & olimex_A10_OLinuXino_LIME gnu :: Host gnu = host "gnu.kitenet.net" $ props @@ -200,7 +200,7 @@ honeybee = host "honeybee.kitenet.net" $ props -- and try to be robust. & "/etc/default/rcS" `File.containsLine` "FSCKFIX=yes" - & Machine.cubietech_Cubietruck + & cubietech_Cubietruck & Apt.installed ["firmware-brcm80211"] -- Workaround for https://bugs.debian.org/844056 `requires` File.hasPrivContent "/lib/firmware/brcm/brcmfmac43362-sdio.txt" anyContext diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index 69a4b188..08306106 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -28,6 +28,7 @@ import qualified Propellor.Property.Grub as Grub import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Qemu as Qemu +import qualified Propellor.Property.FlashKernel as FlashKernel import Propellor.Property.Parted import Propellor.Property.Fstab (SwapPartition(..), genFstab) import Propellor.Property.Partition @@ -193,13 +194,14 @@ imageBuilt' rebuild img mkchroot tabletype partspec = -- installed. final = case fromInfo (containerInfo chroot) of [] -> unbootable "no bootloader is installed" - l -> case filter (not . ignorablefinal) l of - [] -> \_ _ _ -> doNothing - [GrubInstalled] -> grubFinalized - [UbootInstalled p] -> ubootFinalized p - _ -> unbootable $ "multiple bootloaders are installed; don't know which to use: " ++ show l - ignorablefinal FlashKernelInstalled = True - ignorablefinal _ = False + [GrubInstalled] -> grubFinalized + [UbootInstalled p] -> ubootFinalized p + [FlashKernelInstalled] -> flashKernelFinalized + [UbootInstalled p, FlashKernelInstalled] -> + ubootFlashKernelFinalized p + [FlashKernelInstalled, UbootInstalled p] -> + ubootFlashKernelFinalized p + _ -> unbootable "multiple bootloaders are installed; don't know which to use" -- | This property is automatically added to the chroot when building a -- disk image. It cleans any caches of information that can be omitted; @@ -427,6 +429,14 @@ grubFinalized _img mnt loopdevs = Grub.bootsMounted mnt wholediskloopdev ubootFinalized :: (FilePath -> FilePath -> Property Linux) -> Finalization ubootFinalized p (RawDiskImage img) mnt _loopdevs = p img mnt +flashKernelFinalized :: Finalization +flashKernelFinalized _img mnt _loopdevs = FlashKernel.flashKernelMounted mnt + +ubootFlashKernelFinalized :: (FilePath -> FilePath -> Property Linux) -> Finalization +ubootFlashKernelFinalized p img mnt loopdevs = + ubootFinalized p img mnt loopdevs + `before` flashKernelFinalized img mnt loopdevs + isChild :: FilePath -> Maybe MountPoint -> Bool isChild mntpt (Just d) | d `equalFilePath` mntpt = False diff --git a/src/Propellor/Property/FlashKernel.hs b/src/Propellor/Property/FlashKernel.hs index 7aa8420b..3f65f872 100644 --- a/src/Propellor/Property/FlashKernel.hs +++ b/src/Propellor/Property/FlashKernel.hs @@ -5,6 +5,7 @@ module Propellor.Property.FlashKernel where import Propellor.Base import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt +import Propellor.Property.Mount import Propellor.Types.Bootloader import Propellor.Types.Info @@ -25,3 +26,38 @@ installed machine = setInfoProperty go (toInfo [FlashKernelInstalled]) `onChange` (cmdProperty "flash-kernel" [] `assume` MadeChange) `requires` File.dirExists "/etc/flash-kernel" `requires` Apt.installed ["flash-kernel"] + +-- | Runs flash-kernel in the system mounted at a particular directory. +flashKernelMounted :: FilePath -> Property Linux +flashKernelMounted mnt = combineProperties desc $ props + -- remove mounts that are done below to make sure the right thing + -- gets mounted + & cleanupmounts + & bindMount "/dev" (inmnt "/dev") + & mounted "proc" "proc" (inmnt "/proc") mempty + & mounted "sysfs" "sys" (inmnt "/sys") mempty + -- update the initramfs so it gets the uuid of the root partition + & inchroot "update-initramfs" ["-u"] + `assume` MadeChange + & inchroot "flash-kernel" [] + `assume` MadeChange + & cleanupmounts + where + desc = "flash-kernel run" + + -- cannot use </> since the filepath is absolute + inmnt f = mnt ++ f + + inchroot cmd ps = cmdProperty "chroot" ([mnt, cmd] ++ ps) + + cleanupmounts :: Property Linux + cleanupmounts = property desc $ liftIO $ do + cleanup "/sys" + cleanup "/proc" + cleanup "/dev" + return NoChange + where + cleanup m = + let mp = inmnt m + in whenM (isMounted mp) $ + umountLazy mp |
