@@ -542,15 +542,9 @@ pub(crate) fn print_configuration() -> Result<()> {
542
542
}
543
543
544
544
#[ context( "Creating ostree deployment" ) ]
545
- async fn initialize_ostree_root_from_self (
546
- state : & State ,
547
- root_setup : & RootSetup ,
548
- ) -> Result < InstallAleph > {
545
+ async fn initialize_ostree_root ( state : & State , root_setup : & RootSetup ) -> Result < ostree:: Sysroot > {
549
546
let sepolicy = state. load_policy ( ) ?;
550
547
let sepolicy = sepolicy. as_ref ( ) ;
551
-
552
- let container_rootfs = & Dir :: open_ambient_dir ( "/" , cap_std:: ambient_authority ( ) ) ?;
553
-
554
548
// Load a fd for the mounted target physical root
555
549
let rootfs_dir = & root_setup. rootfs_fd ;
556
550
let rootfs = root_setup. rootfs . as_path ( ) ;
@@ -607,6 +601,20 @@ async fn initialize_ostree_root_from_self(
607
601
608
602
let sysroot = ostree:: Sysroot :: new ( Some ( & gio:: File :: for_path ( rootfs) ) ) ;
609
603
sysroot. load ( cancellable) ?;
604
+ Ok ( sysroot)
605
+ }
606
+
607
+ #[ context( "Creating ostree deployment" ) ]
608
+ async fn install_container (
609
+ state : & State ,
610
+ root_setup : & RootSetup ,
611
+ sysroot : & ostree:: Sysroot ,
612
+ ) -> Result < InstallAleph > {
613
+ let sepolicy = state. load_policy ( ) ?;
614
+ let sepolicy = sepolicy. as_ref ( ) ;
615
+ let stateroot = STATEROOT_DEFAULT ;
616
+
617
+ let container_rootfs = & Dir :: open_ambient_dir ( "/" , cap_std:: ambient_authority ( ) ) ?;
610
618
611
619
let ( src_imageref, proxy_cfg) = if !state. source . in_host_mountns {
612
620
( state. source . imageref . clone ( ) , None )
@@ -692,15 +700,15 @@ async fn initialize_ostree_root_from_self(
692
700
)
693
701
. await ?;
694
702
695
- sysroot. load ( cancellable) ?;
696
703
let deployment = sysroot
697
704
. deployments ( )
698
705
. into_iter ( )
699
706
. next ( )
700
707
. ok_or_else ( || anyhow:: anyhow!( "Failed to find deployment" ) ) ?;
701
708
// SAFETY: There must be a path
702
709
let path = sysroot. deployment_dirpath ( & deployment) ;
703
- let root = rootfs_dir
710
+ let root = root_setup
711
+ . rootfs_fd
704
712
. open_dir ( path. as_str ( ) )
705
713
. context ( "Opening deployment dir" ) ?;
706
714
@@ -713,7 +721,7 @@ async fn initialize_ostree_root_from_self(
713
721
for d in [ "ostree" , "boot" ] {
714
722
let mut pathbuf = Utf8PathBuf :: from ( d) ;
715
723
crate :: lsm:: ensure_dir_labeled_recurse (
716
- rootfs_dir ,
724
+ & root_setup . rootfs_fd ,
717
725
& mut pathbuf,
718
726
policy,
719
727
Some ( deployment_root_devino) ,
@@ -1228,8 +1236,9 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
1228
1236
tracing:: debug!( "boot uuid={boot_uuid}" ) ;
1229
1237
1230
1238
// Write the aleph data that captures the system state at the time of provisioning for aid in future debugging.
1239
+ let sysroot = initialize_ostree_root ( state, rootfs) . await ?;
1231
1240
{
1232
- let aleph = initialize_ostree_root_from_self ( state, rootfs) . await ?;
1241
+ let aleph = install_container ( state, rootfs, & sysroot ) . await ?;
1233
1242
rootfs
1234
1243
. rootfs_fd
1235
1244
. atomic_replace_with ( BOOTC_ALEPH_PATH , |f| {
0 commit comments