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