@@ -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 ;
@@ -116,6 +117,9 @@ pub(crate) enum Opt {
116
117
/// Add a transient writable overlayfs on `/usr` that will be discarded on reboot.
117
118
#[ clap( alias = "usroverlay" ) ]
118
119
UsrOverlay ,
120
+ /// Manipulate configuration
121
+ #[ clap( subcommand) ]
122
+ Config ( crate :: config:: ConfigOpts ) ,
119
123
/// Install to the target block device
120
124
#[ cfg( feature = "install" ) ]
121
125
Install ( crate :: install:: InstallOpts ) ,
@@ -216,12 +220,13 @@ async fn pull(
216
220
217
221
/// Stage (queue deployment of) a fetched container image.
218
222
#[ context( "Staging" ) ]
219
- async fn stage (
223
+ pub ( crate ) async fn stage(
220
224
sysroot : & SysrootLock ,
221
225
stateroot : & str ,
222
226
image : Box < LayeredImageState > ,
223
227
spec : & HostSpec ,
224
228
) -> Result < ( ) > {
229
+ <<<<<<< HEAD
225
230
let cancellable = gio:: Cancellable :: NONE ;
226
231
let stateroot = Some ( stateroot ) ;
227
232
let merge_deployment = sysroot. merge_deployment ( stateroot ) ;
@@ -248,6 +253,12 @@ async fn stage(
248
253
if let Some ( imgref) = ostree_imgref. as_ref( ) {
249
254
println ! ( "Queued for next boot: {imgref}" ) ;
250
255
}
256
+ =======
257
+ let merge_deployment = sysroot. merge_deployment( Some ( stateroot) ) ;
258
+ crate :: deploy:: deploy( sysroot, merge_deployment. as_ref( ) , stateroot, image, origin) . await ?;
259
+ crate :: deploy:: cleanup( sysroot) . await ?;
260
+ println ! ( "Queued for next boot: {imgref}" ) ;
261
+ >>>>>>> 6 b0a900 ( Add support for configmaps)
251
262
Ok ( ( ) )
252
263
}
253
264
@@ -265,7 +276,7 @@ pub(crate) fn require_root() -> Result<()> {
265
276
266
277
/// A few process changes that need to be made for writing.
267
278
#[ context( "Preparing for write" ) ]
268
- async fn prepare_for_write ( ) -> Result < ( ) > {
279
+ pub ( crate ) async fn prepare_for_write( ) -> Result < ( ) > {
269
280
if ostree_ext:: container_utils:: is_ostree_container( ) ? {
270
281
anyhow:: bail!(
271
282
"Detected container (ostree base); this command requires a booted host system."
@@ -278,22 +289,43 @@ async fn prepare_for_write() -> Result<()> {
278
289
Ok ( ( ) )
279
290
}
280
291
292
+ pub ( crate ) fn target_deployment( sysroot: & SysrootLock ) -> Result < Deployment > {
293
+ let booted_deployment = sysroot. require_booted_deployment( ) ?;
294
+ Ok ( sysroot. staged_deployment( ) . unwrap_or( booted_deployment) )
295
+ }
296
+
281
297
/// Implementation of the `bootc upgrade` CLI command.
282
298
#[ context( "Upgrading" ) ]
283
299
async fn upgrade( opts: UpgradeOpts ) -> Result < ( ) > {
284
300
prepare_for_write( ) . await ?;
285
301
let sysroot = & get_locked_sysroot( ) . await ?;
302
+ <<<<<<< HEAD
286
303
let booted_deployment = & sysroot. require_booted_deployment( ) ?;
287
304
let ( _deployments, host) = crate :: status:: get_status ( sysroot , Some ( booted_deployment ) ) ?;
288
305
// SAFETY: There must be a status if we have a booted deployment
289
306
let status = host. status. unwrap( ) ;
290
307
let imgref = host. spec. image. as_ref( ) ;
291
308
// If there's no specified image, let's be nice and check if the booted system is using rpm-ostree
292
309
if imgref. is_none( ) && status. booted. map_or( false , |b| b. incompatible) {
310
+ =======
311
+ let repo = & sysroot. repo( ) ;
312
+ let merge_deployment = & target_deployment( sysroot) ?;
313
+ let status = crate :: status:: DeploymentStatus :: from_deployment( merge_deployment, true ) ?;
314
+ let osname = merge_deployment. osname( ) ;
315
+ let origin = merge_deployment
316
+ . origin( )
317
+ . ok_or_else( || anyhow:: anyhow!( "Deployment is missing an origin" ) ) ?;
318
+ let imgref = status
319
+ . image
320
+ . ok_or_else( || anyhow:: anyhow!( "Booted deployment is not container image based" ) ) ?;
321
+ let imgref : OstreeImageReference = imgref. into ( ) ;
322
+ if !status. supported {
323
+ >>>>>>> 6 b0a900 ( Add support for configmaps)
293
324
return Err ( anyhow:: anyhow!(
294
325
"Booted deployment contains local rpm-ostree modifications; cannot upgrade via bootc"
295
326
) ) ;
296
327
}
328
+ <<<<<<< HEAD
297
329
let imgref = imgref. ok_or_else( || anyhow:: anyhow!( "No image source specified" ) ) ?;
298
330
// Find the currently queued digest, if any before we pull
299
331
let queued_digest = status
@@ -332,6 +364,12 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
332
364
return Ok ( ( ) ) ;
333
365
}
334
366
}
367
+ =======
368
+ let commit = merge_deployment. csum( ) ;
369
+ let state = ostree_container:: store:: query_image_commit( repo, & commit) ?;
370
+ let digest = state. manifest_digest. as_str( ) ;
371
+ let fetched = pull( repo, & imgref, opts. quiet) . await ?;
372
+ >>>>>>> 6 b0a900 ( Add support for configmaps)
335
373
336
374
let osname = booted_deployment. osname( ) ;
337
375
stage( sysroot, & osname, fetched, & host. spec) . await ?;
@@ -348,8 +386,16 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
348
386
async fn switch( opts: SwitchOpts ) -> Result < ( ) > {
349
387
prepare_for_write( ) . await ?;
350
388
let cancellable = gio:: Cancellable :: NONE ;
389
+ <<<<<<< HEAD
351
390
352
391
let sysroot = & get_locked_sysroot( ) . await ?;
392
+ =======
393
+ let sysroot = & get_locked_sysroot( ) . await ?;
394
+ let merge_deployment = & target_deployment( sysroot) ?;
395
+ let ( origin, booted_image) = crate :: utils:: get_image_origin( merge_deployment) ?;
396
+ let booted_refspec = origin. optional_string( "origin" , "refspec" ) ?;
397
+ let osname = merge_deployment. osname( ) ;
398
+ >>>>>>> 6 b0a900 ( Add support for configmaps)
353
399
let repo = & sysroot. repo( ) ;
354
400
let booted_deployment = & sysroot. require_booted_deployment( ) ?;
355
401
let ( _deployments, host) = crate :: status:: get_status( sysroot, Some ( booted_deployment) ) ?;
@@ -427,6 +473,7 @@ where
427
473
Opt : : Upgrade ( opts) => upgrade( opts) . await ,
428
474
Opt : : Switch ( opts) => switch( opts) . await ,
429
475
Opt : : UsrOverlay => usroverlay( ) . await ,
476
+ Opt : : Config ( opts) => crate :: config:: run( opts) . await ,
430
477
#[ cfg( feature = "install") ]
431
478
Opt : : Install ( opts) => crate :: install:: install( opts) . await ,
432
479
#[ cfg( feature = "install") ]
0 commit comments