From d0eb9ee246733257690747679ebebd006ce58e6b Mon Sep 17 00:00:00 2001 From: wangyueliang Date: Wed, 5 Jun 2024 17:23:07 +0800 Subject: [PATCH] Mask ISO image EFI directory processing logic The BOOT*.EFI provided by the current openEuler community's shim package cannot handle the jump version grub.cfg. Just mask it and proceed with further processing. --- src/cmd-buildextend-live | 104 +++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/cmd-buildextend-live b/src/cmd-buildextend-live index f4d122fb..755a4a48 100755 --- a/src/cmd-buildextend-live +++ b/src/cmd-buildextend-live @@ -520,59 +520,59 @@ def generate_iso(): "/usr/lib/bootupd/updates/EFI", buildmeta_commit, tmpimageefidir]) - # Find name of vendor directory - vendor_ids = [n for n in os.listdir(tmpimageefidir) if n != "BOOT"] - if len(vendor_ids) != 1: - raise Exception(f"did not find exactly one EFI vendor ID: {vendor_ids}") - - # Delete fallback and its CSV file. Its purpose is to create - # EFI boot variables, which we don't want when booting from - # removable media. - # - # A future shim release will merge fallback.efi into the main - # shim binary and enable the fallback behavior when the CSV - # exists. But for now, fail if fallback.efi is missing. - for path in ensure_glob(os.path.join(tmpimageefidir, "BOOT", "fb*.efi")): - os.unlink(path) - # openEuler shim package has two mm*.efi that put in "BOOT" and "openEuler" dir, delete one of them here - for path in ensure_glob(os.path.join(tmpimageefidir, "BOOT", "mm*.efi")): - os.unlink(path) +# # Find name of vendor directory +# vendor_ids = [n for n in os.listdir(tmpimageefidir) if n != "BOOT"] +# if len(vendor_ids) != 1: +# raise Exception(f"did not find exactly one EFI vendor ID: {vendor_ids}") + +# # Delete fallback and its CSV file. Its purpose is to create +# # EFI boot variables, which we don't want when booting from +# # removable media. +# # +# # A future shim release will merge fallback.efi into the main +# # shim binary and enable the fallback behavior when the CSV +# # exists. But for now, fail if fallback.efi is missing. +# for path in ensure_glob(os.path.join(tmpimageefidir, "BOOT", "fb*.efi")): +# os.unlink(path) +# # openEuler shim package has two mm*.efi that put in "BOOT" and "openEuler" dir, delete one of them here +# for path in ensure_glob(os.path.join(tmpimageefidir, "BOOT", "mm*.efi")): +# os.unlink(path) - for path in ensure_glob(os.path.join(tmpimageefidir, vendor_ids[0], "BOOT*.CSV")): - os.unlink(path) - - # Drop vendor copies of shim; we already have it in BOOT*.EFI in - # BOOT - for path in ensure_glob(os.path.join(tmpimageefidir, vendor_ids[0], "shim*.efi")): - os.unlink(path) - - # Consolidate remaining files into BOOT. shim needs GRUB to be - # there, and the rest doesn't hurt. - for path in ensure_glob(os.path.join(tmpimageefidir, vendor_ids[0], "*")): - shutil.move(path, os.path.join(tmpimageefidir, "BOOT")) - os.rmdir(os.path.join(tmpimageefidir, vendor_ids[0])) - - # Inject a stub grub.cfg pointing to the one in the main ISO image. - # - # When booting via El Torito, this stub is not used; GRUB reads - # the ISO image directly using its own ISO support. This - # happens when booting from a CD device, or when the ISO is - # copied to a USB stick and booted on EFI firmware which prefers - # to boot a hard disk from an El Torito image if it has one. - # EDK II in QEMU behaves this way. - # - # This stub is used with EFI firmware which prefers to boot a - # hard disk from an ESP, or which cannot boot a hard disk via El - # Torito at all. In that case, GRUB thinks it booted from a - # partition of the disk (a fake ESP created by isohybrid, - # pointing to efiboot.img) and needs a grub.cfg there. - with open(os.path.join(tmpimageefidir, "BOOT", "grub.cfg"), "w") as fh: - fh.write(f'''search --label "{volid}" --set root --no-floppy -set prefix=($root)/EFI/{vendor_ids[0]} -echo "Booting via ESP..." -configfile $prefix/grub.cfg -boot -''') +# for path in ensure_glob(os.path.join(tmpimageefidir, vendor_ids[0], "BOOT*.CSV")): +# os.unlink(path) + +# # Drop vendor copies of shim; we already have it in BOOT*.EFI in +# # BOOT +# for path in ensure_glob(os.path.join(tmpimageefidir, vendor_ids[0], "shim*.efi")): +# os.unlink(path) + +# # Consolidate remaining files into BOOT. shim needs GRUB to be +# # there, and the rest doesn't hurt. +# for path in ensure_glob(os.path.join(tmpimageefidir, vendor_ids[0], "*")): +# shutil.move(path, os.path.join(tmpimageefidir, "BOOT")) +# os.rmdir(os.path.join(tmpimageefidir, vendor_ids[0])) + +# # Inject a stub grub.cfg pointing to the one in the main ISO image. +# # +# # When booting via El Torito, this stub is not used; GRUB reads +# # the ISO image directly using its own ISO support. This +# # happens when booting from a CD device, or when the ISO is +# # copied to a USB stick and booted on EFI firmware which prefers +# # to boot a hard disk from an El Torito image if it has one. +# # EDK II in QEMU behaves this way. +# # +# # This stub is used with EFI firmware which prefers to boot a +# # hard disk from an ESP, or which cannot boot a hard disk via El +# # Torito at all. In that case, GRUB thinks it booted from a +# # partition of the disk (a fake ESP created by isohybrid, +# # pointing to efiboot.img) and needs a grub.cfg there. +# with open(os.path.join(tmpimageefidir, "BOOT", "grub.cfg"), "w") as fh: +# fh.write(f'''search --label "{volid}" --set root --no-floppy +# set prefix=($root)/EFI/{vendor_ids[0]} +# echo "Booting via ESP..." +# configfile $prefix/grub.cfg +# boot +# ''') # Install binaries from boot partition # Manually construct the tarball to ensure proper permissions and ownership -- Gitee