Skip to content

Commit

Permalink
feat(xen): correct sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Aug 25, 2024
1 parent 8c0733a commit 17ae11f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
7 changes: 7 additions & 0 deletions rust/tool/shared/src/os_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ impl OsRelease {

Ok(Self(map))
}

pub fn pretty_name(&self) -> &str {
self.0.get("PRETTY_NAME").map(|v| v.as_str()).unwrap_or_default()
}
pub fn version_id(&self) -> &str {
self.0.get("VERSION_ID").map(|v| v.as_str()).unwrap_or_default()
}
}

impl FromStr for OsRelease {
Expand Down
26 changes: 13 additions & 13 deletions rust/tool/systemd/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,29 +255,24 @@ impl Installer {
&initrd_location,
)
.context("Failed to assemble xen image.")?;
let stub_target = self
.esp_paths
.linux
.join(stub_name(generation, &self.key_pair.public_key)?);

let stub_name = stub_name(generation, &self.key_pair.public_key)?;
let stub_target = self.esp_paths.linux.join(&stub_name);
self.gc_roots.extend([&stub_target]);
install_signed(&self.key_pair, &xen_image, &stub_target)
.context("Failed to install the Lanzaboote image.")?;

// TODO: Currently xen doesn't work with specializations,
// and specialization name is not handled here, but this may
// be changed in the future.
// Entry name works as a sort key (?), reusing stub_name to make
// it compatible with UKI entries.
let entry_path = self
.esp_paths
.entries
.join(format!("nixos-xen-{generation}.conf"));
.join(format!("{}.conf", stub_name.display()));
self.gc_roots.extend([&entry_path]);

let mut entry = String::new();
writeln!(
entry,
"title {}",
os_release.0.get("PRETTY_NAME").expect("exists")
)?;
writeln!(entry, "title {}", os_release.pretty_name())?;
writeln!(entry, "version {}", os_release.version_id())?;
// stub_target should be utf-8, .display() is ok here.
// TODO: but better cleanup this. Use esp_relative_uefi_path
// for this calculation.
Expand All @@ -286,6 +281,11 @@ impl Installer {
"efi {}",
stub_target.strip_prefix(&self.esp_paths.esp)?.display()
)?;
writeln!(
entry,
"sort-key {}",
generation.spec.lanzaboote_extension.sort_key,
)?;

let entry_tmp = tempdir.write_secure_file(entry)?;

Expand Down

0 comments on commit 17ae11f

Please sign in to comment.