@@ -131,6 +131,9 @@ pub(crate) enum Opt {
131
131
/// Add a transient writable overlayfs on `/usr` that will be discarded on reboot.
132
132
#[ clap( alias = "usroverlay" ) ]
133
133
UsrOverlay ,
134
+ /// Manipulate configuration
135
+ #[ clap( subcommand) ]
136
+ Config ( crate :: config:: ConfigOpts ) ,
134
137
/// Install to the target block device
135
138
#[ cfg( feature = "install" ) ]
136
139
Install ( crate :: install:: InstallOpts ) ,
@@ -231,15 +234,13 @@ async fn pull(
231
234
232
235
/// Stage (queue deployment of) a fetched container image.
233
236
#[ context( "Staging" ) ]
234
- async fn stage (
237
+ pub ( crate ) async fn stage (
235
238
sysroot : & SysrootLock ,
236
239
stateroot : & str ,
237
240
image : Box < LayeredImageState > ,
238
241
spec : & HostSpec ,
239
242
) -> Result < ( ) > {
240
- let cancellable = gio:: Cancellable :: NONE ;
241
- let stateroot = Some ( stateroot) ;
242
- let merge_deployment = sysroot. merge_deployment ( stateroot) ;
243
+ let merge_deployment = sysroot. merge_deployment ( Some ( stateroot) ) ;
243
244
let origin = glib:: KeyFile :: new ( ) ;
244
245
let ostree_imgref = spec
245
246
. image
@@ -252,14 +253,15 @@ async fn stage(
252
253
imgref. to_string ( ) . as_str ( ) ,
253
254
) ;
254
255
}
255
- let _new_deployment = sysroot. stage_tree_with_options (
256
- stateroot,
257
- image. merge_commit . as_str ( ) ,
258
- Some ( & origin) ,
256
+ crate :: deploy:: deploy (
257
+ sysroot,
259
258
merge_deployment. as_ref ( ) ,
260
- & Default :: default ( ) ,
261
- cancellable,
262
- ) ?;
259
+ stateroot,
260
+ image,
261
+ & origin,
262
+ )
263
+ . await ?;
264
+ crate :: deploy:: cleanup ( sysroot) . await ?;
263
265
if let Some ( imgref) = ostree_imgref. as_ref ( ) {
264
266
println ! ( "Queued for next boot: {imgref}" ) ;
265
267
}
@@ -282,7 +284,7 @@ pub(crate) fn require_root() -> Result<()> {
282
284
283
285
/// A few process changes that need to be made for writing.
284
286
#[ context( "Preparing for write" ) ]
285
- async fn prepare_for_write ( ) -> Result < ( ) > {
287
+ pub ( crate ) async fn prepare_for_write ( ) -> Result < ( ) > {
286
288
if ostree_ext:: container_utils:: is_ostree_container ( ) ? {
287
289
anyhow:: bail!(
288
290
"Detected container (ostree base); this command requires a booted host system."
@@ -295,6 +297,11 @@ async fn prepare_for_write() -> Result<()> {
295
297
Ok ( ( ) )
296
298
}
297
299
300
+ pub ( crate ) fn target_deployment ( sysroot : & SysrootLock ) -> Result < ostree:: Deployment > {
301
+ let booted_deployment = sysroot. require_booted_deployment ( ) ?;
302
+ Ok ( sysroot. staged_deployment ( ) . unwrap_or ( booted_deployment) )
303
+ }
304
+
298
305
/// Implementation of the `bootc upgrade` CLI command.
299
306
#[ context( "Upgrading" ) ]
300
307
async fn upgrade ( opts : UpgradeOpts ) -> Result < ( ) > {
@@ -476,6 +483,7 @@ where
476
483
Opt :: Switch ( opts) => switch ( opts) . await ,
477
484
Opt :: Edit ( opts) => edit ( opts) . await ,
478
485
Opt :: UsrOverlay => usroverlay ( ) . await ,
486
+ Opt :: Config ( opts) => crate :: config:: run ( opts) . await ,
479
487
#[ cfg( feature = "install" ) ]
480
488
Opt :: Install ( opts) => crate :: install:: install ( opts) . await ,
481
489
#[ cfg( feature = "install" ) ]
0 commit comments