@@ -7,6 +7,41 @@ config BR2_TARGET_ROOTFS_CPIO
if BR2_TARGET_ROOTFS_CPIO
+choice
+ prompt "cpio type"
+ default BR2_TARGET_ROOTFS_CPIO_FULL
+
+config BR2_TARGET_ROOTFS_CPIO_FULL
+ bool "cpio the whole root filesystem (ie the content of 'target')"
+ help
+ Build a cpio archive containing the whole the root filesystem.
+
+comment "dracut cpio needs busybox, or systemd init system"
+ depends on !BR2_INIT_BUSYBOX
+ depends on !BR2_INIT_SYSTEMD
+
+config BR2_TARGET_ROOTFS_CPIO_DRACUT
+ bool "Invoke dracut to make an initramfs"
+ select BR2_PACKAGE_HOST_DRACUT
+ select BR2_PACKAGE_HOST_UBOOT_TOOLS
+ depends on BR2_INIT_BUSYBOX || BR2_INIT_SYSTEMD
+ help
+ Builds an additional initramfs using dracut.
+ This can be useful to create a recovery system,
+ for instance.
+
+endchoice
+
+if BR2_TARGET_ROOTFS_CPIO_DRACUT
+config BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE
+ string "configuration file"
+endif
+
+
+endif # BR2_TARGET_ROOTFS_CPIO
+
+if BR2_TARGET_ROOTFS_CPIO_FULL
+
choice
prompt "Compression method"
default BR2_TARGET_ROOTFS_CPIO_NONE
@@ -29,6 +29,8 @@ endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT
+ifeq ($(BR2_TARGET_ROOTFS_CPIO_FULL),y)
+
# --reproducible option was introduced in cpio v2.12, which may not be
# available in some old distributions, so we build host-cpio
ifeq ($(BR2_REPRODUCIBLE),y)
@@ -53,4 +55,38 @@ endef
ROOTFS_CPIO_POST_GEN_HOOKS += ROOTFS_CPIO_UBOOT_MKIMAGE
endif
+else ifeq ($(BR2_TARGET_ROOTFS_CPIO_DRACUT),y)
+
+ROOTFS_CPIO_DEPENDENCIES += host-dracut
+
+ifeq ($(BR2_LINUX_KERNEL),y)
+ROOTFS_CPIO_DEPENDENCIES += linux
+endif
+
+ifeq ($(BR_BUILDING).$(BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE),y.)
+$(error No dracut config file name specified, check your BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE setting)
+endif
+
+ifeq ($(BR2_LINUX_KERNEL),y)
+ROOTFS_CPIO_DRACUT_CMD_OPTS += --kver $(LINUX_VERSION_PROBED)
+else
+ROOTFS_CPIO_DRACUT_CMD_OPTS += --no-kernel
+endif
+
+define ROOTFS_CPIO_CMD
+ mkdir -p $(ROOTFS_CPIO_DIR)/tmp
+
+ TARGET_CROSS="$(TARGET_CROSS)" \
+ $(HOST_DIR)/sbin/dracut \
+ $(ROOTFS_CPIO_DRACUT_CMD_OPTS) \
+ -c $(BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE) \
+ --tmpdir $(ROOTFS_CPIO_DIR)/tmp \
+ -M \
+ --force \
+ --keep \
+ $@
+endef
+
+endif #BR2_TARGET_ROOTFS_CPIO_DRACUT
+
$(eval $(rootfs))
new file mode 100644
@@ -0,0 +1,93 @@
+#Simple dracut config for a system without systemd
+
+#Dracut configuration
+
+show_modules=yes
+i18n_install_all=no
+lvmconf=no
+mdadmconf=no
+early_microcode=no
+hostonly=no
+hostonly_cmdline=no
+use_fstab=no
+kernel_cmdline="rd.break=initqueue"
+do_strip=no
+
+# Dracut modules need
+add_dracutmodules+=" \
+busybox-buildroot \
+bash
+"
+
+# Modules to ignore
+omit_dracutmodules+=" \
+biosdevname \
+btrfs \
+bluetooth \
+busybox \
+caps \
+cifs \
+crypt \
+crypt-gpg \
+dash \
+dbus-broker \
+dbus-daemon \
+dm \
+dmraid \
+dmsquash-live-ntfs \
+dracut-systemd \
+fcoe \
+fcoe-uefi \
+fs-lib \
+iscsi \
+i18n \
+lvmmerge \
+lvm \
+lunmask \
+mdraid \
+memstrack \
+mksh \
+modsign \
+mount-root \
+multipath \
+nbd \
+network-legacy \
+network-wicked \
+nfs \
+nvdimm \
+nvmf \
+parse-lunmask \
+qemu \
+qemu-net \
+resume \
+rootfs-block \
+rngd \
+systemd \
+systemd-udevd \
+systemd-coredump \
+systemd-ask-password \
+systemd-timedated \
+systemd-rfkill \
+systemd-resolved \
+systemd-hostnamed \
+systemd-initrd \
+systemd-journald \
+systemd-ldconfig \
+systemd-networkd \
+systemd-timesyncd \
+systemd-veritysetup \
+systemd-modules-load \
+systemd-sysctl \
+systemd-repart \
+systemd-sysext \
+systemd-sysusers \
+systemd-tmpfiles \
+squash \
+ssh-client \
+stratis \
+tpm2-tss \
+udev-rules \
+url-lib \
+usrmount \
+"
+
new file mode 100644
@@ -0,0 +1,44 @@
+import os
+import infra.basetest
+
+CHECK_FS_CMD = "mount | grep 'rootfs on / type rootfs'"
+
+def boot_img(emulator, builddir):
+ img = os.path.join(builddir, "images", "rootfs.cpio")
+ emulator.boot(arch="armv7",
+ kernel="builtin",
+ options=["-initrd", "{}".format(img)])
+ emulator.login()
+ _, exit_code = emulator.run(CHECK_FS_CMD)
+ return exit_code
+
+class TestCpioDracut(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ """
+ BR2_INIT_BUSYBOX=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ BR2_TARGET_ROOTFS_CPIO_DRACUT=y
+ BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE="{}"
+ """.format(infra.filepath("conf/dracut.conf"))
+
+ def test_run(self):
+
+ exit_code = boot_img(self.emulator,
+ self.builddir)
+ self.assertEqual(exit_code, 0)
+
+class TestCpioFull(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ """
+ BR2_INIT_BUSYBOX=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ BR2_TARGET_ROOTFS_CPIO_FULL=y
+ """
+
+ def test_run(self):
+
+ exit_code = boot_img(self.emulator,
+ self.builddir)
+ self.assertEqual(exit_code, 0)
+
+