From 011a4b80ea3c337dbc8a4c319e732623559e6595 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Wed, 2 Jan 2019 12:20:29 -0500 Subject: [PATCH] add kernel-version field to metainfo --- citadel-image/src/build.rs | 4 ++++ citadel-image/src/config.rs | 4 ++++ libcitadel/src/header.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/citadel-image/src/build.rs b/citadel-image/src/build.rs index 006cd8b..4d0752c 100644 --- a/citadel-image/src/build.rs +++ b/citadel-image/src/build.rs @@ -148,6 +148,7 @@ impl UpdateBuilder { hdr.set_flag(ImageHeader::FLAG_DATA_COMPRESSED); let metainfo = self.generate_metainfo(); + fs::write(self.config.workdir_path("metainfo"), &metainfo)?; hdr.set_metainfo_bytes(&metainfo); Ok(hdr) } @@ -163,6 +164,9 @@ impl UpdateBuilder { let mut v = Vec::new(); writeln!(v, "image-type = \"{}\"", self.config.image_type())?; + if let Some(kv) = self.config.kernel_version() { + writeln!(v, "kernel-version = \"{}\"", kv)?; + } writeln!(v, "channel = \"{}\"", self.config.channel())?; writeln!(v, "version = {}", self.config.version())?; writeln!(v, "nblocks = {}", self.nblocks.unwrap())?; diff --git a/citadel-image/src/config.rs b/citadel-image/src/config.rs index bc5fe47..80bf89f 100644 --- a/citadel-image/src/config.rs +++ b/citadel-image/src/config.rs @@ -86,6 +86,10 @@ impl BuildConfig { &self.img_name } + pub fn kernel_version(&self) -> Option<&str> { + self.kernel_version.as_ref().map(|s| s.as_str()) + } + pub fn version(&self) -> usize { self.version } diff --git a/libcitadel/src/header.rs b/libcitadel/src/header.rs index cc49635..0913590 100644 --- a/libcitadel/src/header.rs +++ b/libcitadel/src/header.rs @@ -291,6 +291,8 @@ struct MetaInfoToml { #[serde(rename = "image-type")] image_type: String, channel: String, + #[serde(rename = "kernel-version")] + kernel_version: Option, version: u32, #[serde(rename = "base-version")] base_version: Option, @@ -351,6 +353,8 @@ impl MetaInfo { self.toml().channel.as_str() } + pub fn kernel_version(&self) -> Option<&str> { self.toml().kernel_version.as_ref().map(|s| s.as_str()) } + pub fn version(&self) -> u32 { self.toml().version }