Skip to content

Commit d2c358e

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 29e5c9a commit d2c358e

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
@@ -57,7 +57,7 @@ use crate::{
5757

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

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

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

645-
// Write the UKI to ESP
646-
let efi_linux_path = mounted_efi.as_ref().join(match bootloader {
647-
Bootloader::Grub => EFI_LINUX,
648-
Bootloader::Systemd => SYSTEMD_UKI_DIR,
652+
// Directory to write the PortableExecutable to
653+
let pe_install_dir = mounted_efi.as_ref().join(match pe_type {
654+
PEType::UkiAddon if INSTALL_ADDONS_AS_GLOBAL => GLOBAL_UKI_ADDON_DIR,
655+
656+
PEType::Uki | PEType::UkiAddon => match bootloader {
657+
Bootloader::Grub => EFI_LINUX,
658+
Bootloader::Systemd => SYSTEMD_UKI_DIR,
659+
},
649660
});
650661

651-
create_dir_all(&efi_linux_path).context("Creating EFI/Linux")?;
662+
create_dir_all(&pe_install_dir)
663+
.with_context(|| format!("Creating {}", pe_install_dir.display()))?;
664+
665+
let final_pe_path = match (INSTALL_ADDONS_AS_GLOBAL, file_path.parent()) {
666+
(true, ..) => pe_install_dir,
652667

653-
let final_pe_path = match file_path.parent() {
654-
Some(parent) => {
668+
(false, Some(parent)) => {
655669
let renamed_path = match parent.as_str().ends_with(EFI_ADDON_DIR_EXT) {
656670
true => {
657671
let dir_name = format!("{}{}", uki_id.to_hex(), EFI_ADDON_DIR_EXT);
@@ -665,13 +679,13 @@ fn write_pe_to_esp(
665679
false => parent.to_path_buf(),
666680
};
667681

668-
let full_path = efi_linux_path.join(renamed_path);
682+
let full_path = pe_install_dir.join(renamed_path);
669683
create_dir_all(&full_path)?;
670684

671685
full_path
672686
}
673687

674-
None => efi_linux_path,
688+
(false, None) => pe_install_dir,
675689
};
676690

677691
let pe_dir = Dir::open_ambient_dir(&final_pe_path, ambient_authority())
@@ -922,6 +936,7 @@ pub(crate) fn setup_composefs_uki_boot(
922936
})?;
923937

924938
if !addons.iter().any(|passed_addon| passed_addon == addon_name) {
939+
tracing::debug!("Skipping addon '{addon_name}'");
925940
continue;
926941
}
927942
}

0 commit comments

Comments
 (0)