|
| 1 | +From 958916db5ec1f707cbd41b543298e3641560835e Mon Sep 17 00:00:00 2001 |
| 2 | +From: Huijing Hei < [email protected]> |
| 3 | +Date: Wed, 3 Dec 2025 13:24:00 +0800 |
| 4 | +Subject: [PATCH] stages: extend to find EFI under `usr/lib/efi` |
| 5 | + |
| 6 | +Because of the change [1], the EFI files will not be copied to |
| 7 | +`usr/lib/bootupd/updates/EFI`, extend support to find EFI files |
| 8 | +from `usr/lib/efi/`. |
| 9 | +See tracker issue [2]. |
| 10 | + |
| 11 | +[1] https://github.com/coreos/bootupd/commit/123a0cd364e89e02b52fb51a53e991c15ada02b7 |
| 12 | +[2] https://github.com/coreos/bootupd/issues/926 |
| 13 | + |
| 14 | +Fixes: https://github.com/osbuild/osbuild/issues/2263 |
| 15 | + |
| 16 | +Co-worked-by: Dusty Mabe < [email protected]> |
| 17 | +Signed-off-by: Huijing Hei < [email protected]> |
| 18 | +--- |
| 19 | + stages/org.osbuild.coreos.live-artifacts.mono | 28 +++++++++++++++++-- |
| 20 | + 1 file changed, 26 insertions(+), 2 deletions(-) |
| 21 | + |
| 22 | +diff --git a/stages/org.osbuild.coreos.live-artifacts.mono b/stages/org.osbuild.coreos.live-artifacts.mono |
| 23 | +index 35ecac4e..5bcf97d8 100755 |
| 24 | +--- a/stages/org.osbuild.coreos.live-artifacts.mono |
| 25 | ++++ b/stages/org.osbuild.coreos.live-artifacts.mono |
| 26 | +@@ -143,6 +143,25 @@ def ensure_glob(pathname, n="", **kwargs): |
| 27 | + return ret |
| 28 | + |
| 29 | + |
| 30 | ++# This function finds the source EFI paths to copy from /usr/ to the EFI/ |
| 31 | ++# directory. Historically this was just the usr/lib/bootupd/updates/EFI/ |
| 32 | ++# directory (populated by bootupd), but as part of BootLoaderUpdatesPhase1 [1] |
| 33 | ++# the shim and grub packages started delivering files in |
| 34 | ++# /usr/lib/efi/(grub|shim)/<version>/EFI/ directly. Lets prefer the |
| 35 | ++# new paths and fallback to the legacy path if those don't exist. |
| 36 | ++# |
| 37 | ++# [1] https://fedoraproject.org/wiki/Changes/BootLoaderUpdatesPhase1 |
| 38 | ++def find_efi_source_paths(tree): |
| 39 | ++ if glob.glob(os.path.join(tree, 'usr/lib/efi/*/*/EFI')): |
| 40 | ++ # BootLoaderUpdatesPhase1 has been implemented and we should |
| 41 | ++ # be able to pick up files from usr/lib/efi/(grub|shim)/<version>/EFI/ |
| 42 | ++ # Let's ensure there's only 2 dirs that match (i.e. one for grub |
| 43 | ++ # one for shim) and return that list. |
| 44 | ++ return ensure_glob(os.path.join(tree, 'usr/lib/efi/*/*/EFI'), n=2) |
| 45 | ++ # Legacy path. Just return a single entry list with the old path. |
| 46 | ++ return [os.path.join(tree, 'usr/lib/bootupd/updates/EFI')] |
| 47 | ++ |
| 48 | ++ |
| 49 | + def find_efi_vendor_dir_name(efidir): |
| 50 | + # Find name of vendor directory for this distro. i.e. "fedora" or "redhat". |
| 51 | + dirs = [n for n in os.listdir(efidir) if n != "BOOT"] |
| 52 | +@@ -485,7 +504,9 @@ def mkefiboot(paths, deployed_tree, volid, loop_client): |
| 53 | + return tarinfo |
| 54 | + |
| 55 | + efidir = paths["efi"] |
| 56 | +- shutil.copytree(os.path.join(deployed_tree, 'usr/lib/bootupd/updates/EFI'), efidir) |
| 57 | ++ for path in find_efi_source_paths(deployed_tree): |
| 58 | ++ shutil.copytree(path, efidir, dirs_exist_ok=True) |
| 59 | ++ |
| 60 | + vendor_id = find_efi_vendor_dir_name(efidir) |
| 61 | + |
| 62 | + # Delete fallback and its CSV file. Its purpose is to create |
| 63 | +@@ -711,7 +732,10 @@ def copy_configs_and_init_kargs_json(deployed_tree, paths, blsentry_kargs, volid |
| 64 | + # [1] https://github.com/coreos/fedora-coreos-config/tree/testing-devel/live/EFI/fedora |
| 65 | + # [2] https://github.com/openshift/os/tree/master/live/EFI/vendor |
| 66 | + # [3] https://github.com/openshift/os/issues/954 |
| 67 | +- efidir = os.path.join(deployed_tree, 'usr/lib/bootupd/updates/EFI') |
| 68 | ++ # |
| 69 | ++ # To find the string for the vendor ID we only need to inspect one |
| 70 | ++ # of the source EFI directories. Grab one here. |
| 71 | ++ efidir = find_efi_source_paths(deployed_tree)[0] |
| 72 | + if os.path.exists(efidir): |
| 73 | + vendor_id = find_efi_vendor_dir_name(efidir) |
| 74 | + grubfilepath = ensure_glob(os.path.join(paths["iso"], 'EFI/*/grub.cfg'), n=1)[0] |
| 75 | +-- |
| 76 | +2.51.0 |
| 77 | + |
0 commit comments