diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-11-16 17:54:47 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-11-16 17:54:47 -0400 |
| commit | cff178de9c0d229574ab884fcca08a41f434e119 (patch) | |
| tree | 6208a18ba662ea907eb51db6196ff54c0577b543 /src/Propellor/Property/Uboot.hs | |
| parent | 19feb8451b75ae669b45add9e9d9851a542fd981 (diff) | |
Uboot: New module.
Installing u-boot to the boot sector is not needed by some boards
(my CubieTruck boots without it), but may be by others.
Tricky part was making u-boot be written to a disk image when building one.
This commit was sponsored by Jake Vosloo on Patreon.
Diffstat (limited to 'src/Propellor/Property/Uboot.hs')
| -rw-r--r-- | src/Propellor/Property/Uboot.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Propellor/Property/Uboot.hs b/src/Propellor/Property/Uboot.hs new file mode 100644 index 00000000..70b4dd68 --- /dev/null +++ b/src/Propellor/Property/Uboot.hs @@ -0,0 +1,36 @@ +module Propellor.Property.Uboot where + +import Propellor.Base +import Propellor.Types.Info +import Propellor.Types.Bootloader +import Propellor.Property.Chroot +import Propellor.Property.Mount +import qualified Propellor.Property.Apt as Apt + +-- | Name of a board. +type BoardName = String + +-- | Installs u-boot for Allwinner/sunxi platforms. +-- +-- This includes writing it to the boot sector. +sunxi :: BoardName -> Property (HasInfo + DebianLike) +sunxi boardname = setInfoProperty (check (not <$> inChroot) go) info + `requires` Apt.installed ["u-boot", "u-boot-sunxi"] + where + go :: Property Linux + go = property' "u-boot installed" $ \w -> do + v <- liftIO $ getMountContaining "/boot" + case v of + Nothing -> error "unable to determine boot device" + Just dev -> ensureProperty w (dd dev "/") + dd :: FilePath -> FilePath -> Property Linux + dd dev prefix = tightenTargets $ cmdProperty "dd" + [ "conv=fsync,notrunc" + , "if=" ++ prefix </> "/usr/lib/u-boot" + </> boardname </> "u-boot-sunxi-with-spl.bin" + , "of=" ++ dev + , "bs=1024" + , "seek=8" + ] + `assume` NoChange + info = toInfo [UbootInstalled dd] |
