Skip to content

Commit 033abb5

Browse files
composefs/install: Install UKI Addons globally
Until now we were scoping passed in UKI Addons to specific deployments, but usecases like ignition, luks (for now at least), require the addons to be applied to all deployments Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 63d09b6 commit 033abb5

File tree

1 file changed

+25
-10
lines changed
  • crates/lib/src/bootc_composefs

1 file changed

+25
-10
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use crate::{
5858

5959
use crate::install::{RootSetup, State};
6060

61-
/// Contains the EFP's filesystem UUID. Used by grub
61+
/// Contains the ESP's filesystem UUID. Used by grub
6262
pub(crate) const EFI_UUID_FILE: &str = "efiuuid.cfg";
6363
/// The EFI Linux directory
6464
pub(crate) const EFI_LINUX: &str = "EFI/Linux";
@@ -76,6 +76,13 @@ const VMLINUZ: &str = "vmlinuz";
7676
/// This is relative to the ESP
7777
pub(crate) const SYSTEMD_UKI_DIR: &str = "EFI/Linux/bootc";
7878

79+
pub(crate) const GLOBAL_UKI_ADDON_DIR: &str = "loader/addons";
80+
81+
/// Whether to install all passed in UKI Addons as global
82+
/// For now, we don't have a reason to scope addons to a specific deployment, but we want to in the
83+
/// future
84+
pub const INSTALL_ADDONS_AS_GLOBAL: bool = true;
85+
7986
pub(crate) enum BootSetupType<'a> {
8087
/// For initial setup, i.e. install to-disk
8188
Setup((&'a RootSetup, &'a State, &'a ComposefsFilesystem)),
@@ -639,16 +646,23 @@ fn write_pe_to_esp(
639646
});
640647
}
641648

642-
// Write the UKI to ESP
643-
let efi_linux_path = mounted_efi.as_ref().join(match bootloader {
644-
Bootloader::Grub => EFI_LINUX,
645-
Bootloader::Systemd => SYSTEMD_UKI_DIR,
649+
// Directory to write the PortableExecutable to
650+
let pe_install_dir = mounted_efi.as_ref().join(match pe_type {
651+
PEType::UkiAddon if INSTALL_ADDONS_AS_GLOBAL => GLOBAL_UKI_ADDON_DIR,
652+
653+
PEType::Uki | PEType::UkiAddon => match bootloader {
654+
Bootloader::Grub => EFI_LINUX,
655+
Bootloader::Systemd => SYSTEMD_UKI_DIR,
656+
},
646657
});
647658

648-
create_dir_all(&efi_linux_path).context("Creating EFI/Linux")?;
659+
create_dir_all(&pe_install_dir)
660+
.with_context(|| format!("Creating {}", pe_install_dir.display()))?;
661+
662+
let final_pe_path = match (INSTALL_ADDONS_AS_GLOBAL, file_path.parent()) {
663+
(true, ..) => pe_install_dir,
649664

650-
let final_pe_path = match file_path.parent() {
651-
Some(parent) => {
665+
(false, Some(parent)) => {
652666
let renamed_path = match parent.as_str().ends_with(EFI_ADDON_DIR_EXT) {
653667
true => {
654668
let dir_name = format!("{}{}", uki_id.to_hex(), EFI_ADDON_DIR_EXT);
@@ -662,13 +676,13 @@ fn write_pe_to_esp(
662676
false => parent.to_path_buf(),
663677
};
664678

665-
let full_path = efi_linux_path.join(renamed_path);
679+
let full_path = pe_install_dir.join(renamed_path);
666680
create_dir_all(&full_path)?;
667681

668682
full_path
669683
}
670684

671-
None => efi_linux_path,
685+
(false, None) => pe_install_dir,
672686
};
673687

674688
let pe_dir = Dir::open_ambient_dir(&final_pe_path, ambient_authority())
@@ -919,6 +933,7 @@ pub(crate) fn setup_composefs_uki_boot(
919933
})?;
920934

921935
if !addons.iter().any(|passed_addon| passed_addon == addon_name) {
936+
tracing::debug!("Skipping addon '{addon_name}'");
922937
continue;
923938
}
924939
}

0 commit comments

Comments
 (0)