summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2017-11-16 15:51:21 -0400
committerJoey Hess2017-11-16 15:51:21 -0400
commit540faf8215f8c38e1c6f8da4d82776986eea62a6 (patch)
treecb76aba1fea6137c183c715e62d6d98b1c86c62b
parent73e2ad46bd7472812008745125656661432eb092 (diff)
flash-kernel support
Can be used to create disk images for arm boards using flash-kernel. This commit was sponsored by Ewen McNeill.
-rw-r--r--debian/changelog2
-rw-r--r--joeyconfig.hs9
-rw-r--r--propellor.cabal1
-rw-r--r--src/Propellor/Property/DiskImage.hs1
-rw-r--r--src/Propellor/Property/FlashKernel.hs27
-rw-r--r--src/Propellor/Types/Bootloader.hs4
6 files changed, 39 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index a0290cf4..97beb619 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,8 @@ propellor (4.9.1) UNRELEASED; urgency=medium
* Debootstrap.built now supports bootstrapping chroots for foreign
OS's, using qemu-user-static.
* Qemu: New module.
+ * FlashKernel: New module, can be used to create disk images for arm
+ boards using flash-kernel.
-- Joey Hess <id@joeyh.name> Thu, 02 Nov 2017 10:28:44 -0400
diff --git a/joeyconfig.hs b/joeyconfig.hs
index ad0ce700..31570f45 100644
--- a/joeyconfig.hs
+++ b/joeyconfig.hs
@@ -24,6 +24,7 @@ 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.FlashKernel as FlashKernel
import qualified Propellor.Property.Borg as Borg
import qualified Propellor.Property.Gpg as Gpg
import qualified Propellor.Property.Systemd as Systemd
@@ -94,16 +95,16 @@ darkstar = host "darkstar.kitenet.net" $ props
& Ssh.userKeys (User "joey") hostContext
[ (SshRsa, "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1YoyHxZwG5Eg0yiMTJLSWJ/+dMM6zZkZiR4JJ0iUfP+tT2bm/lxYompbSqBeiCq+PYcSC67mALxp1vfmdOV//LWlbXfotpxtyxbdTcQbHhdz4num9rJQz1tjsOsxTEheX5jKirFNC5OiKhqwIuNydKWDS9qHGqsKcZQ8p+n1g9Lr3nJVGY7eRRXzw/HopTpwmGmAmb9IXY6DC2k91KReRZAlOrk0287LaK3eCe1z0bu7LYzqqS+w99iXZ/Qs0m9OqAPnHZjWQQ0fN4xn5JQpZSJ7sqO38TBAimM+IHPmy2FTNVVn9zGM+vN1O2xr3l796QmaUG1+XLL0shfR/OZbb joey@darkstar")
]
- & imageBuilt (VirtualBoxPointer "/srv/test.vmdk") mychroot MSDOS
+ & imageBuilt (RawDiskImage "/srv/test.img") mychroot MSDOS
[ partition EXT2 `mountedAt` "/boot"
, partition EXT4 `mountedAt` "/"
, swapPartition (MegaBytes 256)
]
where
mychroot d = debootstrapped mempty d $ props
- & osDebian Unstable X86_64
- & Apt.installed ["linux-image-amd64"]
- & Grub.installed PC
+ & osDebian Unstable ARMHF
+ & Apt.installed ["linux-image-armmp", "u-boot"]
+ & FlashKernel.installed "Olimex A10-OLinuXino-LIME"
gnu :: Host
gnu = host "gnu.kitenet.net" $ props
diff --git a/propellor.cabal b/propellor.cabal
index ec3dec32..b08c81c9 100644
--- a/propellor.cabal
+++ b/propellor.cabal
@@ -111,6 +111,7 @@ Library
Propellor.Property.File
Propellor.Property.Firejail
Propellor.Property.Firewall
+ Propellor.Property.FlashKernel
Propellor.Property.FreeBSD
Propellor.Property.FreeBSD.Pkg
Propellor.Property.FreeBSD.Poudriere
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 6c1a572c..7493dd21 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -192,6 +192,7 @@ imageBuilt' rebuild img mkchroot tabletype partspec =
-- installed.
final = case fromInfo (containerInfo chroot) of
[GrubInstalled] -> grubBooted
+ [FlashKernelInstalled] -> \_ _ -> doNothing
[] -> unbootable "no bootloader is installed"
_ -> unbootable "multiple bootloaders are installed; don't know which to use"
diff --git a/src/Propellor/Property/FlashKernel.hs b/src/Propellor/Property/FlashKernel.hs
new file mode 100644
index 00000000..7aa8420b
--- /dev/null
+++ b/src/Propellor/Property/FlashKernel.hs
@@ -0,0 +1,27 @@
+-- | Make ARM systems bootable using Debian's flash-kernel package.
+
+module Propellor.Property.FlashKernel where
+
+import Propellor.Base
+import qualified Propellor.Property.File as File
+import qualified Propellor.Property.Apt as Apt
+import Propellor.Types.Bootloader
+import Propellor.Types.Info
+
+-- | A machine name, such as "Cubietech Cubietruck" or "Olimex A10-OLinuXino-LIME"
+--
+-- flash-kernel supports many different machines,
+-- see its file /usr/share/flash-kernel/db/all.db for a list.
+type Machine = String
+
+-- | Uses flash-kernel to make a machine bootable.
+--
+-- Before using this, an appropriate kernel needs to already be installed,
+-- and on many machines, u-boot needs to be installed too.
+installed :: Machine -> Property (HasInfo + DebianLike)
+installed machine = setInfoProperty go (toInfo [FlashKernelInstalled])
+ where
+ go = "/etc/flash-kernel/machine" `File.hasContent` [machine]
+ `onChange` (cmdProperty "flash-kernel" [] `assume` MadeChange)
+ `requires` File.dirExists "/etc/flash-kernel"
+ `requires` Apt.installed ["flash-kernel"]
diff --git a/src/Propellor/Types/Bootloader.hs b/src/Propellor/Types/Bootloader.hs
index 4a75503a..9822d520 100644
--- a/src/Propellor/Types/Bootloader.hs
+++ b/src/Propellor/Types/Bootloader.hs
@@ -5,7 +5,9 @@ module Propellor.Types.Bootloader where
import Propellor.Types.Info
-- | Boot loader installed on a host.
-data BootloaderInstalled = GrubInstalled
+data BootloaderInstalled
+ = GrubInstalled
+ | FlashKernelInstalled
deriving (Typeable, Show)
instance IsInfo [BootloaderInstalled] where