@@ -61,6 +61,16 @@ pub(crate) struct BasicFilesystems {
6161/// Configuration for ostree repository
6262pub ( crate ) type OstreeRepoOpts = ostree_ext:: repo_options:: RepoOptions ;
6363
64+ /// Configuration options for bootupd, responsible for setting up the bootloader.
65+ #[ derive( Debug , Clone , Serialize , Deserialize , Default ) ]
66+ #[ serde( rename_all = "kebab-case" , deny_unknown_fields) ]
67+ pub ( crate ) struct Bootupd {
68+ /// Whether to skip writing the boot partition UUID to the bootloader configuration.
69+ /// When true, bootupd is invoked with `--with-static-configs` instead of `--write-uuid`.
70+ /// Defaults to false (UUIDs are written by default).
71+ pub ( crate ) skip_boot_uuid : Option < bool > ,
72+ }
73+
6474/// The serialized `[install]` section
6575#[ derive( Debug , Clone , Serialize , Deserialize , Default ) ]
6676#[ serde( rename = "install" , rename_all = "kebab-case" , deny_unknown_fields) ]
@@ -85,6 +95,8 @@ pub(crate) struct InstallConfiguration {
8595 pub ( crate ) root_mount_spec : Option < String > ,
8696 /// Mount specification for the /boot filesystem.
8797 pub ( crate ) boot_mount_spec : Option < String > ,
98+ /// Bootupd configuration
99+ pub ( crate ) bootupd : Option < Bootupd > ,
88100}
89101
90102fn merge_basic < T > ( s : & mut Option < T > , o : Option < T > , _env : & EnvProperties ) {
@@ -142,6 +154,13 @@ impl Mergeable for OstreeRepoOpts {
142154 }
143155}
144156
157+ impl Mergeable for Bootupd {
158+ /// Apply any values in other, overriding any existing values in `self`.
159+ fn merge ( & mut self , other : Self , env : & EnvProperties ) {
160+ merge_basic ( & mut self . skip_boot_uuid , other. skip_boot_uuid , env)
161+ }
162+ }
163+
145164impl Mergeable for InstallConfiguration {
146165 /// Apply any values in other, overriding any existing values in `self`.
147166 fn merge ( & mut self , other : Self , env : & EnvProperties ) {
@@ -160,6 +179,7 @@ impl Mergeable for InstallConfiguration {
160179 merge_basic ( & mut self . stateroot , other. stateroot , env) ;
161180 merge_basic ( & mut self . root_mount_spec , other. root_mount_spec , env) ;
162181 merge_basic ( & mut self . boot_mount_spec , other. boot_mount_spec , env) ;
182+ self . bootupd . merge ( other. bootupd , env) ;
163183 if let Some ( other_kargs) = other. kargs {
164184 self . kargs
165185 . get_or_insert_with ( Default :: default)
@@ -731,4 +751,62 @@ boot-mount-spec = ""
731751 assert_eq ! ( install. root_mount_spec. as_deref( ) . unwrap( ) , "" ) ;
732752 assert_eq ! ( install. boot_mount_spec. as_deref( ) . unwrap( ) , "" ) ;
733753 }
754+
755+ #[ test]
756+ fn test_parse_bootupd_skip_boot_uuid ( ) {
757+ // Test parsing true
758+ let c: InstallConfigurationToplevel = toml:: from_str (
759+ r#"[install.bootupd]
760+ skip-boot-uuid = true
761+ "# ,
762+ )
763+ . unwrap ( ) ;
764+ assert_eq ! (
765+ c. install. unwrap( ) . bootupd. unwrap( ) . skip_boot_uuid. unwrap( ) ,
766+ true
767+ ) ;
768+
769+ // Test parsing false
770+ let c: InstallConfigurationToplevel = toml:: from_str (
771+ r#"[install.bootupd]
772+ skip-boot-uuid = false
773+ "# ,
774+ )
775+ . unwrap ( ) ;
776+ assert_eq ! (
777+ c. install. unwrap( ) . bootupd. unwrap( ) . skip_boot_uuid. unwrap( ) ,
778+ false
779+ ) ;
780+
781+ // Test default (not specified) is None
782+ let c: InstallConfigurationToplevel = toml:: from_str (
783+ r#"[install]
784+ root-fs-type = "xfs"
785+ "# ,
786+ )
787+ . unwrap ( ) ;
788+ assert ! ( c. install. unwrap( ) . bootupd. is_none( ) ) ;
789+ }
790+
791+ #[ test]
792+ fn test_merge_bootupd_skip_boot_uuid ( ) {
793+ let env = EnvProperties {
794+ sys_arch : "x86_64" . to_string ( ) ,
795+ } ;
796+ let mut install: InstallConfiguration = toml:: from_str (
797+ r#"[bootupd]
798+ skip-boot-uuid = false
799+ "# ,
800+ )
801+ . unwrap ( ) ;
802+ let other = InstallConfiguration {
803+ bootupd : Some ( Bootupd {
804+ skip_boot_uuid : Some ( true ) ,
805+ } ) ,
806+ ..Default :: default ( )
807+ } ;
808+ install. merge ( other, & env) ;
809+ // skip_boot_uuid should be overridden to true
810+ assert_eq ! ( install. bootupd. unwrap( ) . skip_boot_uuid. unwrap( ) , true ) ;
811+ }
734812}
0 commit comments