From c5d127a7a5517466cda43047ff5e069ac43eaa8b Mon Sep 17 00:00:00 2001 From: apply-pr Date: Mon, 18 May 2026 11:00:08 +0530 Subject: [PATCH] fastboot: merge initramfs archives via extract+repack (avoid cat) The current initramfs merge logic concatenates cpio payloads using `cat`. Stream concatenation does not merge filesystem structure and can break early boot path/symlink resolution when firmware and symlinks are split across multiple archives. Replace the `cat` approach with an extract-into-one-dir + repack workflow when firmware_name is provided: - extract ramdisk into a staging rootfs - extract firmware archive into the same staging tree - repack as a single newc cpio.gz (preserving symlinks and hierarchy) If firmware_name is not provided, the template produces the merged output by renaming the original ramdisk artifact to merged-initramfs.cpio.gz. This improves reliability of /lib -> /usr/lib and /lib/firmware resolution during early boot and avoids firmware load failures. Signed-off-by: Anand Kulkarni --- templates/boot/fastboot.jinja2 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/templates/boot/fastboot.jinja2 b/templates/boot/fastboot.jinja2 index dbf45f0..e1d1f5d 100644 --- a/templates/boot/fastboot.jinja2 +++ b/templates/boot/fastboot.jinja2 @@ -29,14 +29,18 @@ docker: image: ghcr.io/mwasilew/docker-mkbootimage:master steps: - - gunzip -c {{ ramdisk_name }} > initramfs-kerneltest-full-image-qcom-armv8a.cpio {% if firmware_name %} - - gunzip -c {{ firmware_name }} > initramfs-firmware-rb3gen2-image-qcom-armv8a.cpio - - cat initramfs-kerneltest-full-image-qcom-armv8a.cpio initramfs-firmware-rb3gen2-image-qcom-armv8a.cpio > merged-initramfs.cpio + - if [ -d rootfs ]; then rm -rf rootfs; fi + - mkdir -p rootfs + - cd rootfs + - gzip -cd ../{{ ramdisk_name }} | cpio -idm --no-absolute-filenames + - gzip -cd ../{{ firmware_name }} | cpio -idm --no-absolute-filenames + - find . -print0 | cpio --null -H newc -o | gzip -9 > ../merged-initramfs.cpio.gz + - cd .. {% else %} - - cat initramfs-kerneltest-full-image-qcom-armv8a.cpio > merged-initramfs.cpio + # No firmware to merge: rename ramdisk as merged output (destructive) + - mv {{ ramdisk_name }} merged-initramfs.cpio.gz {% endif %} - - gzip merged-initramfs.cpio - mkbootimg --header_version 2 --kernel Image --dtb {{ dtb_name }} --cmdline "console=ttyMSM0,115200n8 earlycon qcom_geni_serial.con_enabled=1 kernel.sched_pelt_multiplier=4 mem_sleep_default=s2idle mitigations=auto video=efifb:off" --ramdisk merged-initramfs.cpio.gz --output boot.img to: downloads