Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/lib/src/bootc_composefs/backwards_compat/bcompat_boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
ORIGIN_KEY_BOOT, ORIGIN_KEY_BOOT_TYPE, STATE_DIR_RELATIVE, TYPE1_BOOT_DIR_PREFIX,
TYPE1_ENT_PATH_STAGED, UKI_NAME_PREFIX, USER_CFG_STAGED,
},
parsers::bls_config::{BLSConfig, BLSConfigType},
parsers::bls_config::{BLSConfig, BLSConfigType, EFIKey},
spec::BootloaderKind,
store::Storage,
};
Expand Down Expand Up @@ -214,12 +214,16 @@ fn stage_bls_entry_changes(
.collect();
}

BLSConfigType::EFI { efi, .. } => {
BLSConfigType::EFI { key, .. } => {
// boot_dir in case of UKI is the ESP
plan_efi_binary_renames(&boot_dir, &digest, &mut rename_transaction)?;
*efi = Utf8PathBuf::from("/")
let new_path = Utf8PathBuf::from("/")
.join(BOOTC_UKI_DIR)
.join(get_uki_name(&digest));
*key = match key {
EFIKey::Efi(_) => EFIKey::Efi(new_path),
EFIKey::Uki(_) => EFIKey::Uki(new_path),
};
}

_ => anyhow::bail!("Unknown BLS config type"),
Expand Down
10 changes: 7 additions & 3 deletions crates/lib/src/bootc_composefs/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ use crate::bootc_composefs::state::{get_booted_bls, write_composefs_state};
use crate::bootc_composefs::status::ComposefsCmdline;
use crate::bootc_kargs::compute_new_kargs;
use crate::composefs_consts::{TYPE1_BOOT_DIR_PREFIX, TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED};
use crate::parsers::bls_config::{BLSConfig, BLSConfigType};
use crate::parsers::bls_config::{BLSConfig, BLSConfigType, EFIKey};
use crate::spec::BootloaderKind;
use crate::task::Task;
use crate::{bootc_composefs::repo::open_composefs_repo, store::Storage};
Expand Down Expand Up @@ -997,6 +997,7 @@ fn write_systemd_uki_config(
setup_type: &BootSetupType,
boot_label: UKIInfo,
id: &Sha512HashValue,
bootloader: &Bootloader,
) -> Result<()> {
let os_id = boot_label.os_id.as_deref().unwrap_or("bootc");
let primary_sort_key = primary_sort_key(os_id);
Expand All @@ -1005,7 +1006,10 @@ fn write_systemd_uki_config(
bls_conf
.with_title(boot_label.boot_label)
.with_cfg(BLSConfigType::EFI {
efi: format!("/{BOOTC_UKI_DIR}/{}", get_uki_name(&id.to_hex())).into(),
key: EFIKey::for_bootloader(
format!("/{BOOTC_UKI_DIR}/{}", get_uki_name(&id.to_hex())).into(),
bootloader,
),
})
.with_sort_key(primary_sort_key.clone())
.with_version(boot_label.version.unwrap_or_else(|| id.to_hex()));
Expand Down Expand Up @@ -1169,7 +1173,7 @@ pub(crate) fn setup_composefs_uki_boot(
}

BootloaderKind::BLSCompatible => {
write_systemd_uki_config(&esp_mount.fd, &setup_type, uki_info, id)?
write_systemd_uki_config(&esp_mount.fd, &setup_type, uki_info, id, &bootloader)?
}
};

Expand Down
9 changes: 6 additions & 3 deletions crates/lib/src/bootc_composefs/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
COMPOSEFS_STAGED_DEPLOYMENT_FNAME, COMPOSEFS_TRANSIENT_STATE_DIR, STATE_DIR_RELATIVE,
TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED, USER_CFG_STAGED,
},
parsers::bls_config::{BLSConfigType, parse_bls_config},
parsers::bls_config::{BLSConfigType, EFIKey, parse_bls_config},
spec::{BootEntry, BootloaderKind, DeploymentEntry},
status::Slot,
store::{BootedComposefs, Storage},
Expand Down Expand Up @@ -54,8 +54,11 @@ fn delete_type1_conf_file(
let bls_config = parse_bls_config(&cfg)?;

match &bls_config.cfg_type {
BLSConfigType::EFI { efi } => {
if !efi.as_str().contains(&depl.deployment.verity) {
BLSConfigType::EFI { key } => {
let path = match key {
EFIKey::Efi(path) | EFIKey::Uki(path) => path,
};
if !path.as_str().contains(&depl.deployment.verity) {
continue;
}

Expand Down
9 changes: 6 additions & 3 deletions crates/lib/src/bootc_composefs/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::bootc_composefs::boot::BootType;
use crate::bootc_composefs::status::{
ComposefsCmdline, StagedDeployment, get_sorted_type1_boot_entries,
};
use crate::parsers::bls_config::BLSConfigType;
use crate::parsers::bls_config::{BLSConfigType, EFIKey};
use crate::store::{BootedComposefs, Storage};
use crate::{
composefs_consts::{
Expand Down Expand Up @@ -69,8 +69,11 @@ pub(crate) fn get_booted_bls(boot_dir: &Dir, booted_cfs: &BootedComposefs) -> Re

for entry in sorted_entries {
match &entry.cfg_type {
BLSConfigType::EFI { efi } => {
if efi.as_str().contains(&*booted_cfs.cmdline.digest) {
BLSConfigType::EFI { key } => {
let path = match key {
EFIKey::Efi(path) | EFIKey::Uki(path) => path,
};
if path.as_str().contains(&*booted_cfs.cmdline.digest) {
return Ok(entry);
}
}
Expand Down
9 changes: 6 additions & 3 deletions crates/lib/src/bootc_composefs/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
},
install::EFI_LOADER_INFO,
parsers::{
bls_config::{BLSConfig, BLSConfigType, parse_bls_config},
bls_config::{BLSConfig, BLSConfigType, EFIKey, parse_bls_config},
grub_menuconfig::{MenuEntry, parse_grub_menuentry_file},
},
spec::{BootEntry, BootOrder, BootloaderKind, Host, HostSpec, ImageStatus},
Expand Down Expand Up @@ -980,8 +980,11 @@ async fn composefs_deployment_status_from(

let is_rollback_queued = match &bls_config.cfg_type {
// For UKI boot
BLSConfigType::EFI { efi } => {
efi.as_str().contains(booted_composefs_digest.as_ref())
BLSConfigType::EFI { key } => {
let path = match key {
EFIKey::Efi(path) | EFIKey::Uki(path) => path,
};
path.as_str().contains(booted_composefs_digest.as_ref())
}

// For boot entry Type1
Expand Down
15 changes: 13 additions & 2 deletions crates/lib/src/bootloader.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fs::create_dir_all;
use std::process::Command;
use std::sync::OnceLock;

use anyhow::{Context, Result, anyhow, bail};
use bootc_utils::{ChrootCmd, CommandRunExt};
Expand Down Expand Up @@ -326,9 +327,19 @@ pub(crate) fn install_systemd_boot(
}

#[context("Querying bootctl version")]
fn bootctl_systemd_version() -> Result<u32> {
pub(crate) fn bootctl_systemd_version() -> Result<u32> {
Comment thread
Johan-Liebert1 marked this conversation as resolved.
static VERSION: OnceLock<u32> = OnceLock::new();

if let Some(v) = VERSION.get() {
return Ok(*v);
};

let out = Command::new("bootctl").arg("--version").run_get_string()?;
parse_systemd_version(&out)
let v = parse_systemd_version(&out).context("Failed to parse version to integer")?;

let version = VERSION.get_or_init(|| v);

Ok(*version)
}

/// Parse the systemd major version from `bootctl --version` output, whose first
Expand Down
Loading
Loading