Skip to content

Commit 9353ed1

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 ca784bd commit 9353ed1

4 files changed

Lines changed: 12 additions & 18 deletions

File tree

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const AUTH_EXT: &str = "auth";
137137
/// directory specified by the BLS spec. We do this because we want systemd-boot to only look at
138138
/// our config files and not show the actual UKIs in the bootloader menu
139139
/// This is relative to the ESP
140-
pub(crate) const SYSTEMD_UKI_DIR: &str = "EFI/Linux/bootc";
140+
pub(crate) const BOOTC_UKI_DIR: &str = "EFI/Linux/bootc";
141141

142142
pub(crate) enum BootSetupType<'a> {
143143
/// For initial setup, i.e. install to-disk
@@ -793,7 +793,6 @@ fn write_pe_to_esp(
793793
uki_id: &Sha512HashValue,
794794
missing_fsverity_allowed: bool,
795795
mounted_efi: impl AsRef<Path>,
796-
bootloader: &Bootloader,
797796
) -> Result<Option<UKIInfo>> {
798797
let efi_bin = read_file(file, &repo).context("Reading .efi binary")?;
799798

@@ -843,14 +842,8 @@ fn write_pe_to_esp(
843842
});
844843
}
845844

846-
// Write the UKI to ESP
847-
let efi_linux_path = mounted_efi.as_ref().join(match bootloader {
848-
Bootloader::Grub => EFI_LINUX,
849-
Bootloader::Systemd => SYSTEMD_UKI_DIR,
850-
Bootloader::None => unreachable!("Checked at install time"),
851-
});
852-
853-
create_dir_all(&efi_linux_path).context("Creating EFI/Linux")?;
845+
let efi_linux_path = mounted_efi.as_ref().join(BOOTC_UKI_DIR);
846+
create_dir_all(&efi_linux_path).context("Creating bootc UKI directory")?;
854847

855848
let final_pe_path = match file_path.parent() {
856849
Some(parent) => {
@@ -1000,7 +993,7 @@ fn write_systemd_uki_config(
1000993
bls_conf
1001994
.with_title(boot_label.boot_label)
1002995
.with_cfg(BLSConfigType::EFI {
1003-
efi: format!("/{SYSTEMD_UKI_DIR}/{}{}", id.to_hex(), EFI_EXT).into(),
996+
efi: format!("/{BOOTC_UKI_DIR}/{}{}", id.to_hex(), EFI_EXT).into(),
1004997
})
1005998
.with_sort_key(primary_sort_key.clone())
1006999
.with_version(boot_label.version.unwrap_or_else(|| id.to_hex()));
@@ -1143,7 +1136,6 @@ pub(crate) fn setup_composefs_uki_boot(
11431136
&id,
11441137
missing_fsverity_allowed,
11451138
esp_mount.dir.path(),
1146-
&bootloader,
11471139
)?;
11481140

11491141
if let Some(label) = ret {

crates/lib/src/bootc_composefs/gc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustix::fs::readlink;
1313

1414
use crate::{
1515
bootc_composefs::{
16-
boot::{BootType, SYSTEMD_UKI_DIR, VMLINUZ},
16+
boot::{BootType, BOOTC_UKI_DIR, VMLINUZ},
1717
delete::{delete_image, delete_staged, delete_state_dir},
1818
status::{get_composefs_status, get_imginfo, list_bootloader_entries},
1919
},
@@ -83,7 +83,7 @@ fn collect_boot_binaries(storage: &Storage) -> Result<Vec<BootBinary>> {
8383
/// Scan for UKI binaries in EFI/Linux/bootc
8484
#[fn_error_context::context("Collecting UKI binaries")]
8585
fn collect_uki_binaries(boot_dir: &Dir, boot_binaries: &mut Vec<BootBinary>) -> Result<()> {
86-
let Ok(Some(efi_dir)) = boot_dir.open_dir_optional(SYSTEMD_UKI_DIR) else {
86+
let Ok(Some(efi_dir)) = boot_dir.open_dir_optional(BOOTC_UKI_DIR) else {
8787
return Ok(());
8888
};
8989

@@ -164,7 +164,7 @@ fn delete_uki(storage: &Storage, uki_id: &str, dry_run: bool) -> Result<()> {
164164

165165
// NOTE: We don't delete global addons here
166166
// Which is fine as global addons don't belong to any single deployment
167-
let uki_dir = esp_mnt.fd.open_dir(SYSTEMD_UKI_DIR)?;
167+
let uki_dir = esp_mnt.fd.open_dir(BOOTC_UKI_DIR)?;
168168

169169
for entry in uki_dir.entries_utf8()? {
170170
let entry = entry?;

crates/lib/src/bootc_composefs/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
bootc_composefs::{
3-
boot::{SYSTEMD_UKI_DIR, compute_boot_digest_uki},
3+
boot::{BOOTC_UKI_DIR, compute_boot_digest_uki},
44
state::update_boot_digest_in_origin,
55
},
66
store::Storage,
@@ -10,7 +10,7 @@ use bootc_kernel_cmdline::utf8::Cmdline;
1010
use fn_error_context::context;
1111

1212
fn get_uki(storage: &Storage, deployment_verity: &str) -> Result<Vec<u8>> {
13-
let uki_dir = storage.require_esp()?.fd.open_dir(SYSTEMD_UKI_DIR)?;
13+
let uki_dir = storage.require_esp()?.fd.open_dir(BOOTC_UKI_DIR)?;
1414

1515
let req_fname = format!("{deployment_verity}.efi");
1616

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
sequence::delimited,
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)