tool: introduce --target-system to choose target architecture
We will hard fail in case of encountering different architectures in bootspec. This should still be compatible with cross-compiling systems in the future.
This commit is contained in:
parent
acc4c2e0a1
commit
e5c1d74e3f
|
@ -104,6 +104,7 @@ in
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${cfg.package}/bin/lzbt install \
|
${cfg.package}/bin/lzbt install \
|
||||||
|
--system ${config.nixpkgs.hostPlatform.system} \
|
||||||
--systemd ${config.systemd.package} \
|
--systemd ${config.systemd.package} \
|
||||||
--systemd-boot-loader-config ${loaderConfigFile} \
|
--systemd-boot-loader-config ${loaderConfigFile} \
|
||||||
--public-key ${cfg.publicKeyFile} \
|
--public-key ${cfg.publicKeyFile} \
|
||||||
|
|
|
@ -76,6 +76,7 @@ impl EspGenerationPaths {
|
||||||
pub fn new<const N: usize, P: EspPaths<N>>(
|
pub fn new<const N: usize, P: EspPaths<N>>(
|
||||||
esp_paths: &P,
|
esp_paths: &P,
|
||||||
generation: &Generation,
|
generation: &Generation,
|
||||||
|
system: Architecture,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let bootspec = &generation.spec.bootspec.bootspec;
|
let bootspec = &generation.spec.bootspec.bootspec;
|
||||||
let bootspec_system: Architecture = Architecture::from_nixos_system(&bootspec.system)?;
|
let bootspec_system: Architecture = Architecture::from_nixos_system(&bootspec.system)?;
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::path::PathBuf;
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
|
use crate::esp::Architecture;
|
||||||
use crate::install;
|
use crate::install;
|
||||||
use lanzaboote_tool::signature::KeyPair;
|
use lanzaboote_tool::signature::KeyPair;
|
||||||
|
|
||||||
|
@ -30,6 +31,10 @@ enum Commands {
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct InstallCommand {
|
struct InstallCommand {
|
||||||
|
/// Target system
|
||||||
|
#[arg(long)]
|
||||||
|
target_system: String,
|
||||||
|
|
||||||
/// Systemd path
|
/// Systemd path
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
systemd: PathBuf,
|
systemd: PathBuf,
|
||||||
|
@ -90,6 +95,7 @@ fn install(args: InstallCommand) -> Result<()> {
|
||||||
|
|
||||||
install::Installer::new(
|
install::Installer::new(
|
||||||
PathBuf::from(lanzaboote_stub),
|
PathBuf::from(lanzaboote_stub),
|
||||||
|
Architecture::from_nixos_system(&args.target_system)?,
|
||||||
args.systemd,
|
args.systemd,
|
||||||
args.systemd_boot_loader_config,
|
args.systemd_boot_loader_config,
|
||||||
key_pair,
|
key_pair,
|
||||||
|
|
|
@ -30,11 +30,13 @@ pub struct Installer {
|
||||||
configuration_limit: usize,
|
configuration_limit: usize,
|
||||||
esp_paths: SystemdEspPaths,
|
esp_paths: SystemdEspPaths,
|
||||||
generation_links: Vec<PathBuf>,
|
generation_links: Vec<PathBuf>,
|
||||||
|
arch: Architecture,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Installer {
|
impl Installer {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
lanzaboote_stub: PathBuf,
|
lanzaboote_stub: PathBuf,
|
||||||
|
arch: Architecture,
|
||||||
systemd: PathBuf,
|
systemd: PathBuf,
|
||||||
systemd_boot_loader_config: PathBuf,
|
systemd_boot_loader_config: PathBuf,
|
||||||
key_pair: KeyPair,
|
key_pair: KeyPair,
|
||||||
|
@ -56,6 +58,7 @@ impl Installer {
|
||||||
configuration_limit,
|
configuration_limit,
|
||||||
esp_paths,
|
esp_paths,
|
||||||
generation_links,
|
generation_links,
|
||||||
|
arch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +241,7 @@ impl Installer {
|
||||||
|
|
||||||
let bootspec = &generation.spec.bootspec.bootspec;
|
let bootspec = &generation.spec.bootspec.bootspec;
|
||||||
|
|
||||||
let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation)?;
|
let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation, self.arch)?;
|
||||||
self.gc_roots.extend(esp_gen_paths.to_iter());
|
self.gc_roots.extend(esp_gen_paths.to_iter());
|
||||||
|
|
||||||
let initrd_content = fs::read(
|
let initrd_content = fs::read(
|
||||||
|
@ -284,7 +287,7 @@ impl Installer {
|
||||||
|
|
||||||
let bootspec = &generation.spec.bootspec.bootspec;
|
let bootspec = &generation.spec.bootspec.bootspec;
|
||||||
|
|
||||||
let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation)?;
|
let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation, self.arch)?;
|
||||||
|
|
||||||
let kernel_cmdline =
|
let kernel_cmdline =
|
||||||
assemble_kernel_cmdline(&bootspec.init, bootspec.kernel_params.clone());
|
assemble_kernel_cmdline(&bootspec.init, bootspec.kernel_params.clone());
|
||||||
|
|
Loading…
Reference in New Issue