11//! Perform initial setup for a container image based system root
22
33use std:: collections:: HashSet ;
4+ #[ cfg( feature = "bootc" ) ]
45use std:: os:: fd:: BorrowedFd ;
5- use std:: process:: Command ;
66
77use anyhow:: Result ;
8- use bootc_utils:: CommandRunExt ;
9- use cap_std_ext:: cmdext:: CapStdExtCommandExt ;
108use fn_error_context:: context;
11- use ocidir:: cap_std:: fs:: Dir ;
129use ostree:: glib;
1310
1411use super :: store:: { gc_image_layers, LayeredImageState } ;
@@ -58,6 +55,7 @@ pub struct DeployOpts<'a> {
5855
5956// Access the file descriptor for a sysroot
6057#[ allow( unsafe_code) ]
58+ #[ cfg( feature = "bootc" ) ]
6159pub ( crate ) fn sysroot_fd ( sysroot : & ostree:: Sysroot ) -> BorrowedFd {
6260 unsafe { BorrowedFd :: borrow_raw ( sysroot. fd ( ) ) }
6361}
@@ -72,7 +70,6 @@ pub async fn deploy(
7270 imgref : & OstreeImageReference ,
7371 options : Option < DeployOpts < ' _ > > ,
7472) -> Result < Box < LayeredImageState > > {
75- let sysroot_dir = & Dir :: reopen_dir ( & sysroot_fd ( sysroot) ) ?;
7673 let cancellable = ostree:: gio:: Cancellable :: NONE ;
7774 let options = options. unwrap_or_default ( ) ;
7875 let repo = & sysroot. repo ( ) ;
@@ -147,9 +144,15 @@ pub async fn deploy(
147144 // doesn't try to invoke this, as that won't work right now.
148145 #[ cfg( feature = "bootc" ) ]
149146 if !options. skip_completion {
147+ use bootc_utils:: CommandRunExt ;
148+ use cap_std_ext:: cmdext:: CapStdExtCommandExt ;
149+ use ocidir:: cap_std:: fs:: Dir ;
150+
151+ let sysroot_dir = & Dir :: reopen_dir ( & sysroot_fd ( sysroot) ) ?;
152+
150153 // Note that the sysroot is provided as `.` but we use cwd_dir to
151154 // make the process current working directory the sysroot.
152- let st = Command :: new ( "/proc/self/exe" )
155+ let st = std :: process :: Command :: new ( "/proc/self/exe" )
153156 . args ( [ "internals" , "bootc-install-completion" , "." , stateroot] )
154157 . cwd_dir ( sysroot_dir. try_clone ( ) ?)
155158 . lifecycle_bind ( )
0 commit comments