[2/8] dracut-module: make module-setup compatible with sysroot

Message ID 20260915100125.1991311-3-felix.moessbauer@siemens.com
State Under Review
Headers show
Series [1/8] rootfs: generalize deployment of rootfs artifact | expand

Commit Message

Felix Moessbauer Sept. 15, 2026, 10:01 a.m. UTC
As a preparation for cross-building dracut initrds, we need to ensure
the module setup does not call external tooling (which would have to be
emulated). Further, all tool output must be consumable under sysroot as
well (e.g. paths must be resolved in the target chroot). We fix this by
replacing calls to tooling with the corresponding dracut helpers.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 .../dracut-example-lighttpd/files/install.sh         | 12 ++++++++----
 .../dracut-module/files/module-setup.sh.tmpl         |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

Patch

diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
index b7295b94..66b54a43 100644
--- a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
@@ -1,5 +1,9 @@ 
-inst_multiple -o /usr/lib/lighttpd/*.so
-inst_multiple -o /usr/share/lighttpd/*
+# Copy optional lighttpd modules and assets from the target sysroot.
+for source in "${dracutsysrootdir}"/usr/lib/*/lighttpd/*.so \
+			  "${dracutsysrootdir}"/usr/share/lighttpd/*; do
+	[[ -e "$source" ]] || continue
+	inst_simple "$source" "${source#"$dracutsysrootdir"}"
+done
 
 inst_simple "${moddir}/lighttpd.service" "$systemdsystemunitdir/lighttpd.service"
 inst_simple "${moddir}/lighttpd.conf" /etc/lighttpd/lighttpd.conf
@@ -13,8 +17,8 @@  mkdir -p -m 0700 "$initdir/var/cache/lighttpd/uploads"
 mkdir -p -m 0700 "$initdir/var/log/lighttpd/"
 mkdir -p -m 0755 "$initdir/var/www/html"
 
-/usr/bin/install -m 0644 /usr/share/lighttpd/index.html "$initdir/var/www/html/index.html"
+inst_simple "${dracutsysrootdir}"/usr/share/lighttpd/index.html /var/www/html/index.html
 touch "$moddir"/error.log
-/usr/bin/install -m 0644 "$moddir"/error.log "$initdir/var/log/lighttpd/error.log"
+inst_simple "$moddir"/error.log /var/log/lighttpd/error.log
 chown -R www-data:www-data "$initdir/var/log/lighttpd/"
 systemctl -q --root "$initdir" enable lighttpd
diff --git a/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
index be0f4c54..b38ae50c 100644
--- a/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
+++ b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
@@ -31,7 +31,7 @@  cmdline() {
 
 install() {
     for executable in ${DRACUT_REQUIRED_BINARIES}; do
-        if exec_path=$(command -v $executable 2>/dev/null); then
+        if exec_path=$(find_binary "$executable"); then
             inst_binary "$exec_path"
         else
             echo "(ERROR): Unable to copy $executable" >&2