Skip to content

Commit f855d30

Browse files
composefs/uki: Install all UKIs in EFI/Linux/bootc
We were making a distinction based on the bootloader and installing UKIs in EFI/Linux for Grub and EFI/Linux/bootc for sd-boot. IMO it's better if we use the same directory for both bootloaders Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 800568a commit f855d30

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const VMLINUZ: &str = "vmlinuz";
7373
/// directory specified by the BLS spec. We do this because we want systemd-boot to only look at
7474
/// our config files and not show the actual UKIs in the bootloader menu
7575
/// This is relative to the ESP
76-
pub(crate) const SYSTEMD_UKI_DIR: &str = "EFI/Linux/bootc";
76+
pub(crate) const BOOTC_UKI_DIR: &str = "EFI/Linux/bootc";
7777

7878
pub(crate) enum BootSetupType<'a> {
7979
/// For initial setup, i.e. install to-disk
@@ -420,7 +420,7 @@ pub(crate) fn setup_composefs_bls_boot(
420420
let current_cfg = get_booted_bls(&boot_dir)?;
421421

422422
let mut cmdline = match current_cfg.cfg_type {
423-
BLSConfigType::NonEFI { options, .. } => {
423+
BLSConfigType::NonUKI { options, .. } => {
424424
let options = options
425425
.ok_or_else(|| anyhow::anyhow!("No 'options' found in BLS Config"))?;
426426

@@ -658,7 +658,6 @@ fn write_pe_to_esp(
658658
uki_id: &Sha512HashValue,
659659
is_insecure_from_opts: bool,
660660
mounted_efi: impl AsRef<Path>,
661-
bootloader: &Bootloader,
662661
) -> Result<Option<UKILabels>> {
663662
let efi_bin = read_file(file, &repo).context("Reading .efi binary")?;
664663

@@ -703,13 +702,8 @@ fn write_pe_to_esp(
703702
});
704703
}
705704

706-
// Write the UKI to ESP
707-
let efi_linux_path = mounted_efi.as_ref().join(match bootloader {
708-
Bootloader::Grub => EFI_LINUX,
709-
Bootloader::Systemd => SYSTEMD_UKI_DIR,
710-
});
711-
712-
create_dir_all(&efi_linux_path).context("Creating EFI/Linux")?;
705+
let efi_linux_path = mounted_efi.as_ref().join(BOOTC_UKI_DIR);
706+
create_dir_all(&efi_linux_path).context("Creating bootc UKI directory")?;
713707

714708
let final_pe_path = match file_path.parent() {
715709
Some(parent) => {
@@ -858,7 +852,7 @@ fn write_systemd_uki_config(
858852
bls_conf
859853
.with_title(boot_label.boot_label)
860854
.with_cfg(BLSConfigType::UKI {
861-
uki: format!("/{SYSTEMD_UKI_DIR}/{}{}", id.to_hex(), EFI_EXT).into(),
855+
uki: format!("/{BOOTC_UKI_DIR}/{}{}", id.to_hex(), EFI_EXT).into(),
862856
})
863857
.with_sort_key(default_sort_key.into())
864858
.with_version(boot_label.version.unwrap_or(default_sort_key.into()));
@@ -998,7 +992,6 @@ pub(crate) fn setup_composefs_uki_boot(
998992
&id,
999993
is_insecure_from_opts,
1000994
esp_mount.dir.path(),
1001-
&bootloader,
1002995
)?;
1003996

1004997
if let Some(label) = ret {

crates/lib/src/bootc_composefs/delete.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use composefs_boot::bootloader::{EFI_ADDON_DIR_EXT, EFI_EXT};
77

88
use crate::{
99
bootc_composefs::{
10-
boot::{find_vmlinuz_initrd_duplicates, get_efi_uuid_source, BootType, SYSTEMD_UKI_DIR},
10+
boot::{find_vmlinuz_initrd_duplicates, get_efi_uuid_source, BootType, BOOTC_UKI_DIR},
1111
gc::composefs_gc,
1212
repo::open_composefs_repo,
1313
rollback::{composefs_rollback, rename_exchange_user_cfg},
@@ -153,7 +153,7 @@ fn delete_kernel_initrd(bls_config: &BLSConfigType, boot_dir: &Dir) -> Result<()
153153
#[fn_error_context::context("Deleting UKI and UKI addons {uki_id}")]
154154
fn delete_uki(uki_id: &str, esp_mnt: &Dir) -> Result<()> {
155155
// TODO: We don't delete global addons here
156-
let ukis = esp_mnt.open_dir(SYSTEMD_UKI_DIR)?;
156+
let ukis = esp_mnt.open_dir(BOOTC_UKI_DIR)?;
157157

158158
for entry in ukis.entries_utf8()? {
159159
let entry = entry?;

crates/lib/src/parsers/grub_menuconfig.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use nom::{
1515
Err, IResult, Parser,
1616
};
1717

18+
use crate::bootc_composefs::boot::BOOTC_UKI_DIR;
19+
1820
/// Body content of a GRUB menuentry containing parsed commands.
1921
#[derive(Debug, PartialEq, Eq)]
2022
pub(crate) struct MenuentryBody<'a> {
@@ -95,7 +97,7 @@ impl<'a> MenuEntry<'a> {
9597
title: format!("{boot_label}: ({uki_id})"),
9698
body: MenuentryBody {
9799
insmod: vec!["fat", "chain"],
98-
chainloader: format!("/EFI/Linux/{uki_id}.efi"),
100+
chainloader: format!("/{BOOTC_UKI_DIR}/{uki_id}.efi"),
99101
search: "--no-floppy --set=root --fs-uuid \"${EFI_PART_UUID}\"",
100102
version: 0,
101103
extra: vec![],

0 commit comments

Comments
 (0)