Message ID | 20211219073119.1087539-3-thierry.bultel@linatsea.fr |
---|---|
State | Superseded |
Headers | show |
Series | [v2,1/3] package/cross-ldd: new package | expand |
Hello Thierry, On Sun, 19 Dec 2021 08:31:19 +0100 Thierry Bultel <thierry.bultel@linatsea.fr> wrote: > Adds an option to invoke the dracut host tool, providing > a configuration file, instead of having a full cpio archive > of the whole target directory. > > Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr> > Changes v1 -> v2 (suggested by Arnoult and Yann) > - was a new fs type, now an option of cpio > - deals with the case of a build with no kernel > - gets the kernel name in a smarter way > - checks for the name of dracut configuration file > > Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr> Thanks for working on this! What would be nice is to add a test case in support/testing/ for this. We already have lots of tests for various filesystem types in support/testing/tests/fs. Thanks! Thomas
Le 19/12/2021 à 11:13, Thomas Petazzoni a écrit : > Hello Thierry, > > On Sun, 19 Dec 2021 08:31:19 +0100 > Thierry Bultel <thierry.bultel@linatsea.fr> wrote: > >> Adds an option to invoke the dracut host tool, providing >> a configuration file, instead of having a full cpio archive >> of the whole target directory. >> >> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr> >> Changes v1 -> v2 (suggested by Arnoult and Yann) >> - was a new fs type, now an option of cpio >> - deals with the case of a build with no kernel >> - gets the kernel name in a smarter way >> - checks for the name of dracut configuration file >> >> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr> > Thanks for working on this! What would be nice is to add a test case in > support/testing/ for this. We already have lots of tests for various > filesystem types in support/testing/tests/fs. Thanks Thomas, done and just submitted in my v3 patches. The tests also cover the full cpio mode, and revealed some unhandled cases in dracut mode, where the uClibc required to pay more attention. Cheers Thierry > > Thanks! > > Thomas
diff --git a/fs/cpio/Config.in b/fs/cpio/Config.in index c1151a2881..09c5bf46d3 100644 --- a/fs/cpio/Config.in +++ b/fs/cpio/Config.in @@ -7,6 +7,34 @@ config BR2_TARGET_ROOTFS_CPIO if BR2_TARGET_ROOTFS_CPIO +choice + prompt "cpio type" +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. + +config BR2_TARGET_ROOTFS_CPIO_DRACUT + bool "Invoke dracut to make an initramfs" + depends on BR2_LINUX_KERNEL + select BR2_PACKAGE_HOST_DRACUT + select BR2_PACKAGE_HOST_UBOOT_TOOLS + help + Builds an additional initramfs using dracut. + This can be useful to create a recovery system, + for instance. + +if BR2_TARGET_ROOTFS_CPIO_DRACUT +config BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE + string "configuration file" +endif + +endchoice + +endif # BR2_TARGET_ROOTFS_CPIO + +if BR2_TARGET_ROOTFS_CPIO_FULL + choice prompt "Compression method" default BR2_TARGET_ROOTFS_CPIO_NONE diff --git a/fs/cpio/cpio.mk b/fs/cpio/cpio.mk index 81f8c393d1..c5fbb05a57 100644 --- a/fs/cpio/cpio.mk +++ b/fs/cpio/cpio.mk @@ -29,6 +29,41 @@ endif # BR2_ROOTFS_DEVICE_CREATION_STATIC ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT +ifeq ($(BR2_TARGET_ROOTFS_CPIO_DRACUT),y) + +export TARGET_CROSS +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 $(@D)/tmp + rm -rf $(@D)/tmp/* + + $(HOST_DIR)/usr/bin/dracut_wrapper.sh \ + $(ROOTFS_CPIO_DRACUT_CMD_OPTS) \ + -c $(BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE) \ + --tmpdir $(@D)/tmp \ + -M \ + --force \ + --keep \ + $@ +endef + +else 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 +88,6 @@ endef ROOTFS_CPIO_POST_GEN_HOOKS += ROOTFS_CPIO_UBOOT_MKIMAGE endif +endif #BR2_TARGET_ROOTFS_CPIO_DRACUT + $(eval $(rootfs))