@@ -58,6 +58,9 @@ pub(crate) struct BasicFilesystems {
5858 // pub(crate) esp: Option<FilesystemCustomization>,
5959}
6060
61+ /// Configuration for ostree repository
62+ pub ( crate ) type OstreeRepoOpts = ostree_ext:: repo_options:: RepoOptions ;
63+
6164/// The serialized [install] section
6265#[ derive( Debug , Clone , Serialize , Deserialize , Default ) ]
6366#[ serde( rename = "install" , rename_all = "kebab-case" , deny_unknown_fields) ]
@@ -73,6 +76,8 @@ pub(crate) struct InstallConfiguration {
7376 pub ( crate ) kargs : Option < Vec < String > > ,
7477 /// Supported architectures for this configuration
7578 pub ( crate ) match_architectures : Option < Vec < String > > ,
79+ /// Ostree repository configuration
80+ pub ( crate ) ostree : Option < OstreeRepoOpts > ,
7681}
7782
7883fn merge_basic < T > ( s : & mut Option < T > , o : Option < T > , _env : & EnvProperties ) {
@@ -119,6 +124,17 @@ impl Mergeable for BasicFilesystems {
119124 }
120125}
121126
127+ impl Mergeable for OstreeRepoOpts {
128+ /// Apply any values in other, overriding any existing values in `self`.
129+ fn merge ( & mut self , other : Self , env : & EnvProperties ) {
130+ merge_basic (
131+ & mut self . bls_append_except_default ,
132+ other. bls_append_except_default ,
133+ env,
134+ )
135+ }
136+ }
137+
122138impl Mergeable for InstallConfiguration {
123139 /// Apply any values in other, overriding any existing values in `self`.
124140 fn merge ( & mut self , other : Self , env : & EnvProperties ) {
@@ -133,6 +149,7 @@ impl Mergeable for InstallConfiguration {
133149 #[ cfg( feature = "install-to-disk" ) ]
134150 merge_basic ( & mut self . block , other. block , env) ;
135151 self . filesystem . merge ( other. filesystem , env) ;
152+ self . ostree . merge ( other. ostree , env) ;
136153 if let Some ( other_kargs) = other. kargs {
137154 self . kargs
138155 . get_or_insert_with ( Default :: default)
@@ -572,4 +589,54 @@ root-fs-type = "xfs"
572589 )
573590 ) ;
574591 }
592+
593+ #[ test]
594+ fn test_parse_ostree ( ) {
595+ let env = EnvProperties {
596+ sys_arch : "x86_64" . to_string ( ) ,
597+ } ;
598+
599+ // Table-driven test cases for parsing bls-append-except-default
600+ let parse_cases = [
601+ ( "console=ttyS0" , "console=ttyS0" ) ,
602+ ( "console=ttyS0,115200n8" , "console=ttyS0,115200n8" ) ,
603+ ( "rd.lvm.lv=vg/root" , "rd.lvm.lv=vg/root" ) ,
604+ ] ;
605+ for ( input, expected) in parse_cases {
606+ let toml_str = format ! (
607+ r#"[install.ostree]
608+ bls-append-except-default = "{input}"
609+ "#
610+ ) ;
611+ let c: InstallConfigurationToplevel = toml:: from_str ( & toml_str) . unwrap ( ) ;
612+ assert_eq ! (
613+ c. install
614+ . unwrap( )
615+ . ostree
616+ . unwrap( )
617+ . bls_append_except_default
618+ . unwrap( ) ,
619+ expected
620+ ) ;
621+ }
622+
623+ // Test merging: other config should override original
624+ let mut install: InstallConfiguration = toml:: from_str (
625+ r#"[ostree]
626+ bls-append-except-default = "console=ttyS0"
627+ "# ,
628+ )
629+ . unwrap ( ) ;
630+ let other = InstallConfiguration {
631+ ostree : Some ( OstreeRepoOpts {
632+ bls_append_except_default : Some ( "console=tty0" . to_string ( ) ) ,
633+ } ) ,
634+ ..Default :: default ( )
635+ } ;
636+ install. merge ( other, & env) ;
637+ assert_eq ! (
638+ install. ostree. unwrap( ) . bls_append_except_default. unwrap( ) ,
639+ "console=tty0"
640+ ) ;
641+ }
575642}
0 commit comments