Re: [Buildroot] [PATCH 3/3] fs/dracut: new fs type
From: Thierry Bultel <hidden>
Date: 2021-12-17 11:04:52
Hi,
quoted
+ 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_DRACUT +config BR2_TARGET_ROOTFS_DRACUT_CONF_FILE + string "configuration file"Is there a possibility for a default configuration file?
Would that really make sense ? What would be default the expected packages in the ram disk ? Notice that the content of the config file strongly depends on the init system (dracut being mostly thought for systemd, but I use it with busybox/init.d in my case). But I agree that I must add an error in the .mk when the file is not specified/does not exist (more notes below)
quoted
+endif +diff --git a/fs/dracut/dracut.mk b/fs/dracut/dracut.mk new file mode 100644 index 0000000000..9c91150e82 --- /dev/null +++ b/fs/dracut/dracut.mk@@ -0,0 +1,55 @@ +################################################################################ +# +# dracut to archive target filesystem +# +################################################################################ + +ROOTFS_DRACUT_DEPENDENCIES = host-dracut host-uboot-tools + +ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y) + +define ROOTFS_DRACUT_ADD_INIT + if [ ! -e $(TARGET_DIR)/init ]; then \ + ln -sf sbin/init $(TARGET_DIR)/init; \ + fi +endef + +else + +# devtmpfs does not get automounted when initramfs is used. +# Add a pre-init script to mount it before running init +# We must have /dev/console very early, even before /init runs, +# for stdin/stdout/stderr +define ROOTFS_DRACUT_ADD_INIT + if [ ! -e $(TARGET_DIR)/init ]; then \ + $(INSTALL) -m 0755 fs/cpio/init $(TARGET_DIR)/init; \ + fi + mkdir -p $(TARGET_DIR)/dev + mknod -m 0622 $(TARGET_DIR)/dev/console c 5 1 +endef + +endif # BR2_ROOTFS_DEVICE_CREATION_STATICThe above is the same logic as in cpio.mk. It would be better if we could refactor that to a common place.
I definitively agree, that is what I said myself. But what is the most appropriate place to put it ?
quoted
+ +ROOTFS_DRACUT_PRE_GEN_HOOKS += ROOTFS_DRACUT_ADD_INIT + +define ROOTFS_DRACUT_CMD + + mkdir -p $(@D)/tmp + rm -rf $(@D)/tmp/* + + DRACUT_LDD=$(TARGET_CROSS)ldd \ + DRACUT_INSTALL="$(HOST_DIR)/lib/dracut/dracut-install"\ + dracutbasedir=$(HOST_DIR)/usr/lib/dracut \It would be nice if all of the above could be patches into host-dracut, so when called from a post-image script, it's not needed to pass all of that in.
This time, I do not agree. I contrary to some tools that are not thought for cross environments, and that deserve patching to behave the appropriate way, dracut is designed for that. At various places it checks the given environment variables (in both bash and C), and this is the way to use it.
You should also check then if it gets properly updated by support/misc/relocate-sdk.sh (I think yes).
I am sorry, but I do not see the point here, would you mind explain please ?
quoted
+ dracutsysrootdir=$(TARGET_DIR) \ + $(HOST_DIR)/bin/dracut \ + --kver $(BR2_LINUX_KERNEL_VERSION).0 \This should be indented with a second tab. Also, you can't use BR2_LINUX_KERNEL_VERSION because that's only available if BR2_LINUX_KERNEL=y. So either you have to depend on that, or you need to add an option to Config.in to be able to set it. Also, you should probably use LINUX_VERSION_PROBED instead (at least if you need an actual kernel version, and not some commit hash or something). Also, what is the .0 appended to it?
Dracut needs the /lib/modules/x.x.x directory name When a 5.10 kernel is selected, modules go to /lib/modules/5.10.0 Thanks for the LINUX_VERSION_PROBED, this is what I needed !
quoted
+ -c $(BR2_TARGET_ROOTFS_DRACUT_CONF_FILE) \We normally have a check in the makefile to exit immediately if the option is not set. See for example in linux-backports. Note that it needs to be in a BR_BUILDING condition.
Ok, I will check that Regards Thierrt
Regards, Arnoutquoted
+ --tmpdir $(@D)/tmp \ + -M \ + --force \ + --keep \ + $@ + +endef + +$(eval $(rootfs))
-- Re: test www.linatsea.fr <www.linatsea.fr> -- www.linatsea.fr