@@ -28,9 +28,13 @@ pub(crate) struct UpgradeOpts {
28
28
29
29
#[ clap( long) ]
30
30
pub ( crate ) touch_if_changed : Option < Utf8PathBuf > ,
31
+
32
+ /// Check if an update is available without applying it
33
+ #[ clap( long) ]
34
+ pub ( crate ) check : bool ,
31
35
}
32
36
33
- /// Perform an upgrade operation
37
+ /// Perform an switch operation
34
38
#[ derive( Debug , Parser ) ]
35
39
pub ( crate ) struct SwitchOpts {
36
40
/// Don't display progress
@@ -57,7 +61,7 @@ pub(crate) struct SwitchOpts {
57
61
pub ( crate ) target : String ,
58
62
}
59
63
60
- /// Perform an upgrade operation
64
+ /// Perform a status operation
61
65
#[ derive( Debug , Parser ) ]
62
66
pub ( crate ) struct StatusOpts {
63
67
/// Output in JSON format.
@@ -281,14 +285,36 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
281
285
let commit = booted_deployment. csum ( ) ;
282
286
let state = ostree_container:: store:: query_image_commit ( repo, & commit) ?;
283
287
let digest = state. manifest_digest . as_str ( ) ;
284
- let fetched = pull ( repo, & imgref, opts. quiet ) . await ?;
285
288
286
- if fetched. merge_commit . as_str ( ) == commit. as_str ( ) {
287
- println ! ( "Already queued: {digest}" ) ;
288
- return Ok ( ( ) ) ;
289
- }
289
+ if opts. check {
290
+ // pull the image manifest without the layers
291
+ let config = Default :: default ( ) ;
292
+ let mut imp = ostree_container:: store:: ImageImporter :: new ( repo, & imgref, config) . await ?;
293
+ match imp. prepare ( ) . await ? {
294
+ PrepareResult :: AlreadyPresent ( c) => {
295
+ println ! (
296
+ "No changes available for {}. Latest digest: {}" ,
297
+ imgref, c. manifest_digest
298
+ ) ;
299
+ return Ok ( ( ) ) ;
300
+ }
301
+ PrepareResult :: Ready ( p) => {
302
+ println ! (
303
+ "New manifest available for {}. Digest {}" ,
304
+ imgref, p. manifest_digest
305
+ ) ;
306
+ }
307
+ }
308
+ } else {
309
+ let fetched = pull ( repo, & imgref, opts. quiet ) . await ?;
310
+
311
+ if fetched. merge_commit . as_str ( ) == commit. as_str ( ) {
312
+ println ! ( "Already queued: {digest}" ) ;
313
+ return Ok ( ( ) ) ;
314
+ }
290
315
291
- stage ( sysroot, & osname, & imgref, fetched, & origin) . await ?;
316
+ stage ( sysroot, & osname, & imgref, fetched, & origin) . await ?;
317
+ }
292
318
293
319
if let Some ( path) = opts. touch_if_changed {
294
320
std:: fs:: write ( & path, "" ) . with_context ( || format ! ( "Writing {path}" ) ) ?;
0 commit comments