@@ -14,6 +14,7 @@ use ostree_ext::container as ostree_container;
14
14
use ostree_ext:: container:: SignatureSource ;
15
15
use ostree_ext:: keyfileext:: KeyFileExt ;
16
16
use ostree_ext:: ostree;
17
+ use ostree_ext:: ostree:: Deployment ;
17
18
use ostree_ext:: sysroot:: SysrootLock ;
18
19
use std:: ffi:: OsString ;
19
20
use std:: os:: unix:: process:: CommandExt ;
@@ -109,6 +110,9 @@ pub(crate) enum Opt {
109
110
/// Add a transient writable overlayfs on `/usr` that will be discarded on reboot.
110
111
#[ clap( alias = "usroverlay" ) ]
111
112
UsrOverlay ,
113
+ /// Manipulate configuration
114
+ #[ clap( subcommand) ]
115
+ Config ( crate :: config:: ConfigOpts ) ,
112
116
/// Install to the target block device
113
117
#[ cfg( feature = "install" ) ]
114
118
Install ( crate :: install:: InstallOpts ) ,
@@ -208,7 +212,7 @@ async fn pull(
208
212
209
213
/// Stage (queue deployment of) a fetched container image.
210
214
#[ context( "Staging" ) ]
211
- async fn stage (
215
+ pub ( crate ) async fn stage (
212
216
sysroot : & SysrootLock ,
213
217
stateroot : & str ,
214
218
imgref : & ostree_container:: OstreeImageReference ,
@@ -244,7 +248,7 @@ pub(crate) fn require_root() -> Result<()> {
244
248
245
249
/// A few process changes that need to be made for writing.
246
250
#[ context( "Preparing for write" ) ]
247
- async fn prepare_for_write ( ) -> Result < ( ) > {
251
+ pub ( crate ) async fn prepare_for_write ( ) -> Result < ( ) > {
248
252
if ostree_ext:: container_utils:: is_ostree_container ( ) ? {
249
253
anyhow:: bail!(
250
254
"Detected container (ostree base); this command requires a booted host system."
@@ -257,16 +261,21 @@ async fn prepare_for_write() -> Result<()> {
257
261
Ok ( ( ) )
258
262
}
259
263
264
+ pub ( crate ) fn target_deployment ( sysroot : & SysrootLock ) -> Result < Deployment > {
265
+ let booted_deployment = sysroot. require_booted_deployment ( ) ?;
266
+ Ok ( sysroot. staged_deployment ( ) . unwrap_or ( booted_deployment) )
267
+ }
268
+
260
269
/// Implementation of the `bootc upgrade` CLI command.
261
270
#[ context( "Upgrading" ) ]
262
271
async fn upgrade ( opts : UpgradeOpts ) -> Result < ( ) > {
263
272
prepare_for_write ( ) . await ?;
264
273
let sysroot = & get_locked_sysroot ( ) . await ?;
265
274
let repo = & sysroot. repo ( ) ;
266
- let booted_deployment = & sysroot . require_booted_deployment ( ) ?;
267
- let status = crate :: status:: DeploymentStatus :: from_deployment ( booted_deployment , true ) ?;
268
- let osname = booted_deployment . osname ( ) ;
269
- let origin = booted_deployment
275
+ let merge_deployment = & target_deployment ( sysroot ) ?;
276
+ let status = crate :: status:: DeploymentStatus :: from_deployment ( merge_deployment , true ) ?;
277
+ let osname = merge_deployment . osname ( ) ;
278
+ let origin = merge_deployment
270
279
. origin ( )
271
280
. ok_or_else ( || anyhow:: anyhow!( "Deployment is missing an origin" ) ) ?;
272
281
let imgref = status
@@ -278,7 +287,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
278
287
"Booted deployment contains local rpm-ostree modifications; cannot upgrade via bootc"
279
288
) ) ;
280
289
}
281
- let commit = booted_deployment . csum ( ) ;
290
+ let commit = merge_deployment . csum ( ) ;
282
291
let state = ostree_container:: store:: query_image_commit ( repo, & commit) ?;
283
292
let digest = state. manifest_digest . as_str ( ) ;
284
293
let fetched = pull ( repo, & imgref, opts. quiet ) . await ?;
@@ -303,11 +312,11 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
303
312
prepare_for_write ( ) . await ?;
304
313
305
314
let cancellable = gio:: Cancellable :: NONE ;
306
- let sysroot = get_locked_sysroot ( ) . await ?;
307
- let booted_deployment = & sysroot . require_booted_deployment ( ) ?;
308
- let ( origin, booted_image) = crate :: utils:: get_image_origin ( booted_deployment ) ?;
315
+ let sysroot = & get_locked_sysroot ( ) . await ?;
316
+ let merge_deployment = & target_deployment ( sysroot ) ?;
317
+ let ( origin, booted_image) = crate :: utils:: get_image_origin ( merge_deployment ) ?;
309
318
let booted_refspec = origin. optional_string ( "origin" , "refspec" ) ?;
310
- let osname = booted_deployment . osname ( ) ;
319
+ let osname = merge_deployment . osname ( ) ;
311
320
let repo = & sysroot. repo ( ) ;
312
321
313
322
let transport = ostree_container:: Transport :: try_from ( opts. transport . as_str ( ) ) ?;
@@ -373,6 +382,8 @@ where
373
382
Opt :: Upgrade ( opts) => upgrade ( opts) . await ,
374
383
Opt :: Switch ( opts) => switch ( opts) . await ,
375
384
Opt :: UsrOverlay => usroverlay ( ) . await ,
385
+ #[ cfg( feature = "k8s-base" ) ]
386
+ Opt :: Config ( opts) => crate :: config:: run ( opts) . await ,
376
387
#[ cfg( feature = "install" ) ]
377
388
Opt :: Install ( opts) => crate :: install:: install ( opts) . await ,
378
389
#[ cfg( feature = "install" ) ]
0 commit comments