All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package
@ 2021-12-23 11:13 Thierry Bultel
  2021-12-23 11:13 ` [Buildroot] [PATCH v3 2/3] package/dracut: new host package Thierry Bultel
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Thierry Bultel @ 2021-12-23 11:13 UTC (permalink / raw)
  To: buildroot; +Cc: Thierry Bultel, Thomas Petazzoni

cross-ldd works just as ldd, but supports
other architectures. It is needed by dracut, for instance.

Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
Changes v1 -> v2:
  - simplified the download (suggested by Arnoult)
Changes v2 -> v3
  - changed the name to -ldd-cross, in order to avoid
    a conflict with the external toolchains that implement it

Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
 package/Config.in              |  1 +
 package/cross-ldd/Config.in    |  7 +++++++
 package/cross-ldd/cross-ldd.mk | 19 +++++++++++++++++++
 3 files changed, 27 insertions(+)
 create mode 100644 package/cross-ldd/Config.in
 create mode 100644 package/cross-ldd/cross-ldd.mk

diff --git a/package/Config.in b/package/Config.in
index bcb23132c9..5d0f858c03 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -162,6 +162,7 @@ menu "Development tools"
 	source "package/check/Config.in"
 	source "package/cmake/Config.in"
 	source "package/cppunit/Config.in"
+	source "package/cross-ldd/Config.in"
 	source "package/cukinia/Config.in"
 	source "package/cunit/Config.in"
 	source "package/cvs/Config.in"
diff --git a/package/cross-ldd/Config.in b/package/cross-ldd/Config.in
new file mode 100644
index 0000000000..3858fbc5fe
--- /dev/null
+++ b/package/cross-ldd/Config.in
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_HOST_CROSS_LDD
+	bool "cross-ldd"
+	help
+	  ldd drop-in replacement for cross-compilation
+	  toolchains.
+	  This is the officially supported version mentioned
+	  in the dracut documentation
diff --git a/package/cross-ldd/cross-ldd.mk b/package/cross-ldd/cross-ldd.mk
new file mode 100644
index 0000000000..fc0752adff
--- /dev/null
+++ b/package/cross-ldd/cross-ldd.mk
@@ -0,0 +1,19 @@
+################################################################################
+#
+# cross-ldd
+#
+################################################################################
+
+CROSS_LDD_VERSION = 6c9c724ebd6a29c279c6e5734e44c07f067808ec
+CROSS_LDD_SOURCE = $(CROSS_LDD_VERSION).tar.gz
+CROSS_LDD_SITE = https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f/archive
+
+# Notice that we change the name to '-ldd-cross', in order to avoid conflict
+# with some external toolchains that implement it
+
+define HOST_CROSS_LDD_INSTALL_CMDS
+	$(SED) 's/-ldd}/-ldd-cross}'/g $(@D)/cross-compile-ldd
+	install -D -m 755 $(@D)/cross-compile-ldd $(TARGET_CROSS)ldd-cross
+endef
+
+$(eval $(host-generic-package))
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH v3 2/3] package/dracut: new host package
  2021-12-23 11:13 [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package Thierry Bultel
@ 2021-12-23 11:13 ` Thierry Bultel
  2022-01-05 23:16   ` Yann E. MORIN
  2021-12-23 11:13 ` [Buildroot] [PATCH v3 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
  2022-01-05 22:29 ` [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package Yann E. MORIN
  2 siblings, 1 reply; 10+ messages in thread
From: Thierry Bultel @ 2021-12-23 11:13 UTC (permalink / raw)
  To: buildroot; +Cc: Thierry Bultel, Thomas Petazzoni

dracut is the tool used by desktop distributions to
build initrds. In the embedded world, it can be
very usefull, too, for instance when wanting to
create an initramfs for a system recovery mode.
Whereas it is definitively possible to achieve
this with buildroot, the process is to have a
dedicated buildroot configuration for that,
and perform a full build. Instead of doing that,
the idea is to use dracut to pick the needed
binaries/shared libraries, configuration files,
or kernel modules from the 'target' directory.
The advantage is to save build time, and also
to have a consistency between the packages versions
taken for the recovery and the production filesystem.

Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
Changes v1 -> v2 (all suggested by Arnoult)
  - added a wrapper script
Changes v2 -> v2
  - added modules for:
     - supporting busybox system init type
     - fixing a missing symlink for uClibc

Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
 package/Config.in.host                        |  1 +
 .../05busybox-buildroot/module-setup.sh       | 69 +++++++++++++++++++
 package/dracut/06uclibc/module-setup.sh       | 20 ++++++
 package/dracut/Config.in.host                 | 10 +++
 package/dracut/dracut.mk                      | 45 ++++++++++++
 package/dracut/dracut_wrapper.sh              | 15 ++++
 6 files changed, 160 insertions(+)
 create mode 100755 package/dracut/05busybox-buildroot/module-setup.sh
 create mode 100644 package/dracut/06uclibc/module-setup.sh
 create mode 100644 package/dracut/Config.in.host
 create mode 100644 package/dracut/dracut.mk
 create mode 100644 package/dracut/dracut_wrapper.sh

diff --git a/package/Config.in.host b/package/Config.in.host
index 6e5a5c5fc5..72531374f4 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -14,6 +14,7 @@ menu "Host utilities"
 	source "package/cramfs/Config.in.host"
 	source "package/cryptsetup/Config.in.host"
 	source "package/dbus-python/Config.in.host"
+	source "package/dracut/Config.in.host"
 	source "package/dfu-util/Config.in.host"
 	source "package/dos2unix/Config.in.host"
 	source "package/dosfstools/Config.in.host"
diff --git a/package/dracut/05busybox-buildroot/module-setup.sh b/package/dracut/05busybox-buildroot/module-setup.sh
new file mode 100755
index 0000000000..b227571db4
--- /dev/null
+++ b/package/dracut/05busybox-buildroot/module-setup.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+check() {
+	require_binaries \
+		busybox | return 1
+
+	return 0
+}
+
+depends() {
+	return 0
+}
+
+
+install_busybox_links() {
+	dir=$1
+	linkname=$2
+
+	(cd "$dracutsysrootdir"$dir &&
+	for x in *; do
+	    if [ "$(readlink "$x")" = $linkname ]; then
+	    	ln -sf $linkname $initdir/$dir/$x
+	    fi
+	done
+	)
+
+}
+
+install() {
+
+	inst_multiple /bin/busybox
+
+	# wrapper script for early console; will launch /sbin/init
+	# after having mounted devtmpfs
+	inst_multiple /init
+
+	ln -s ../bin/busybox $initdir/sbin/init
+
+	if [ -e $dracutsysrootdir/lib64 ]; then
+		ln -s lib $initdir/lib64
+		ln -s lib $initdir/usr/lib64
+	fi
+
+	if [ -e $dracutsysrootdir/lib32 ]; then
+		ln -s lib $initdir/lib32
+		ln -s lib $initdir/usr/lib32
+	fi
+	
+	install_busybox_links "/bin" "busybox"
+	install_busybox_links "/sbin" "../bin/busybox"
+	install_busybox_links "/usr/bin" "../../bin/busybox" 
+	install_busybox_links "/usr/sbin" "../../bin/busybox"
+	
+	inst_multiple \
+		/etc/inittab	\
+		/etc/init.d/rcS \
+		/etc/init.d/rcK \
+		/etc/issue	\
+		/etc/fstab	\
+		/etc/group	\
+		/etc/passwd	\
+		/etc/shadow	\
+		/etc/hostname
+	
+#	mkdir -p $initdir/etc/init.d
+#	cp -a $dracutsysrootdir/etc/init.d/* $initdir/etc/init.d
+	
+}
+
diff --git a/package/dracut/06uclibc/module-setup.sh b/package/dracut/06uclibc/module-setup.sh
new file mode 100644
index 0000000000..77e9bd864e
--- /dev/null
+++ b/package/dracut/06uclibc/module-setup.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+check() {
+	return 0
+}
+
+depends() {
+	return 0
+}
+
+
+
+install() {
+
+	# Despite of the fact that the listed dependency (reported by readelf -d)
+	# is purely ld-uClibc.so.1, the loader needs the ld-uClibc.so.0, too
+
+	ln -s ld-uClibc.so.1 $initdir/lib/ld-uClibc.so.0
+
+}
diff --git a/package/dracut/Config.in.host b/package/dracut/Config.in.host
new file mode 100644
index 0000000000..074d46f623
--- /dev/null
+++ b/package/dracut/Config.in.host
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_HOST_DRACUT
+	bool
+	select BR2_PACKAGE_HOST_KMOD
+	select BR2_PACKAGE_HOST_CROSS_LDD
+	help
+	  dracut is used to create an initramfs image by
+	  copying tools and files from an installed system
+	  and combining it with the dracut framework.
+
+	  https://dracut.wiki.kernel.org
diff --git a/package/dracut/dracut.mk b/package/dracut/dracut.mk
new file mode 100644
index 0000000000..6c82b4ba75
--- /dev/null
+++ b/package/dracut/dracut.mk
@@ -0,0 +1,45 @@
+################################################################################
+#
+# dracut
+#
+################################################################################
+
+DRACUT_VERSION = 055
+DRACUT_SOURCE = dracut-$(DRACUT_VERSION).tar.xz
+DRACUT_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/boot/dracut
+DRACUT_LICENSE = GPL-2.0
+DRACUT_LICENSE_FILES = COPYING
+
+HOST_DRACUT_DEPENDENCIES += host-pkgconf host-kmod host-cross-ldd
+
+define HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT
+	$(SED) '/unset LD_LIBRARY_PATH/d' $(HOST_DIR)/bin/dracut
+	$(SED) '/unset LD_PRELOAD/d' $(HOST_DIR)/bin/dracut
+endef
+
+define HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
+	$(INSTALL) -D -m 0755 package/dracut/dracut_wrapper.sh \
+		$(HOST_DIR)/usr/bin/dracut_wrapper.sh
+endef
+
+ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
+define HOST_DRACUT_POST_INSTALL_UCLIBC_MODULE
+	$(INSTALL) -D -m 0755 package/dracut/06uclibc/module-setup.sh \
+		$(HOST_DIR)/lib/dracut/modules.d/06uclibc/module-setup.sh
+endef
+HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_UCLIBC_MODULE
+endif
+
+ifeq ($(BR2_INIT_BUSYBOX),y)
+define HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE
+	$(INSTALL) -D -m 0755 package/dracut/05busybox-buildroot/module-setup.sh \
+		$(HOST_DIR)/lib/dracut/modules.d/05busybox-buildroot/module-setup.sh
+endef
+HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE
+
+endif
+
+HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT
+HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
+
+$(eval $(host-autotools-package))
diff --git a/package/dracut/dracut_wrapper.sh b/package/dracut/dracut_wrapper.sh
new file mode 100644
index 0000000000..9d3db3b58e
--- /dev/null
+++ b/package/dracut/dracut_wrapper.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+set -x
+
+if [ -z "$*" ]; then
+    echo "No argument supplied"
+    exit
+fi
+
+DRACUT_LDD=${TARGET_CROSS}ldd-cross \
+DRACUT_INSTALL="${HOST_DIR}/lib/dracut/dracut-install" \
+dracutbasedir=${HOST_DIR}/usr/lib/dracut \
+dracutsysrootdir=${TARGET_DIR} \
+${HOST_DIR}/bin/dracut "$@"
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH v3 3/3] fs/cpio: new option to use dracut tool
  2021-12-23 11:13 [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package Thierry Bultel
  2021-12-23 11:13 ` [Buildroot] [PATCH v3 2/3] package/dracut: new host package Thierry Bultel
@ 2021-12-23 11:13 ` Thierry Bultel
  2022-01-06 10:31   ` Yann E. MORIN
  2022-01-05 22:29 ` [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package Yann E. MORIN
  2 siblings, 1 reply; 10+ messages in thread
From: Thierry Bultel @ 2021-12-23 11:13 UTC (permalink / raw)
  To: buildroot; +Cc: Thierry Bultel, Thomas Petazzoni

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
Changes v2 -> v3
  - fixed a typo on the --no-kernel option for dracut
  - removed the unneeded dependency to kernel
  - added tests for cpio, for both full, and dracut modes

Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
 fs/cpio/Config.in                     | 27 ++++++++
 fs/cpio/cpio.mk                       | 37 +++++++++++
 support/testing/conf/dracut.conf      | 93 +++++++++++++++++++++++++++
 support/testing/tests/fs/test_cpio.py | 44 +++++++++++++
 4 files changed, 201 insertions(+)
 create mode 100644 support/testing/conf/dracut.conf
 create mode 100644 support/testing/tests/fs/test_cpio.py

diff --git a/fs/cpio/Config.in b/fs/cpio/Config.in
index c1151a2881..3d0f963a8d 100644
--- a/fs/cpio/Config.in
+++ b/fs/cpio/Config.in
@@ -7,6 +7,33 @@ 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"
+	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..e0e0eb2b1e 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))
diff --git a/support/testing/conf/dracut.conf b/support/testing/conf/dracut.conf
new file mode 100644
index 0000000000..eb793a3562
--- /dev/null
+++ b/support/testing/conf/dracut.conf
@@ -0,0 +1,93 @@
+#Yuco dracut config
+
+#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 \
+"
+
diff --git a/support/testing/tests/fs/test_cpio.py b/support/testing/tests/fs/test_cpio.py
new file mode 100644
index 0000000000..5570693dc2
--- /dev/null
+++ b/support/testing/tests/fs/test_cpio.py
@@ -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)
+
+
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package
  2021-12-23 11:13 [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package Thierry Bultel
  2021-12-23 11:13 ` [Buildroot] [PATCH v3 2/3] package/dracut: new host package Thierry Bultel
  2021-12-23 11:13 ` [Buildroot] [PATCH v3 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
@ 2022-01-05 22:29 ` Yann E. MORIN
  2 siblings, 0 replies; 10+ messages in thread
From: Yann E. MORIN @ 2022-01-05 22:29 UTC (permalink / raw)
  To: Thierry Bultel; +Cc: Thomas Petazzoni, buildroot

Thierry, All,

On 2021-12-23 12:13 +0100, Thierry Bultel spake thusly:
> cross-ldd works just as ldd, but supports
> other architectures. It is needed by dracut, for instance.
> 
> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
> ---
[--SNIP--]
> diff --git a/package/cross-ldd/Config.in b/package/cross-ldd/Config.in
> new file mode 100644
> index 0000000000..3858fbc5fe
> --- /dev/null
> +++ b/package/cross-ldd/Config.in
> @@ -0,0 +1,7 @@
> +config BR2_PACKAGE_HOST_CROSS_LDD
> +	bool "cross-ldd"

I don't think this tool warrants a Kconfig entry. I.e. it should be a
blind host-only package, with no Config.in.

> +	help
> +	  ldd drop-in replacement for cross-compilation
> +	  toolchains.
> +	  This is the officially supported version mentioned
> +	  in the dracut documentation

It would have been nice to add a pointer to that documentation (I spent
quite some time look for it...). It's in: docs/README.cross

> diff --git a/package/cross-ldd/cross-ldd.mk b/package/cross-ldd/cross-ldd.mk
> new file mode 100644
> index 0000000000..fc0752adff
> --- /dev/null
> +++ b/package/cross-ldd/cross-ldd.mk
> @@ -0,0 +1,19 @@
> +################################################################################
> +#
> +# cross-ldd
> +#
> +################################################################################
> +
> +CROSS_LDD_VERSION = 6c9c724ebd6a29c279c6e5734e44c07f067808ec
> +CROSS_LDD_SOURCE = $(CROSS_LDD_VERSION).tar.gz
> +CROSS_LDD_SITE = https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f/archive

I find it really sad that we have to use a random gist without proper
packaging or repository... :-( But I guess we don't have much options...

You are missing the license for that script:

    CROSS_LDD_LICENSE = GPL-2.0

(I should know, I wrote it! ;-) And incidentally, it is also mentioned
in the help text.)

> +# Notice that we change the name to '-ldd-cross', in order to avoid conflict
> +# with some external toolchains that implement it

-ldd-cross is still too generic. Make it really specific to buildroot, by
calling it -ldd-buildroot

> +define HOST_CROSS_LDD_INSTALL_CMDS
> +	$(SED) 's/-ldd}/-ldd-cross}'/g $(@D)/cross-compile-ldd
> +	install -D -m 755 $(@D)/cross-compile-ldd $(TARGET_CROSS)ldd-cross
> +endef

This install comand does two things:

  - modify the source script
  - install the modified script

Semantically, we want to separate actions that happen in the source tree
into one of the extract, patch, configure, or build commands.

Also, usually, we shy away from patching with sed expressions, and we
prefer actual patches.

Regards,
Yann E. MORIN.

> +
> +$(eval $(host-generic-package))
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Buildroot] [PATCH v3 2/3] package/dracut: new host package
  2021-12-23 11:13 ` [Buildroot] [PATCH v3 2/3] package/dracut: new host package Thierry Bultel
@ 2022-01-05 23:16   ` Yann E. MORIN
  2022-01-06 14:56     ` Thierry Bultel
  0 siblings, 1 reply; 10+ messages in thread
From: Yann E. MORIN @ 2022-01-05 23:16 UTC (permalink / raw)
  To: Thierry Bultel; +Cc: Thomas Petazzoni, buildroot

Thierry, All,

On 2021-12-23 12:13 +0100, Thierry Bultel spake thusly:
> dracut is the tool used by desktop distributions to
> build initrds. In the embedded world, it can be
> very usefull, too, for instance when wanting to
> create an initramfs for a system recovery mode.
> Whereas it is definitively possible to achieve
> this with buildroot, the process is to have a
> dedicated buildroot configuration for that,
> and perform a full build. Instead of doing that,
> the idea is to use dracut to pick the needed
> binaries/shared libraries, configuration files,
> or kernel modules from the 'target' directory.
> The advantage is to save build time, and also
> to have a consistency between the packages versions
> taken for the recovery and the production filesystem.

Please, wrap your commit log to ~72 chars.

> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
> ---
[--SNIP--]
> diff --git a/package/dracut/05busybox-buildroot/module-setup.sh b/package/dracut/05busybox-buildroot/module-setup.sh
> new file mode 100755
> index 0000000000..b227571db4
> --- /dev/null
> +++ b/package/dracut/05busybox-buildroot/module-setup.sh

You will have to (briefly, maybe) explain how those 'modules' are meant
to be used...

> @@ -0,0 +1,69 @@
> +#!/bin/bash

... here you make it an executable (0755) shell script, but it only
defines functions, it actually calls nothing. Are moduels supposed to be
source-d from dracut itself?

> +check() {
> +	require_binaries \
> +		busybox | return 1

This can't possibly work: it will always fail (there is a single pipe,
so the whole command will fail).

Then what happens depends on whether the shell is set -e or not. If it
is not set -e, the execution continues, and the check() function will
always return 0 (success). If the shell is set -e, then execution of
check() ends right there, and presumably check() is called as an
if-block condition, and thus the condition will never be true.

So, it was not tested? ;-)

(also: commands that fit on a line should be on a single line, like so:
    require_binaries busybox || return 1
)

> +	return 0
> +}
> +
> +depends() {
> +	return 0
> +}
> +
> +
> +install_busybox_links() {
> +	dir=$1
> +	linkname=$2
> +
> +	(cd "$dracutsysrootdir"$dir &&

    $ shellcheck package/dracut/05busybox-buildroot/module-setup.sh
        (cd "$dracutsysrootdir"$dir &&
                               ^--^ SC2086: Double quote to prevent globbing and word splitting.

Also, please do variable expansion with curly braces (everywhere):

    "${dracutsysrootdir}${dir}"

> +	for x in *; do
> +	    if [ "$(readlink "$x")" = $linkname ]; then
> +	    	ln -sf $linkname $initdir/$dir/$x
> +	    fi
> +	done
> +	)
> +
> +}
> +
> +install() {
> +

No initial empty line at begining of function.

[--SNIP--]
> +#	mkdir -p $initdir/etc/init.d
> +#	cp -a $dracutsysrootdir/etc/init.d/* $initdir/etc/init.d

Commented-out debug code or non-function code should just be removed.

> +	

No empty line at the end of function.

> +}
> +
> diff --git a/package/dracut/06uclibc/module-setup.sh b/package/dracut/06uclibc/module-setup.sh
> new file mode 100644
> index 0000000000..77e9bd864e
> --- /dev/null
> +++ b/package/dracut/06uclibc/module-setup.sh
> @@ -0,0 +1,20 @@
> +#!/bin/bash
> +
> +check() {
> +	return 0
> +}
> +
> +depends() {
> +	return 0
> +}
> +
> +
> +
> +install() {
> +
> +	# Despite of the fact that the listed dependency (reported by readelf -d)
> +	# is purely ld-uClibc.so.1, the loader needs the ld-uClibc.so.0, too
> +
> +	ln -s ld-uClibc.so.1 $initdir/lib/ld-uClibc.so.0
> +

Extra empty lines...

But still, a little explanations (in the commit log) on how those
scripts are supposed to be used would help further review.

[--SNIP--]
> diff --git a/package/dracut/dracut.mk b/package/dracut/dracut.mk
> new file mode 100644
> index 0000000000..6c82b4ba75
> --- /dev/null
> +++ b/package/dracut/dracut.mk
> @@ -0,0 +1,45 @@
> +################################################################################
> +#
> +# dracut
> +#
> +################################################################################
> +
> +DRACUT_VERSION = 055
> +DRACUT_SOURCE = dracut-$(DRACUT_VERSION).tar.xz
> +DRACUT_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/boot/dracut
> +DRACUT_LICENSE = GPL-2.0
> +DRACUT_LICENSE_FILES = COPYING
> +
> +HOST_DRACUT_DEPENDENCIES += host-pkgconf host-kmod host-cross-ldd

First assignment should not be +=, but just =.

> +define HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT
> +	$(SED) '/unset LD_LIBRARY_PATH/d' $(HOST_DIR)/bin/dracut
> +	$(SED) '/unset LD_PRELOAD/d' $(HOST_DIR)/bin/dracut

As for cross-ldd, we prefer that patching be done with actual patches
rather than sed expressions.

> +endef
> +
> +define HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
> +	$(INSTALL) -D -m 0755 package/dracut/dracut_wrapper.sh \
> +		$(HOST_DIR)/usr/bin/dracut_wrapper.sh

Your commit log does not explain the reason why we need to have a
wrapper, or how it is going to be used...

Usually, when we introduce a wrapper, it replace sthe original
executable in name, and the original is renamed, with the wrapper
eventually calling into the renamed original...

So having a wrapper installed as you do it is slightly off-road...

> +endef
> +
> +ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
> +define HOST_DRACUT_POST_INSTALL_UCLIBC_MODULE
> +	$(INSTALL) -D -m 0755 package/dracut/06uclibc/module-setup.sh \
> +		$(HOST_DIR)/lib/dracut/modules.d/06uclibc/module-setup.sh
> +endef
> +HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_UCLIBC_MODULE
> +endif

And what about glibc? musl?

Can we unconditionally install the modules and change their check()
functions to decide whther the moduels is usable or not? Or something
else dynamic?

> +ifeq ($(BR2_INIT_BUSYBOX),y)
> +define HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE
> +	$(INSTALL) -D -m 0755 package/dracut/05busybox-buildroot/module-setup.sh \
> +		$(HOST_DIR)/lib/dracut/modules.d/05busybox-buildroot/module-setup.sh
> +endef
> +HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE

And what about systemd as an init system? openrc? sysv-init? Others?

> +endif
> +
> +HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT
> +HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT

Spaces around the operator. Also, since this is the same hook, a single
assignment is better:

    HOST_DRACUT_POST_INSTALL_HOOKS += \
        HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT \
        HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT

Note: we prefer to have uncondtional asignemnts come before the
conditional ones, and we also prefer to have ythe hook assignment
come right after the hook definitionm like so:


    define HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT
        blabla
    endef
    HOST_DRACUT_POST_INSTALL_HOOKS = HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT

    define HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
        blabla
    endef
    HOST_DRACUT_POST_INSTALL_HOOKS += HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT

    ifeq ($(BR2_INIT_BUSYBOX),y)
    define HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE
        blabla
    endef
    HOST_DRACUT_POST_INSTALL_HOOKS += HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE
    endif

and so on...

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Buildroot] [PATCH v3 3/3] fs/cpio: new option to use dracut tool
  2021-12-23 11:13 ` [Buildroot] [PATCH v3 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
@ 2022-01-06 10:31   ` Yann E. MORIN
  2022-01-06 13:48     ` Thierry Bultel
  0 siblings, 1 reply; 10+ messages in thread
From: Yann E. MORIN @ 2022-01-06 10:31 UTC (permalink / raw)
  To: Thierry Bultel; +Cc: Thomas Petazzoni, buildroot

Thierry, All,

On 2021-12-23 12:13 +0100, Thierry Bultel spake thusly:
> 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>
[--SNIP--]
> diff --git a/fs/cpio/Config.in b/fs/cpio/Config.in
> index c1151a2881..3d0f963a8d 100644
> --- a/fs/cpio/Config.in
> +++ b/fs/cpio/Config.in
> @@ -7,6 +7,33 @@ config BR2_TARGET_ROOTFS_CPIO
>  
>  if BR2_TARGET_ROOTFS_CPIO
>  
> +choice
> +	prompt "cpio type"

Missing empty line between the choice prompt and the first choice entry.

> +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"
> +	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

Don't add the option in the choice, but outside of it.

> diff --git a/fs/cpio/cpio.mk b/fs/cpio/cpio.mk
> index 81f8c393d1..e0e0eb2b1e 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

Don't do such a global export. If you need it in the environment, then
do so when calling the utility, like:

    TARGET_CROSS="$(TARGET_CROSS)" \
    $(HOST_DIR)/bin/dracut \
        blabla other options...

> +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/*

The $(@D) for ROOTFS_*_CMD is $(BINARIES_DIR), i.e. output/images/ and
so creating a te,mporary directory in there is not so nice. You should
use $(ROOTFS_CPIO_DIR)/tmp

Also, if I understand correctly, you are doing this mkdir+rm trick to
ensure you have an empty tmp directory to start with. By using
$(ROOTFS_CPIO_DIR) as base, this will be guaranteed, because
$(ROOTFS_CPIO_DIR) is removed and recreated before running the fs
commands.

> +	$(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)

Please, keep the original, plain cpio first in the code, and add the
dracut specificities after.

>  # --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))
> diff --git a/support/testing/conf/dracut.conf b/support/testing/conf/dracut.conf
> new file mode 100644
> index 0000000000..eb793a3562
> --- /dev/null
> +++ b/support/testing/conf/dracut.conf
> @@ -0,0 +1,93 @@
> +#Yuco dracut config

"Yuco"?

> +#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+=" \
[--SNIP big list of stuff--]
> +"

Rather than remove select stuff, can't we just start from an empty set
and add just what is needed?

Regards,
Yann E. MORIN.

> +
> diff --git a/support/testing/tests/fs/test_cpio.py b/support/testing/tests/fs/test_cpio.py
> new file mode 100644
> index 0000000000..5570693dc2
> --- /dev/null
> +++ b/support/testing/tests/fs/test_cpio.py
> @@ -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)
> +
> +
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Buildroot] [PATCH v3 3/3] fs/cpio: new option to use dracut tool
  2022-01-06 10:31   ` Yann E. MORIN
@ 2022-01-06 13:48     ` Thierry Bultel
  0 siblings, 0 replies; 10+ messages in thread
From: Thierry Bultel @ 2022-01-06 13:48 UTC (permalink / raw)
  To: buildroot, yann.morin.1998


>> +
>> +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+=" \
> [--SNIP big list of stuff--]
>> +"
> Rather than remove select stuff, can't we just start from an empty set
> and add just what is needed?

Yann,

Unfortunately, This is not that simple.
Dracut will unconditionally source a lot of unwanted modules present in 
host/usr/lib/modules.d
(basically because it considers that the init system is systemd always) 
unless you tell it not to do it.

There is no option to specify another directory to look in, nor a way to 
select the only needed modules.
Only excluding them seems the way.

Also, when you asked why I put the module-setup.sh as executable. You 
are right, it is not mandatory to do
so, because dracut just sources these files. The fact is that all the 
ones that it provides are set
as executables, with no real reason.

Regards,
Thierry
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Buildroot] [PATCH v3 2/3] package/dracut: new host package
  2022-01-05 23:16   ` Yann E. MORIN
@ 2022-01-06 14:56     ` Thierry Bultel
  2022-01-06 15:13       ` Thomas Petazzoni
  0 siblings, 1 reply; 10+ messages in thread
From: Thierry Bultel @ 2022-01-06 14:56 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: Thomas Petazzoni, buildroot


> And what about glibc? musl?
>
> Can we unconditionally install the modules and change their check()
> functions to decide whther the moduels is usable or not? Or something
> else dynamic?

There is not extra work to do for glibc (this is my default 
configuration). I did not test with musl, yet.

>> +ifeq ($(BR2_INIT_BUSYBOX),y)
>> +define HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE
>> +	$(INSTALL) -D -m 0755 package/dracut/05busybox-buildroot/module-setup.sh \
>> +		$(HOST_DIR)/lib/dracut/modules.d/05busybox-buildroot/module-setup.sh
>> +endef
>> +HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_BUSYBOX_MODULE
> And what about systemd as an init system? openrc? sysv-init? Others?
Keeping in mind that systemd is the officially supported init system by 
dracut, there is no extra work
for it. However, I brought support for busybox init, through the above 
dracut module (05busybox-buildroot).
Adding support for the other ones could be done later, so I suggest we 
simply disable dracut when the
init system is not supported; by adding

     depends on !BR2_INIT_SYSV
     depends on !BR2_INIT_OPENRC

in Config.in.host; with the appropriate comment. Does that sound 
acceptable ?

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Buildroot] [PATCH v3 2/3] package/dracut: new host package
  2022-01-06 14:56     ` Thierry Bultel
@ 2022-01-06 15:13       ` Thomas Petazzoni
  2022-01-06 15:56         ` Thierry Bultel
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Petazzoni @ 2022-01-06 15:13 UTC (permalink / raw)
  To: Thierry Bultel; +Cc: Yann E. MORIN, buildroot

On Thu, 6 Jan 2022 15:56:32 +0100
Thierry Bultel <thierry.bultel@linatsea.fr> wrote:

> Keeping in mind that systemd is the officially supported init system by 
> dracut, there is no extra work
> for it. However, I brought support for busybox init, through the above 
> dracut module (05busybox-buildroot).
> Adding support for the other ones could be done later, so I suggest we 
> simply disable dracut when the
> init system is not supported; by adding
> 
>      depends on !BR2_INIT_SYSV
>      depends on !BR2_INIT_OPENRC
> 
> in Config.in.host; with the appropriate comment. Does that sound 
> acceptable ?

But is it just the init system that requires those special dracut
"modules" ? Or other aspects of the system will also require some
special modules ?

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Buildroot] [PATCH v3 2/3] package/dracut: new host package
  2022-01-06 15:13       ` Thomas Petazzoni
@ 2022-01-06 15:56         ` Thierry Bultel
  0 siblings, 0 replies; 10+ messages in thread
From: Thierry Bultel @ 2022-01-06 15:56 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: Yann E. MORIN, buildroot



Le 06/01/2022 à 16:13, Thomas Petazzoni a écrit :
> On Thu, 6 Jan 2022 15:56:32 +0100
> Thierry Bultel <thierry.bultel@linatsea.fr> wrote:
>
>> Keeping in mind that systemd is the officially supported init system by
>> dracut, there is no extra work
>> for it. However, I brought support for busybox init, through the above
>> dracut module (05busybox-buildroot).
>> Adding support for the other ones could be done later, so I suggest we
>> simply disable dracut when the
>> init system is not supported; by adding
>>
>>       depends on !BR2_INIT_SYSV
>>       depends on !BR2_INIT_OPENRC
>>
>> in Config.in.host; with the appropriate comment. Does that sound
>> acceptable ?
> But is it just the init system that requires those special dracut
> "modules" ? Or other aspects of the system will also require some
> special modules ?

The dracut modules are used at build time.
The rule is that any file that is expected in the dracut image must be 
handled
by a dracut module. For instance,
"host/lib/dracut/modules.d/00bash"
"host/lib/dracut/modules.d/50sshd" work out of the box.

The implicitely loaded "90kernel-modules" (that check modules 
dependencies to one another,
and to firmwares) also work fine.

But nothing handles /etc/init.d/rcS, typically.
And all the wanted init scripts (/etc/init.d/S40network is a good example)
must be taken individually.
A huge work would be to contribute to dracut to bring whole support for 
initd
scripts, but I think it is out of the scope.

Another reason to write a module is when dracut does not support the 
feature, yet,
for instance, I had to write one for hostapd. Apparently it is not a 
common case
to have the wifi in an initramfs, but for a recovery system, that makes 
more sense.

Adding support for SYSV or OPENRC basically consists in writing the 
appropriate rules
in new modules to bring the expected files to the filesystem, nothing more.

By the way, my suggestion to use "depends on !xxx" directives cannot
work because it does an "unmet direct dependency detected", since
BR2_PACKAGE_HOST_DRACUT is selected by BR2_TARGET_ROOTFS_CPIO_DRACUT

I am a little bit confused about how to solve that properly.

Thierry

> Thomas


_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-01-06 15:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23 11:13 [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package Thierry Bultel
2021-12-23 11:13 ` [Buildroot] [PATCH v3 2/3] package/dracut: new host package Thierry Bultel
2022-01-05 23:16   ` Yann E. MORIN
2022-01-06 14:56     ` Thierry Bultel
2022-01-06 15:13       ` Thomas Petazzoni
2022-01-06 15:56         ` Thierry Bultel
2021-12-23 11:13 ` [Buildroot] [PATCH v3 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
2022-01-06 10:31   ` Yann E. MORIN
2022-01-06 13:48     ` Thierry Bultel
2022-01-05 22:29 ` [Buildroot] [PATCH v3 1/3] package/cross-ldd: new package Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.