From 5d3e06b5ab3b55cbdd8d51f36fcfc6de0a4c73c8 Mon Sep 17 00:00:00 2001 From: Joel Capitao Date: Tue, 6 Jan 2026 18:42:50 +0100 Subject: [PATCH] install: support configuring sysroot.bls-append-except-default Add a new [install.ostree] configuration section to allow setting the ostree sysroot.bls-append-except-default option during installation. Co-authored-by: Jean-Baptiste Trystram Closes: https://github.com/bootc-dev/bootc/issues/1710 --- crates/lib/src/install.rs | 12 +++++++ crates/lib/src/install/config.rs | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/crates/lib/src/install.rs b/crates/lib/src/install.rs index 993bea730..f3570356e 100644 --- a/crates/lib/src/install.rs +++ b/crates/lib/src/install.rs @@ -802,6 +802,18 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result .run_capture_stderr()?; } + // Apply ostree configuration from install config + if let Some(install_config) = state.install_config.as_ref() { + if let Some(ostree_config) = install_config.ostree.as_ref() { + if let Some(bls_append_except_default) = ostree_config.bls_append_except_default.as_ref() { + Command::new("ostree") + .args(["config", "--repo", "ostree/repo", "set", "sysroot.bls-append-except-default", bls_append_except_default]) + .cwd_dir(rootfs_dir.try_clone()?) + .run_capture_stderr()?; + } + } + } + let sysroot = { let path = format!( "/proc/{}/fd/{}", diff --git a/crates/lib/src/install/config.rs b/crates/lib/src/install/config.rs index bdeecb459..c71562ac8 100644 --- a/crates/lib/src/install/config.rs +++ b/crates/lib/src/install/config.rs @@ -58,6 +58,15 @@ pub(crate) struct BasicFilesystems { // pub(crate) esp: Option, } +/// Configuration for ostree repository +#[derive(Debug, Clone, Serialize, Deserialize, Default)] +#[serde(rename_all = "kebab-case", deny_unknown_fields)] +pub(crate) struct Ostree { + /// Boot Loader Spec entries that should append arguments only for non-default entries + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) bls_append_except_default: Option, +} + /// The serialized [install] section #[derive(Debug, Clone, Serialize, Deserialize, Default)] #[serde(rename = "install", rename_all = "kebab-case", deny_unknown_fields)] @@ -73,6 +82,8 @@ pub(crate) struct InstallConfiguration { pub(crate) kargs: Option>, /// Supported architectures for this configuration pub(crate) match_architectures: Option>, + /// Ostree repository configuration + pub(crate) ostree: Option, } fn merge_basic(s: &mut Option, o: Option, _env: &EnvProperties) { @@ -119,6 +130,13 @@ impl Mergeable for BasicFilesystems { } } +impl Mergeable for Ostree { + /// Apply any values in other, overriding any existing values in `self`. + fn merge(&mut self, other: Self, env: &EnvProperties) { + merge_basic(&mut self.bls_append_except_default, other.bls_append_except_default, env) + } +} + impl Mergeable for InstallConfiguration { /// Apply any values in other, overriding any existing values in `self`. fn merge(&mut self, other: Self, env: &EnvProperties) { @@ -133,6 +151,7 @@ impl Mergeable for InstallConfiguration { #[cfg(feature = "install-to-disk")] merge_basic(&mut self.block, other.block, env); self.filesystem.merge(other.filesystem, env); + self.ostree.merge(other.ostree, env); if let Some(other_kargs) = other.kargs { self.kargs .get_or_insert_with(Default::default) @@ -572,4 +591,44 @@ root-fs-type = "xfs" ) ); } + + #[test] + fn test_parse_ostree() { + let env = EnvProperties { + sys_arch: "x86_64".to_string(), + }; + let c: InstallConfigurationToplevel = toml::from_str( + r##"[install.ostree] +bls-append-except-default = "console=ttyS0" +"##, + ) + .unwrap(); + let install = c.install.unwrap(); + assert_eq!( + install.ostree.as_ref().unwrap().bls_append_except_default.as_ref().unwrap(), + "console=ttyS0" + ); + + // Test merging ostree config + let c: InstallConfigurationToplevel = toml::from_str( + r##"[install.ostree] +bls-append-except-default = "console=ttyS0" +"##, + ) + .unwrap(); + let mut install = c.install.unwrap(); + let other = InstallConfigurationToplevel { + install: Some(InstallConfiguration { + ostree: Some(Ostree { + bls_append_except_default: Some("console=tty0".to_string()), + }), + ..Default::default() + }), + }; + install.merge(other.install.unwrap(), &env); + assert_eq!( + install.ostree.as_ref().unwrap().bls_append_except_default.as_ref().unwrap(), + "console=tty0" + ); + } }