@@ -15,7 +15,7 @@ pub(crate) mod osconfig;
15
15
16
16
use std:: collections:: HashMap ;
17
17
use std:: fs:: create_dir_all;
18
- use std:: io:: { Seek , SeekFrom , Write } ;
18
+ use std:: io:: Write ;
19
19
use std:: os:: fd:: { AsFd , AsRawFd } ;
20
20
use std:: os:: unix:: fs:: symlink;
21
21
use std:: os:: unix:: process:: CommandExt ;
@@ -1781,19 +1781,26 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
1781
1781
transport : state. source . imageref . transport . to_string ( ) ,
1782
1782
signature : None ,
1783
1783
} ,
1784
+ false ,
1784
1785
) ?;
1785
1786
1786
1787
Ok ( ( ) )
1787
1788
}
1788
1789
1790
+ pub ( crate ) const COMPOSEFS_TRANSIENT_STATE_DIR : & str = "/run/composefs" ;
1791
+ pub ( crate ) const COMPOSEFS_STAGED_DEPLOYMENT_PATH : & str = "/run/composefs/staged-deployment" ;
1792
+ /// Relative to /sysroot
1793
+ pub ( crate ) const STATE_DIR_RELATIVE : & str = "state/deploy" ;
1794
+
1789
1795
/// Creates and populates /sysroot/state/deploy/image_id
1790
1796
#[ context( "Writing composefs state" ) ]
1791
1797
pub ( crate ) fn write_composefs_state (
1792
1798
root_path : & Utf8PathBuf ,
1793
1799
deployment_id : Sha256HashValue ,
1794
1800
imgref : & ImageReference ,
1801
+ staged : bool ,
1795
1802
) -> Result < ( ) > {
1796
- let state_path = root_path. join ( format ! ( "state/deploy /{}" , deployment_id. to_hex( ) ) ) ;
1803
+ let state_path = root_path. join ( format ! ( "{STATE_DIR_RELATIVE} /{}" , deployment_id. to_hex( ) ) ) ;
1797
1804
1798
1805
create_dir_all ( state_path. join ( "etc/upper" ) ) ?;
1799
1806
create_dir_all ( state_path. join ( "etc/work" ) ) ?;
@@ -1823,6 +1830,19 @@ pub(crate) fn write_composefs_state(
1823
1830
. write ( config. to_string ( ) . as_bytes ( ) )
1824
1831
. context ( "Falied to write to .origin file" ) ?;
1825
1832
1833
+ if staged {
1834
+ std:: fs:: create_dir_all ( COMPOSEFS_TRANSIENT_STATE_DIR )
1835
+ . with_context ( || format ! ( "Creating {COMPOSEFS_TRANSIENT_STATE_DIR}" ) ) ?;
1836
+
1837
+ let mut file = std:: fs:: OpenOptions :: new ( )
1838
+ . write ( true )
1839
+ . create ( true )
1840
+ . open ( COMPOSEFS_STAGED_DEPLOYMENT_PATH )
1841
+ . context ( "Opening staged-deployment file" ) ?;
1842
+
1843
+ file. write_all ( deployment_id. to_hex ( ) . as_bytes ( ) ) ?;
1844
+ }
1845
+
1826
1846
Ok ( ( ) )
1827
1847
}
1828
1848
0 commit comments