From 609c11f26d7e035abcd66f3691171151b1b41a0e Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Fri, 16 Jun 2023 16:42:19 +0200 Subject: [PATCH] tool(systemd-boot): install it once instead of checking for each generation systemd-boot is now installed once for many generations rather than multiple times. This means it is not really possible to manage different system in the same "machine", which is a very obscure usecase, theoretically possible, but not yet encountered. --- rust/tool/shared/src/esp.rs | 2 +- rust/tool/systemd/src/install.rs | 4 ++-- rust/tool/systemd/tests/common/mod.rs | 2 ++ rust/tool/systemd/tests/systemd_boot.rs | 12 ++++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/rust/tool/shared/src/esp.rs b/rust/tool/shared/src/esp.rs index 9437cb0..348e64c 100644 --- a/rust/tool/shared/src/esp.rs +++ b/rust/tool/shared/src/esp.rs @@ -53,7 +53,7 @@ impl Architecture { /// Generic ESP paths which can be specific to a bootloader pub trait EspPaths { /// Build an ESP path structure out of the ESP root directory - fn new(esp: impl AsRef) -> Self; + fn new(esp: impl AsRef, arch: Architecture) -> Self; /// Return the used file paths to store as garbage collection roots. fn iter(&self) -> std::array::IntoIter<&PathBuf, N>; diff --git a/rust/tool/systemd/src/install.rs b/rust/tool/systemd/src/install.rs index c5fc764..d0de11d 100644 --- a/rust/tool/systemd/src/install.rs +++ b/rust/tool/systemd/src/install.rs @@ -45,8 +45,8 @@ impl Installer { generation_links: Vec, ) -> Self { let mut gc_roots = Roots::new(); - let esp_paths = SystemdEspPaths::new(esp); - gc_roots.extend(esp_paths.iter()); + let esp_paths = EspPaths::new(esp, target_arch); + gc_roots.extend(esp_paths.to_iter()); Self { broken_gens: BTreeSet::new(), diff --git a/rust/tool/systemd/tests/common/mod.rs b/rust/tool/systemd/tests/common/mod.rs index 82d9380..0e1182c 100644 --- a/rust/tool/systemd/tests/common/mod.rs +++ b/rust/tool/systemd/tests/common/mod.rs @@ -156,6 +156,8 @@ pub fn lanzaboote_install( .env("LANZABOOTE_STUB", test_systemd_stub) .arg("-vv") .arg("install") + .arg("--system") + .arg(TARGET_SYSTEM_DOUBLE) .arg("--systemd") .arg(test_systemd) .arg("--systemd-boot-loader-config") diff --git a/rust/tool/systemd/tests/systemd_boot.rs b/rust/tool/systemd/tests/systemd_boot.rs index 03eb803..53e5fbe 100644 --- a/rust/tool/systemd/tests/systemd_boot.rs +++ b/rust/tool/systemd/tests/systemd_boot.rs @@ -2,6 +2,8 @@ use std::fs; use std::path::PathBuf; use anyhow::Result; +use lanzaboote_tool::architecture::Architecture; +use lzbt_systemd::architecture::SystemdArchitectureExt; use tempfile::tempdir; mod common; @@ -113,9 +115,15 @@ fn overwrite_unsigned_systemd_boot_binaries() -> Result<()> { } fn systemd_boot_path(esp: &tempfile::TempDir) -> PathBuf { - esp.path().join("EFI/systemd/systemd-bootx64.efi") + let arch = Architecture::from_nixos_system(TARGET_SYSTEM_DOUBLE).unwrap(); + esp.path() + .join("EFI/systemd/") + .join(arch.systemd_filename()) } fn systemd_boot_fallback_path(esp: &tempfile::TempDir) -> PathBuf { - esp.path().join("EFI/BOOT/BOOTX64.EFI") + let arch = Architecture::from_nixos_system(TARGET_SYSTEM_DOUBLE).unwrap(); + esp.path() + .join("EFI/BOOT/") + .join(arch.efi_fallback_filename()) }