Merge remote-tracking branch 'origin/lanzatool-bootspec-funz'

This commit is contained in:
Julian Stecklina 2022-11-24 12:28:03 +01:00
commit 417122e840
3 changed files with 26 additions and 34 deletions

View File

@ -1,25 +1,23 @@
{ {
"v1": { "init": "/run/current-system/init",
"init": "/run/current-system/init", "initrd": "/run/current-system/initrd",
"initrd": "/run/current-system/initrd", "kernel": "/run/current-system/kernel",
"kernel": "/run/current-system/kernel", "kernelParams": [
"kernelParams": [ "amd_iommu=on",
"amd_iommu=on", "amd_iommu=pt",
"amd_iommu=pt", "iommu=pt",
"iommu=pt", "kvm.ignore_msrs=1",
"kvm.ignore_msrs=1", "kvm.report_ignored_msrs=0",
"kvm.report_ignored_msrs=0", "udev.log_priority=3",
"udev.log_priority=3", "systemd.unified_cgroup_hierarchy=1",
"systemd.unified_cgroup_hierarchy=1", "loglevel=4"
"loglevel=4" ],
], "label": "LanzaOS",
"label": "LanzaOS", "toplevel": "/run/current-system",
"toplevel": "/run/current-system", "extension": {
"extension": { "esp": "esp",
"esp": "esp", "systemd": "/run/current-system/systemd",
"systemd": "/run/current-system/systemd", "bootctl": "/run/current-system/sw/bin/bootctl",
"bootctl": "/run/current-system/sw/bin/bootctl", "osRelease": "/etc/os-release"
"osRelease": "/etc/os-release"
}
} }
} }

View File

@ -2,14 +2,9 @@ use std::path::PathBuf;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct Bootspec {
pub v1: GenerationV1,
}
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)] #[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct GenerationV1 { pub struct Bootspec {
/// Label for the system closure /// Label for the system closure
pub label: String, pub label: String,
/// Path to kernel (bzImage) -- $toplevel/kernel /// Path to kernel (bzImage) -- $toplevel/kernel

View File

@ -16,30 +16,29 @@ pub fn install(
) -> Result<()> { ) -> Result<()> {
let bootspec_doc: Bootspec = serde_json::from_slice(&fs::read(bootspec)?)?; let bootspec_doc: Bootspec = serde_json::from_slice(&fs::read(bootspec)?)?;
let esp_paths = EspPaths::new(&bootspec_doc.v1.extension.esp); let esp_paths = EspPaths::new(&bootspec_doc.extension.esp);
let lanzaboote_image = pe::assemble_image( let lanzaboote_image = pe::assemble_image(
lanzaboote_stub, lanzaboote_stub,
&bootspec_doc.v1.extension.os_release, &bootspec_doc.extension.os_release,
&bootspec_doc.v1.kernel_params, &bootspec_doc.kernel_params,
&esp_paths.kernel, &esp_paths.kernel,
&esp_paths.initrd, &esp_paths.initrd,
) )
.expect("Failed to assemble stub"); .expect("Failed to assemble stub");
let wrapped_initrd = let wrapped_initrd =
pe::wrap_initrd(initrd_stub, &bootspec_doc.v1.initrd).expect("Failed to assemble stub"); pe::wrap_initrd(initrd_stub, &bootspec_doc.initrd).expect("Failed to assemble stub");
// Copy the files to the ESP // Copy the files to the ESP
fs::create_dir_all(&esp_paths.nixos)?; fs::create_dir_all(&esp_paths.nixos)?;
fs::copy(bootspec_doc.v1.kernel, esp_paths.kernel)?; fs::copy(bootspec_doc.kernel, esp_paths.kernel)?;
fs::copy(wrapped_initrd, esp_paths.initrd)?; fs::copy(wrapped_initrd, esp_paths.initrd)?;
fs::create_dir_all(&esp_paths.linux)?; fs::create_dir_all(&esp_paths.linux)?;
fs::copy(lanzaboote_image, esp_paths.lanzaboote_image)?; fs::copy(lanzaboote_image, esp_paths.lanzaboote_image)?;
let systemd_boot = bootspec_doc let systemd_boot = bootspec_doc
.v1
.extension .extension
.systemd .systemd
.join("lib/systemd/boot/efi/systemd-bootx64.efi"); .join("lib/systemd/boot/efi/systemd-bootx64.efi");