@@ -76,10 +76,15 @@ use serde::{Deserialize, Serialize};
7676use self :: baseline:: InstallBlockDeviceOpts ;
7777use crate :: bls_config:: { parse_bls_config, BLSConfig } ;
7878use crate :: boundimage:: { BoundImage , ResolvedBoundImage } ;
79+ use crate :: composefs_consts:: {
80+ BOOT_LOADER_ENTRIES , COMPOSEFS_CMDLINE , COMPOSEFS_STAGED_DEPLOYMENT_FNAME ,
81+ COMPOSEFS_TRANSIENT_STATE_DIR , ORIGIN_KEY_BOOT , ORIGIN_KEY_BOOT_DIGEST , ORIGIN_KEY_BOOT_TYPE ,
82+ STAGED_BOOT_LOADER_ENTRIES , STATE_DIR_ABS , STATE_DIR_RELATIVE , USER_CFG , USER_CFG_STAGED ,
83+ } ;
7984use crate :: containerenv:: ContainerExecutionInfo ;
8085use crate :: deploy:: {
8186 get_sorted_uki_boot_entries, prepare_for_pull, pull_from_prepared, PreparedImportMeta ,
82- PreparedPullResult , USER_CFG , USER_CFG_STAGED ,
87+ PreparedPullResult ,
8388} ;
8489use crate :: kernel_cmdline:: Cmdline ;
8590use crate :: lsm;
@@ -1496,7 +1501,7 @@ async fn initialize_composefs_repository(
14961501
14971502 rootfs_dir
14981503 . create_dir_all ( "composefs" )
1499- . context ( "Creating dir ' composefs' " ) ?;
1504+ . context ( "Creating dir composefs" ) ?;
15001505
15011506 let repo = open_composefs_repo ( rootfs_dir) ?;
15021507
@@ -1518,7 +1523,7 @@ async fn initialize_composefs_repository(
15181523fn get_booted_bls ( ) -> Result < BLSConfig > {
15191524 let cmdline = crate :: kernel_cmdline:: Cmdline :: from_proc ( ) ?;
15201525 let booted = cmdline
1521- . find_str ( "composefs" )
1526+ . find_str ( COMPOSEFS_CMDLINE )
15221527 . ok_or_else ( || anyhow:: anyhow!( "Failed to find composefs parameter in kernel cmdline" ) ) ?;
15231528
15241529 for entry in std:: fs:: read_dir ( "/sysroot/boot/loader/entries" ) ? {
@@ -1708,10 +1713,10 @@ pub(crate) fn setup_composefs_bls_boot(
17081713
17091714 match & state. composefs_options {
17101715 Some ( opt) if opt. insecure => {
1711- cmdline_options. push_str ( & format ! ( " composefs =?{id_hex}" ) ) ;
1716+ cmdline_options. push_str ( & format ! ( " {COMPOSEFS_CMDLINE} =?{id_hex}" ) ) ;
17121717 }
17131718 None | Some ( ..) => {
1714- cmdline_options. push_str ( & format ! ( " composefs ={id_hex}" ) ) ;
1719+ cmdline_options. push_str ( & format ! ( " {COMPOSEFS_CMDLINE} ={id_hex}" ) ) ;
17151720 }
17161721 } ;
17171722
@@ -1723,7 +1728,7 @@ pub(crate) fn setup_composefs_bls_boot(
17231728 vec ! [
17241729 format!( "root=UUID={DPS_UUID}" ) ,
17251730 RW_KARG . to_string( ) ,
1726- format!( "composefs ={id_hex}" ) ,
1731+ format!( "{COMPOSEFS_CMDLINE} ={id_hex}" ) ,
17271732 ]
17281733 . join ( " " ) ,
17291734 ) ,
@@ -1766,9 +1771,12 @@ pub(crate) fn setup_composefs_bls_boot(
17661771 booted_bls. version = 0 ; // entries are sorted by their filename in reverse order
17671772
17681773 // This will be atomically renamed to 'loader/entries' on shutdown/reboot
1769- ( boot_dir. join ( "loader/entries.staged" ) , Some ( booted_bls) )
1774+ (
1775+ boot_dir. join ( format ! ( "loader/{STAGED_BOOT_LOADER_ENTRIES}" ) ) ,
1776+ Some ( booted_bls) ,
1777+ )
17701778 } else {
1771- ( boot_dir. join ( "loader/entries" ) , None )
1779+ ( boot_dir. join ( format ! ( "loader/{BOOT_LOADER_ENTRIES}" ) ) , None )
17721780 } ;
17731781
17741782 create_dir_all ( & entries_path) . with_context ( || format ! ( "Creating {:?}" , entries_path) ) ?;
@@ -2130,20 +2138,6 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
21302138 Ok ( ( ) )
21312139}
21322140
2133- pub ( crate ) const COMPOSEFS_TRANSIENT_STATE_DIR : & str = "/run/composefs" ;
2134- /// File created in /run/composefs to record a staged-deployment
2135- pub ( crate ) const COMPOSEFS_STAGED_DEPLOYMENT_FNAME : & str = "staged-deployment" ;
2136-
2137- /// Absolute path to composefs-native state directory
2138- pub ( crate ) const STATE_DIR_ABS : & str = "/sysroot/state/deploy" ;
2139- /// Relative path to composefs-native state directory. Relative to /sysroot
2140- pub ( crate ) const STATE_DIR_RELATIVE : & str = "state/deploy" ;
2141-
2142- pub ( crate ) const ORIGIN_KEY_BOOT : & str = "boot" ;
2143- pub ( crate ) const ORIGIN_KEY_BOOT_TYPE : & str = "boot_type" ;
2144- /// Key to store the SHA256 sum of vmlinuz + initrd for a deployment
2145- pub ( crate ) const ORIGIN_KEY_BOOT_DIGEST : & str = "digest" ;
2146-
21472141/// Creates and populates /sysroot/state/deploy/image_id
21482142#[ context( "Writing composefs state" ) ]
21492143pub ( crate ) fn write_composefs_state (
0 commit comments