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",
"initrd": "/run/current-system/initrd",
"kernel": "/run/current-system/kernel",
"kernelParams": [
"amd_iommu=on",
"amd_iommu=pt",
"iommu=pt",
"kvm.ignore_msrs=1",
"kvm.report_ignored_msrs=0",
"udev.log_priority=3",
"systemd.unified_cgroup_hierarchy=1",
"loglevel=4"
],
"label": "LanzaOS",
"toplevel": "/run/current-system",
"extension": {
"esp": "esp",
"systemd": "/run/current-system/systemd",
"bootctl": "/run/current-system/sw/bin/bootctl",
"osRelease": "/etc/os-release"
}
"init": "/run/current-system/init",
"initrd": "/run/current-system/initrd",
"kernel": "/run/current-system/kernel",
"kernelParams": [
"amd_iommu=on",
"amd_iommu=pt",
"iommu=pt",
"kvm.ignore_msrs=1",
"kvm.report_ignored_msrs=0",
"udev.log_priority=3",
"systemd.unified_cgroup_hierarchy=1",
"loglevel=4"
],
"label": "LanzaOS",
"toplevel": "/run/current-system",
"extension": {
"esp": "esp",
"systemd": "/run/current-system/systemd",
"bootctl": "/run/current-system/sw/bin/bootctl",
"osRelease": "/etc/os-release"
}
}

View File

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

View File

@ -16,30 +16,29 @@ pub fn install(
) -> Result<()> {
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(
lanzaboote_stub,
&bootspec_doc.v1.extension.os_release,
&bootspec_doc.v1.kernel_params,
&bootspec_doc.extension.os_release,
&bootspec_doc.kernel_params,
&esp_paths.kernel,
&esp_paths.initrd,
)
.expect("Failed to assemble stub");
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
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::create_dir_all(&esp_paths.linux)?;
fs::copy(lanzaboote_image, esp_paths.lanzaboote_image)?;
let systemd_boot = bootspec_doc
.v1
.extension
.systemd
.join("lib/systemd/boot/efi/systemd-bootx64.efi");