diff mbox series

[1/2] live-vm-common.bbclass: conditionally to add kernel and initrd to efi.img of ISO live

Message ID 20250328130242.929372-1-hongxu.jia@windriver.com
State New
Headers show
Series [1/2] live-vm-common.bbclass: conditionally to add kernel and initrd to efi.img of ISO live | expand

Commit Message

Hongxu Jia March 28, 2025, 1:02 p.m. UTC
Add var-EFI_ISO_KERNEL, if ${EFI_ISO_KERNEL} != "1", do not add kernel and
initrd to efi.img of ISO live.

For grub-efi's ISO live, the kernel and initrd is not necessary in efi.img,
because grub-efi's bootx64.efi sets `search.file ($cmdpath)/EFI/BOOT/grub.cfg root'
to locate kernel and initrd in ISO live image.

It helps while the size of initrd is big to break the limit of efi.img in which
the filesystem type is FAT

Also clean up ${EFIIMGDIR} before populating

Set EFI_ISO_KERNEL ??= "1" by default which adds kernel and initrd to efi.img
as usual

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/classes-recipe/live-vm-common.bbclass | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/live-vm-common.bbclass b/meta/classes-recipe/live-vm-common.bbclass
index d90cc67ebc..f087d9e236 100644
--- a/meta/classes-recipe/live-vm-common.bbclass
+++ b/meta/classes-recipe/live-vm-common.bbclass
@@ -48,18 +48,25 @@  efi_populate_common() {
         printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh
 }
 
+# Kernel(with initrd) image in efi.img of ISO live
+EFI_ISO_KERNEL ??= "1"
+
 efi_iso_populate() {
         iso_dir=$1
         efi_populate $iso_dir
+
+        rm -rf ${EFIIMGDIR}
         # Build a EFI directory to create efi.img
         mkdir -p ${EFIIMGDIR}/${EFIDIR}
         cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
-        cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR}
+        if [ "${EFI_ISO_KERNEL}" = "1" ]; then
+                cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR}
+        fi
 
         EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
         printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${EFIIMGDIR}/startup.nsh
 
-        if [ -f "$iso_dir/initrd" ] ; then
+        if [ -f "$iso_dir/initrd" -a "${EFI_ISO_KERNEL}" = "1" ] ; then
                 cp $iso_dir/initrd ${EFIIMGDIR}
         fi
 }