diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..8ac8b04c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,18 @@ +# Required dependencies + +In order to build `bootc` you will need the following dependencies. + +Fedora: +``` +sudo dnf install ostree-libs ostree-devel +``` + +# Pre flight checks + +Makes sure you commented your code additions, then run +``` +cargo fmt +cargo clippy +``` +Make sure to apply any relevant suggestions. + diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 6413911c..b1a25243 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -28,9 +28,13 @@ pub(crate) struct UpgradeOpts { #[clap(long)] pub(crate) touch_if_changed: Option, + + /// Check if an update is available without applying it + #[clap(long)] + pub(crate) check: bool, } -/// Perform an upgrade operation +/// Perform an switch operation #[derive(Debug, Parser)] pub(crate) struct SwitchOpts { /// Don't display progress @@ -57,7 +61,7 @@ pub(crate) struct SwitchOpts { pub(crate) target: String, } -/// Perform an upgrade operation +/// Perform a status operation #[derive(Debug, Parser)] pub(crate) struct StatusOpts { /// Output in JSON format. @@ -281,14 +285,36 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { let commit = booted_deployment.csum(); let state = ostree_container::store::query_image_commit(repo, &commit)?; let digest = state.manifest_digest.as_str(); - let fetched = pull(repo, &imgref, opts.quiet).await?; - if fetched.merge_commit.as_str() == commit.as_str() { - println!("Already queued: {digest}"); - return Ok(()); - } + if opts.check { + // pull the image manifest without the layers + let config = Default::default(); + let mut imp = ostree_container::store::ImageImporter::new(repo, &imgref, config).await?; + match imp.prepare().await? { + PrepareResult::AlreadyPresent(c) => { + println!( + "No changes available for {}. Latest digest: {}", + imgref, c.manifest_digest + ); + return Ok(()); + } + PrepareResult::Ready(p) => { + println!( + "New manifest available for {}. Digest {}", + imgref, p.manifest_digest + ); + } + } + } else { + let fetched = pull(repo, &imgref, opts.quiet).await?; + + if fetched.merge_commit.as_str() == commit.as_str() { + println!("Already queued: {digest}"); + return Ok(()); + } - stage(sysroot, &osname, &imgref, fetched, &origin).await?; + stage(sysroot, &osname, &imgref, fetched, &origin).await?; + } if let Some(path) = opts.touch_if_changed { std::fs::write(&path, "").with_context(|| format!("Writing {path}"))?;