Skip to content

Conversation

@giuseppe
Copy link

when --composefs-backend is used, make sure there is a UKI in the specified image.

Assisted-by: Claude Code (Sonnet 4.5)

Copy link

@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 adds a crucial check for a Unified Kernel Image (UKI) when the --composefs-backend option is used. The overall approach is correct. I've provided a couple of suggestions to improve the implementation: one to simplify the shell command used for the check in images.rs, and another to adjust the location of the check in to_disk.rs to ensure it also runs during a --dry-run for more accurate validation.

Comment on lines 221 to 224
let output = Command::new("podman")
.args(["run", "--rm", name, "sh", "-c", "ls /boot/EFI/Linux/*.efi 2>/dev/null | head -1"])
.output()?;
Ok(output.status.success() && !output.stdout.is_empty())

Choose a reason for hiding this comment

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

medium

The shell command to check for the UKI file can be simplified. Instead of piping ls to head and checking stdout, you can rely on the exit code of ls. ls will fail with a non-zero exit code if no files match the glob. By redirecting stdout and stderr to /dev/null, you can simply check the command's success status. This is a more idiomatic and robust approach in shell scripting.

Suggested change
let output = Command::new("podman")
.args(["run", "--rm", name, "sh", "-c", "ls /boot/EFI/Linux/*.efi 2>/dev/null | head -1"])
.output()?;
Ok(output.status.success() && !output.stdout.is_empty())
let status = Command::new("podman")
.args(["run", "--rm", name, "sh", "-c", "ls /boot/EFI/Linux/*.efi >/dev/null 2>&1"])
.status()?;
Ok(status.success())

Comment on lines 426 to 431
if opts.install.composefs_backend && !images::has_uki(&opts.source_image)? {
return Err(eyre!(
"Image '{}' has no UKI - not suitable for --composefs-backend",
opts.source_image
));
}

Choose a reason for hiding this comment

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

medium

This check for a UKI is currently performed after the --dry-run logic has already completed and exited. A dry run should ideally perform all validations to accurately predict if the real operation would succeed. If the image is missing a UKI, the operation will fail, and a dry run should report this.

Please consider moving this validation block to the beginning of the run function (e.g., around line 372) so that it is executed for both normal and dry runs.

@travier
Copy link

travier commented Jan 30, 2026

In theory we support both GRUB + Type1 BLS and systemd-boot + UKI for the pure composefs backend so it's not limited to UKIs.

@travier
Copy link

travier commented Jan 30, 2026

when --composefs-backend is used, make sure there is a UKI in
the specified image.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
}

/// Check if image has a UKI (required for --composefs-backend)
pub fn has_uki(name: &str) -> Result<bool> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's already code in this repo to parse the kernel state

/// Main entry point for the bootc installation process. See module-level documentation
/// for details on the installation workflow and architecture.
pub fn run(opts: ToDiskOpts) -> Result<()> {
if opts.install.composefs_backend && !images::has_uki(&opts.source_image)? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As @travier said this is strictly speaking not true, or to say it another way we definitely want to support it, but it is also true that we are not CI testing it or documenting it right now.

@giuseppe giuseppe closed this Jan 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.

3 participants