Skip to content

Conversation

Johan-Liebert1
Copy link
Collaborator

@Johan-Liebert1 Johan-Liebert1 commented Sep 2, 2025

If we find UKI addons in the boot entries list, write them to ESP along with the UKI

Right now if a UKI Addon also has the composefs= cmdline param, it's ignored.

Supporting: containers/composefs-rs#126

Needs containers/composefs-rs#178

Johan-Liebert1 and others added 27 commits August 29, 2025 17:05
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Signed-off-by: Colin Walters <walters@verbum.org>
Signed-off-by: Colin Walters <walters@verbum.org>
Parse the Grub menuentry file, `boot/grub2/user.cfg` to get a list of
bootable UKIs and figure out if a rollback is currently queued.

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
Returning a local reference to a `&str` is quite tricky with rust.
Update `title` and `chainloader`, the two dynamic fields in the grub
menuentry, to be `String` instead of `&str`

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
We parse the grub menuentries, get the rollback deployment then perform
the rollback, which basically consists of writing a new .staged
menuentry file then atomically swapping the staged and the current
menuentry.

Rollback while there is a staged deployment is still to be handled.

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
…iles

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
If two deployments have the same VMLinuz + Initrd then, we can use the
same binaries for both the deployments.

Before writing the BLS entries to disk we calculate the SHA256Sum
of VMLinuz + Initrd combo, then test if any other deployment has the
same SHA256Sum for the binaries. Store the hash in the origin file under
`boot -> hash` for future lookups.

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
Centralize all constants in a separate file

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
Instead of `/sysroot/state/os/fedora` use `/sysroot/state/os/default` as
the default state directory.

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
Instaed of writing all present menuentries, only write the menuentry for
switch/upgrade and the menuentry for the currently booted deployment.

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
This allows for easier testing

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Add tests for functions `get_sorted_bls_boot_entries` and
`get_sorted_uki_boot_entries`

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Signed-off-by: Colin Walters <walters@verbum.org>
Signed-off-by: Colin Walters <walters@verbum.org>
The duplication between this and composefs-boot is high
and we need to squash it; an important step there
would probably be lowering the karg parsing.

Signed-off-by: Colin Walters <walters@verbum.org>
Signed-off-by: Robert Sturla <robertsturla@outlook.com>

install: create temporary directory for ESP bls mount

Plus additional review comments:
- Created constant for EFI/LINUX
- Switched from Task to Command
- Create efi_dir as Utf8PathBuf

Signed-off-by: Robert Sturla <robertsturla@outlook.com>
- Use `read_file` from `composefs::fs`
- Always define `mod parsers`
- Re-alphabetize/group module definitions

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Fill `version` field in generated BLS config

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
composefs/install/bls: Fix empty version in config
For bind mounting /etc we copy the contents of the EROFS' /etc to the
deployment's state directory

Mounting the EORFS requires help from the initramfs crate, so we also
turn it into a library crate.

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
composefs/install: Copy /etc contents to state
If we find UKI addons in the boot entries list, write them to ESP along
with the UKI

Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
@Johan-Liebert1
Copy link
Collaborator Author

I thought needs-ok-to-test skipped CI as the CI won't currently pass anyway

Copy link
Contributor

@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 the UKI boot setup to handle UKI addons by processing a list of boot entries instead of a single one. A new helper function, write_pe_to_esp, is introduced to encapsulate writing PE files to the ESP, which is a good separation of concerns. The changes are generally well-structured and address the goal of handling UKI addons. I've identified a couple of areas for improvement regarding code consistency and robustness. My detailed feedback is in the comments below.

@@ -1143,10 +1143,10 @@ async fn switch_composefs(opts: SwitchOpts) -> Result<()> {
BootSetupType::Upgrade(&fs),
repo,
&id,
entry,
&entry,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The call to setup_composefs_bls_boot here uses &entry, but a similar call in upgrade_composefs (line 961) uses entry. In both functions, entry is of type &ComposefsBootEntry. While using &entry works due to auto-dereferencing, for consistency and clarity it would be better to use entry in both places.

                entry,

create_dir_all(&efi_linux_path).context("Creating EFI/Linux")?;

let final_pe_path = if let Some(parent) = file_path.parent() {
let renamed_path = if parent.as_str()?.ends_with(EFI_ADDON_DIR_EXT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using parent.as_str()? could lead to an error if the path contains non-UTF-8 characters. It's safer and cleaner to use parent.ends_with(), which operates directly on &Path and avoids the need for string conversion.

Suggested change
let renamed_path = if parent.as_str()?.ends_with(EFI_ADDON_DIR_EXT) {
let renamed_path = if parent.ends_with(EFI_ADDON_DIR_EXT) {

@Johan-Liebert1 Johan-Liebert1 marked this pull request as draft September 2, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants