-
Notifications
You must be signed in to change notification settings - Fork 131
composefs-native/uki: Handle UKI addons #1573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: composefs-backend
Are you sure you want to change the base?
composefs-native/uki: Handle UKI addons #1573
Conversation
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>
Just reducing code here.
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>
I thought |
There was a problem hiding this 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
let renamed_path = if parent.as_str()?.ends_with(EFI_ADDON_DIR_EXT) { | |
let renamed_path = if parent.ends_with(EFI_ADDON_DIR_EXT) { |
fd703ec
to
023be10
Compare
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