Skip to content

efi: Choose update layout depending on /usr/lib/efi#1089

Merged
Johan-Liebert1 merged 2 commits intocoreos:mainfrom
Johan-Liebert1:usr-lib-efi-backwards-compat
Apr 29, 2026
Merged

efi: Choose update layout depending on /usr/lib/efi#1089
Johan-Liebert1 merged 2 commits intocoreos:mainfrom
Johan-Liebert1:usr-lib-efi-backwards-compat

Conversation

@Johan-Liebert1
Copy link
Copy Markdown
Member

@Johan-Liebert1 Johan-Liebert1 commented Apr 23, 2026

In #995 changes were made to move files from usr/lib/ostree-boot/EFI to usr/lib/efi which caused issues with older bootupd failing to understand the new layout created by newer version of bootupd. We will start putting grub, shim and other related stuff in /usr/lib/efi starting fedora44 while older releases still have them in /usr/lib/ostree-boot, we need bootupd to properly handle both cases.

To make the change backwards compatible, we now check for the existence of usr/lib/efi, and only use the new layout if we find it. Else, default back to the older layout at usr/lib/bootupd

Fixes: #1057

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors EFI metadata generation to support both legacy and newer image layouts by checking for EFI files in /usr/lib/ostree-boot and /usr/lib/efi. It introduces helper functions for metadata generation and file transfers. Review feedback highlighted a critical bug where a path existence check was performed against the host filesystem instead of the target sysroot, as well as suggestions for more idiomatic path handling and fixing a potential double-slash in path construction.

Comment thread src/efi.rs Outdated
Comment thread src/efi.rs Outdated
Comment thread src/efi.rs Outdated
Comment thread src/efi.rs Outdated
Comment thread src/efi.rs Outdated
@Johan-Liebert1 Johan-Liebert1 force-pushed the usr-lib-efi-backwards-compat branch from fde73b8 to 14cab82 Compare April 23, 2026 09:31
@Johan-Liebert1 Johan-Liebert1 requested a review from travier April 23, 2026 09:42
@Johan-Liebert1 Johan-Liebert1 force-pushed the usr-lib-efi-backwards-compat branch 4 times, most recently from db36a9c to d81d546 Compare April 27, 2026 05:44
Copy link
Copy Markdown
Member

@jbtrystram jbtrystram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superficial review since I am not really knowledgeable about this, but it feels a bit weird overall.
If i understand this, this is addressing the case where a disk image was created using a more recent bootupd version that's what actually ships into the image. This is essentially a bug from the build system.

Also, why not simply always symlink usr/lib/bootupd/updates to /lib/ostree-boot/EFI when the second exist but not the first, instead of moving things around ?
I guess there is already migration logic the other way around that will happen later ?

Comment thread src/efi.rs
Comment on lines +800 to +802
let Some(efi_components) = get_efi_component_from_usr(sysroot_path, EFILIB)? else {
anyhow::bail!("Failed to find EFI components");
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an unusual way of handling the unwrapping.
Why do you need to bail here ? Can't the error simply be bubbled up ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_efi_component_from_usr returns Result<Option<T>>, the let .. else {} is to handle the Option part after the result is bubbled up by the ? operator

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, T is an option already, I missed that. There is flatten that could work I guess.

Comment thread src/efi.rs
}
modules_vec.sort_unstable();

// change to now to workaround https://github.com/coreos/bootupd/issues/933
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we account for SOURCE_DATE_EPOCH here ?
See #1075

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does sound like a one liner fix, afaics we are comparing package names and version for sorting and not the timestamps. This could be a separate PR though. wdyt?

@Johan-Liebert1 Johan-Liebert1 changed the title efi: Handle compatibility for systems with no usr/lib/efi efi: Handle compatibility for systems where grub & shim are not moved to /usr/lib/efi Apr 28, 2026
@travier
Copy link
Copy Markdown
Member

travier commented Apr 28, 2026

Reading this PR, I've realized that the code in #955 is incorrectly copying things from /usr/lib/ostree-boot to /usr/lib/efi in the /usr/lib/efi case when it should only look at what files are present in /usr/lib/ostree-boot to generate the metadata but read the files from /usr/lib/efi (they should be an exact copy but well).

@Johan-Liebert1
Copy link
Copy Markdown
Member Author

the /usr/lib/efi case when it should only look at what files are present in /usr/lib/ostree-boot

wouldn't /usr/lib/ostree-boot not have anything in the /usr/lib/efi case?

@travier
Copy link
Copy Markdown
Member

travier commented Apr 28, 2026

Damned, that's likely right and don't remember what we checked the last time :/ But the code does not read like that (I need to re-read that).

In coreos#995 changes were made to move
files from `usr/lib/ostree-boot/EFI` to `usr/lib/efi` instead of `usr/lib/bootupd`
which caused issues with tools that expect the older layout.

We now check for the existence of `usr/lib/efi`, and only use the new layout if
we find it. Else, default back to the older layout at `usr/lib/bootupd`.

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Update e2e tests to handle both, new i.e. `/usr/lib/efi`, and old i.e.
`/usr/lib/bootupd/updates` layouts, depending upon the existence of
`/usr/lib/efi`

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
@Johan-Liebert1 Johan-Liebert1 force-pushed the usr-lib-efi-backwards-compat branch from d81d546 to fbb5911 Compare April 29, 2026 09:45
@Johan-Liebert1 Johan-Liebert1 changed the title efi: Handle compatibility for systems where grub & shim are not moved to /usr/lib/efi efi: Choose update layout depending on /usr/lib/efi Apr 29, 2026
@travier travier requested a review from jbtrystram April 29, 2026 10:03
Copy link
Copy Markdown
Member

@travier travier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We updated this one together with Pragyan. LGTM

@Johan-Liebert1 Johan-Liebert1 merged commit e994131 into coreos:main Apr 29, 2026
12 checks passed
@Johan-Liebert1 Johan-Liebert1 mentioned this pull request Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make bootupctl backend generate-metadata|install|update use the new layout only on systems with /usr/lib/efi

3 participants