@@ -57,7 +57,6 @@ use ostree_ext::composefs_oci::{
5757 image:: create_filesystem as create_composefs_filesystem, pull as composefs_oci_pull,
5858} ;
5959use ostree_ext:: container:: deploy:: ORIGIN_CONTAINER ;
60- use ostree_ext:: oci_spec;
6160use ostree_ext:: ostree;
6261use ostree_ext:: ostree_prepareroot:: { ComposefsState , Tristate } ;
6362use ostree_ext:: prelude:: Cast ;
@@ -74,7 +73,6 @@ use serde::{Deserialize, Serialize};
7473
7574#[ cfg( feature = "install-to-disk" ) ]
7675use self :: baseline:: InstallBlockDeviceOpts ;
77- use crate :: bls_config:: { parse_bls_config, BLSConfig } ;
7876use crate :: boundimage:: { BoundImage , ResolvedBoundImage } ;
7977use crate :: composefs_consts:: {
8078 BOOT_LOADER_ENTRIES , COMPOSEFS_CMDLINE , COMPOSEFS_STAGED_DEPLOYMENT_FNAME ,
@@ -89,6 +87,7 @@ use crate::deploy::{
8987} ;
9088use crate :: kernel_cmdline:: Cmdline ;
9189use crate :: lsm;
90+ use crate :: parsers:: bls_config:: { parse_bls_config, BLSConfig } ;
9291use crate :: parsers:: grub_menuconfig:: MenuEntry ;
9392use crate :: progress_jsonl:: ProgressWriter ;
9493use crate :: spec:: ImageReference ;
@@ -1536,8 +1535,11 @@ fn get_booted_bls() -> Result<BLSConfig> {
15361535
15371536 let bls = parse_bls_config ( & std:: fs:: read_to_string ( & entry. path ( ) ) ?) ?;
15381537
1539- // TODO clean this up
1540- if bls. options . contains ( booted. as_ref ( ) ) {
1538+ let Some ( opts) = & bls. options else {
1539+ anyhow:: bail!( "options not found in bls config" )
1540+ } ;
1541+
1542+ if opts. contains ( booted. as_ref ( ) ) {
15411543 return Ok ( bls) ;
15421544 }
15431545 }
@@ -1747,18 +1749,18 @@ pub(crate) fn setup_composefs_bls_boot(
17471749 let boot_digest = compute_boot_digest ( usr_lib_modules_vmlinuz, & repo)
17481750 . context ( "Computing boot digest" ) ?;
17491751
1750- let mut bls_config = BLSConfig {
1751- title : Some ( id_hex. clone ( ) ) ,
1752- version : 1 ,
1753- linux : format ! ( "/boot/{id_hex}/vmlinuz" ) ,
1754- initrd : format ! ( "/boot/{id_hex}/initrd" ) ,
1755- options : cmdline_refs ,
1756- extra : HashMap :: new ( ) ,
1757- } ;
1752+ let mut bls_config = BLSConfig :: default ( ) ;
1753+ bls_config . title = Some ( id_hex. clone ( ) ) ;
1754+ bls_config . sort_key = Some ( "1" . into ( ) ) ;
1755+ bls_config . machine_id = None ;
1756+ bls_config . linux = format ! ( "/boot/{id_hex}/vmlinuz" ) ;
1757+ bls_config . initrd = vec ! [ format! ( "/boot/{id_hex}/initrd" ) ] ;
1758+ bls_config . options = Some ( cmdline_refs ) ;
1759+ bls_config . extra = HashMap :: new ( ) ;
17581760
17591761 if let Some ( symlink_to) = find_vmlinuz_initrd_duplicates ( & boot_digest) ? {
17601762 bls_config. linux = format ! ( "/boot/{symlink_to}/vmlinuz" ) ;
1761- bls_config. initrd = format ! ( "/boot/{symlink_to}/initrd" ) ;
1763+ bls_config. initrd = vec ! [ format!( "/boot/{symlink_to}/initrd" ) ] ;
17621764 } else {
17631765 write_bls_boot_entries_to_disk ( & boot_dir, id, usr_lib_modules_vmlinuz, & repo) ?;
17641766 }
@@ -1769,7 +1771,7 @@ pub(crate) fn setup_composefs_bls_boot(
17691771
17701772 let ( entries_path, booted_bls) = if is_upgrade {
17711773 let mut booted_bls = get_booted_bls ( ) ?;
1772- booted_bls. version = 0 ; // entries are sorted by their filename in reverse order
1774+ booted_bls. sort_key = Some ( "0" . into ( ) ) ; // entries are sorted by their filename in reverse order
17731775
17741776 // This will be atomically renamed to 'loader/entries' on shutdown/reboot
17751777 (
@@ -1787,13 +1789,15 @@ pub(crate) fn setup_composefs_bls_boot(
17871789 . with_context ( || format ! ( "Opening {entries_path}" ) ) ?;
17881790
17891791 loader_entries_dir. atomic_write (
1790- format ! ( "bootc-composefs-{}.conf" , bls_config. version) ,
1792+ // SAFETY: We set sort_key above
1793+ format ! ( "bootc-composefs-{}.conf" , bls_config. sort_key. as_ref( ) . unwrap( ) ) ,
17911794 bls_config. to_string ( ) . as_bytes ( ) ,
17921795 ) ?;
17931796
17941797 if let Some ( booted_bls) = booted_bls {
17951798 loader_entries_dir. atomic_write (
1796- format ! ( "bootc-composefs-{}.conf" , booted_bls. version) ,
1799+ // SAFETY: We set sort_key above
1800+ format ! ( "bootc-composefs-{}.conf" , booted_bls. sort_key. as_ref( ) . unwrap( ) ) ,
17971801 booted_bls. to_string ( ) . as_bytes ( ) ,
17981802 ) ?;
17991803 }
0 commit comments