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.
This commit is contained in:
Raito Bezarius 2023-06-16 16:42:19 +02:00 committed by nikstur
parent e5c1d74e3f
commit 609c11f26d
4 changed files with 15 additions and 5 deletions

View File

@ -53,7 +53,7 @@ impl Architecture {
/// Generic ESP paths which can be specific to a bootloader /// Generic ESP paths which can be specific to a bootloader
pub trait EspPaths<const N: usize> { pub trait EspPaths<const N: usize> {
/// Build an ESP path structure out of the ESP root directory /// Build an ESP path structure out of the ESP root directory
fn new(esp: impl AsRef<Path>) -> Self; fn new(esp: impl AsRef<Path>, arch: Architecture) -> Self;
/// Return the used file paths to store as garbage collection roots. /// Return the used file paths to store as garbage collection roots.
fn iter(&self) -> std::array::IntoIter<&PathBuf, N>; fn iter(&self) -> std::array::IntoIter<&PathBuf, N>;

View File

@ -45,8 +45,8 @@ impl Installer {
generation_links: Vec<PathBuf>, generation_links: Vec<PathBuf>,
) -> Self { ) -> Self {
let mut gc_roots = Roots::new(); let mut gc_roots = Roots::new();
let esp_paths = SystemdEspPaths::new(esp); let esp_paths = EspPaths::new(esp, target_arch);
gc_roots.extend(esp_paths.iter()); gc_roots.extend(esp_paths.to_iter());
Self { Self {
broken_gens: BTreeSet::new(), broken_gens: BTreeSet::new(),

View File

@ -156,6 +156,8 @@ pub fn lanzaboote_install(
.env("LANZABOOTE_STUB", test_systemd_stub) .env("LANZABOOTE_STUB", test_systemd_stub)
.arg("-vv") .arg("-vv")
.arg("install") .arg("install")
.arg("--system")
.arg(TARGET_SYSTEM_DOUBLE)
.arg("--systemd") .arg("--systemd")
.arg(test_systemd) .arg(test_systemd)
.arg("--systemd-boot-loader-config") .arg("--systemd-boot-loader-config")

View File

@ -2,6 +2,8 @@ use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::Result; use anyhow::Result;
use lanzaboote_tool::architecture::Architecture;
use lzbt_systemd::architecture::SystemdArchitectureExt;
use tempfile::tempdir; use tempfile::tempdir;
mod common; mod common;
@ -113,9 +115,15 @@ fn overwrite_unsigned_systemd_boot_binaries() -> Result<()> {
} }
fn systemd_boot_path(esp: &tempfile::TempDir) -> PathBuf { 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 { 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())
} }