From c3c3d3eb9f4896fc64d1f668a4cb0014a7a4668a Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 1 Nov 2023 20:28:03 -0400 Subject: [PATCH] cli: Correctly no-op unchanged updates Regression from previous rework around staged diffs; we were incorectly re-staging the same thing. Signed-off-by: Colin Walters --- lib/src/cli.rs | 6 ++++++ tests/kolainst/basic | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index b23e1b292..e81d0294f 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -342,8 +342,14 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { let staged_unchanged = staged_digest .map(|d| d == fetched_digest) .unwrap_or_default(); + let booted_unchanged = booted_image + .as_ref() + .map(|img| img.manifest_digest.as_str() == fetched_digest) + .unwrap_or_default(); if staged_unchanged { println!("Staged update present, not changed."); + } else if booted_unchanged { + println!("No update available.") } else { let osname = booted_deployment.osname(); crate::deploy::stage(sysroot, &osname, &fetched, &spec).await?; diff --git a/tests/kolainst/basic b/tests/kolainst/basic index fdf6a9ce7..888eed2ac 100755 --- a/tests/kolainst/basic +++ b/tests/kolainst/basic @@ -19,6 +19,11 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in echo "booted into $image" echo "ok status test" + assert_streq "null" $(jq '.status.staged' < status.json) + # Should be a no-op + bootc update + assert_streq "null" $(jq '.status.staged' < status.json) + test '!' -w /usr bootc usroverlay test -w /usr