@@ -15,6 +15,7 @@ use ostree_ext::container as ostree_container;
1515use  ostree_ext:: container:: SignatureSource ; 
1616use  ostree_ext:: keyfileext:: KeyFileExt ; 
1717use  ostree_ext:: ostree; 
18+ use  ostree_ext:: ostree:: Deployment ; 
1819use  ostree_ext:: sysroot:: SysrootLock ; 
1920use  std:: ffi:: OsString ; 
2021use  std:: os:: unix:: process:: CommandExt ; 
@@ -110,6 +111,9 @@ pub(crate) enum Opt {
110111    /// Add a transient writable overlayfs on `/usr` that will be discarded on reboot. 
111112#[ clap( alias = "usroverlay" ) ]  
112113    UsrOverlay , 
114+     /// Manipulate configuration 
115+ #[ clap( subcommand) ]  
116+     Config ( crate :: config:: ConfigOpts ) , 
113117    /// Install to the target block device 
114118#[ cfg( feature = "install" ) ]  
115119    Install ( crate :: install:: InstallOpts ) , 
@@ -209,7 +213,7 @@ async fn pull(
209213
210214/// Stage (queue deployment of) a fetched container image. 
211215#[ context( "Staging" ) ]  
212- async  fn  stage ( 
216+ pub ( crate )   async  fn  stage ( 
213217    sysroot :  & SysrootLock , 
214218    stateroot :  & str , 
215219    imgref :  & ostree_container:: OstreeImageReference , 
@@ -245,7 +249,7 @@ pub(crate) fn require_root() -> Result<()> {
245249
246250/// A few process changes that need to be made for writing. 
247251#[ context( "Preparing for write" ) ]  
248- async  fn  prepare_for_write ( )  -> Result < ( ) >  { 
252+ pub ( crate )   async  fn  prepare_for_write ( )  -> Result < ( ) >  { 
249253    if  ostree_ext:: container_utils:: is_ostree_container ( ) ? { 
250254        anyhow:: bail!( 
251255            "Detected container (ostree base); this command requires a booted host system." 
@@ -258,16 +262,21 @@ async fn prepare_for_write() -> Result<()> {
258262    Ok ( ( ) ) 
259263} 
260264
265+ pub ( crate )  fn  target_deployment ( sysroot :  & SysrootLock )  -> Result < Deployment >  { 
266+     let  booted_deployment = sysroot. require_booted_deployment ( ) ?; 
267+     Ok ( sysroot. staged_deployment ( ) . unwrap_or ( booted_deployment) ) 
268+ } 
269+ 
261270/// Implementation of the `bootc upgrade` CLI command. 
262271#[ context( "Upgrading" ) ]  
263272async  fn  upgrade ( opts :  UpgradeOpts )  -> Result < ( ) >  { 
264273    prepare_for_write ( ) . await ?; 
265274    let  sysroot = & get_locked_sysroot ( ) . await ?; 
266275    let  repo = & sysroot. repo ( ) . unwrap ( ) ; 
267-     let  booted_deployment  = & sysroot . require_booted_deployment ( ) ?; 
268-     let  status = crate :: status:: DeploymentStatus :: from_deployment ( booted_deployment ,  true ) ?; 
269-     let  osname = booted_deployment . osname ( ) . unwrap ( ) ; 
270-     let  origin = booted_deployment 
276+     let  merge_deployment  = & target_deployment ( sysroot ) ?; 
277+     let  status = crate :: status:: DeploymentStatus :: from_deployment ( merge_deployment ,  true ) ?; 
278+     let  osname = merge_deployment . osname ( ) . unwrap ( ) ; 
279+     let  origin = merge_deployment 
271280        . origin ( ) 
272281        . ok_or_else ( || anyhow:: anyhow!( "Deployment is missing an origin" ) ) ?; 
273282    let  imgref = status
@@ -279,7 +288,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
279288            "Booted deployment contains local rpm-ostree modifications; cannot upgrade via bootc" 
280289        ) ) ; 
281290    } 
282-     let  commit = booted_deployment . csum ( ) . unwrap ( ) ; 
291+     let  commit = merge_deployment . csum ( ) . unwrap ( ) ; 
283292    let  state = ostree_container:: store:: query_image_commit ( repo,  & commit) ?; 
284293    let  digest = state. manifest_digest . as_str ( ) ; 
285294    let  fetched = pull ( repo,  & imgref,  opts. quiet ) . await ?; 
@@ -304,11 +313,11 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
304313    prepare_for_write ( ) . await ?; 
305314
306315    let  cancellable = gio:: Cancellable :: NONE ; 
307-     let  sysroot = get_locked_sysroot ( ) . await ?; 
308-     let  booted_deployment  = & sysroot . require_booted_deployment ( ) ?; 
309-     let  ( origin,  booted_image)  = crate :: utils:: get_image_origin ( booted_deployment ) ?; 
316+     let  sysroot = & get_locked_sysroot ( ) . await ?; 
317+     let  merge_deployment  = & target_deployment ( sysroot ) ?; 
318+     let  ( origin,  booted_image)  = crate :: utils:: get_image_origin ( merge_deployment ) ?; 
310319    let  booted_refspec = origin. optional_string ( "origin" ,  "refspec" ) ?; 
311-     let  osname = booted_deployment . osname ( ) . unwrap ( ) ; 
320+     let  osname = merge_deployment . osname ( ) . unwrap ( ) ; 
312321    let  repo = & sysroot. repo ( ) . unwrap ( ) ; 
313322
314323    let  transport = ostree_container:: Transport :: try_from ( opts. transport . as_str ( ) ) ?; 
@@ -374,6 +383,8 @@ where
374383        Opt :: Upgrade ( opts)  => upgrade ( opts) . await , 
375384        Opt :: Switch ( opts)  => switch ( opts) . await , 
376385        Opt :: UsrOverlay  => usroverlay ( ) . await , 
386+         #[ cfg( feature = "k8s-base" ) ]  
387+         Opt :: Config ( opts)  => crate :: config:: run ( opts) . await , 
377388        #[ cfg( feature = "install" ) ]  
378389        Opt :: Install ( opts)  => crate :: install:: install ( opts) . await , 
379390        #[ cfg( feature = "install" ) ]  
0 commit comments