[v6,04/13] rootfs: Copy the newly created initrd.img to the work directory

Message ID 20251105093710.19582-5-Quirin.Gylstorff@siemens.com
State Superseded
Headers show
Series Add support for dracut | expand

Commit Message

Quirin Gylstorff Nov. 5, 2025, 9:29 a.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

This allows to change the permissions of the initrd to 0644. And
all followup steps do not need sudo.

This is necessary as dracut creates the initrd with 0600 permissions.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 meta/classes/rootfs.bbclass | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Patch

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index c683d5d2..78da8a4b 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -606,17 +606,11 @@  rootfs_generate_initramfs() {
             echo "Total number of modules: $mods_total"
             echo "Generating initrd for kernel version: $kernel_version"
             sudo -E chroot "${ROOTFSDIR}" sh -c ' \
-                ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE};'
+                ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE}; \
+                find /boot -name "initrd.img-$kernel_version*" -exec install --mode 0644 {} /isar-work/initrd.img \; \
+                '
         done
-        if [ -n "${INITRD_DEPLOY_FILE}" ]; then
-            if [ -f "${ROOTFSDIR}/initrd.img" ]; then
-                # debian (mkinitramfs)
-                cp ${ROOTFSDIR}/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
-            else
-                # ubuntu (dracut)
-                cp ${ROOTFSDIR}/boot/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
-            fi
-        fi
+        install --owner $(id -u) --group $(id -g) ${WORKDIR}/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
     else
         echo "no kernel in this rootfs, do not generate initrd"
     fi