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