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