From c8272d85f271afe52e837bc2bd0baf42ea9775c1 Mon Sep 17 00:00:00 2001 From: John Akre Date: Tue, 2 Oct 2018 13:27:12 -0700 Subject: [PATCH] testlib: Add minversion support to bump_format The bump_format testlib function created new minversions for the +10 and +20 versions, but it should only create a new minversion for the +20 version. This change copies the +20 update content into the +10 update and preserves the versions of unchanged files in the +10 version. Also, this change updates the minversion header field for the +20 version to reflect a minversion update. Signed-off-by: John Akre --- test/functional/testlib.bash | 63 ++++++++++--------- .../update-re-update-bad-os-release.bats | 2 +- .../update/update-re-update-required.bats | 2 +- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/test/functional/testlib.bash b/test/functional/testlib.bash index ede859ab..1cc338b3 100644 --- a/test/functional/testlib.bash +++ b/test/functional/testlib.bash @@ -1026,17 +1026,49 @@ bump_format() { # swupd_function new_version="$((version+20))" new_version_path="$env_name"/web-dir/"$new_version" format="$(< "$env_name"/web-dir/"$version"/format)" - mom="$new_version_path"/Manifest.MoM # create two new versions for the format bump, each version separated by 10 # from each other and from the current latest version create_version "$env_name" "$middle_version" "$version" "$format" create_version -r "$env_name" "$new_version" "$middle_version" "$((format+1))" + + # Update the +10 version + mom="$middle_version_path"/Manifest.MoM + + # +10 and +20 versions should have matching content + sudo rm -rf "$middle_version_path" + sudo cp -r "$new_version_path" "$middle_version_path" + + # Update +10 format and versions + update_manifest -p "$mom" format "$format" + update_manifest -p "$mom" version "$middle_version" + update_manifest -p "$mom" previous "$version" + + # The +20 version updates the os-release and format files. Change + # the versions of these files in the +10 to the +10's version. + update_manifest -p "$mom" file-version os-core "$middle_version" + update_manifest -p "$middle_version_path"/Manifest.os-core file-version /usr/lib/os-release "$middle_version" + update_manifest -p "$middle_version_path"/Manifest.os-core file-version /usr/share/defaults/swupd/format "$middle_version" + + mapfile -t bundles < <(awk '/^M\.\.\./ { print $4 }' "$mom") + IFS=$'\n' + for bundle in ${bundles[*]}; do + manifest="$middle_version_path"/Manifest."$bundle" + update_manifest -p "$manifest" format "$format" + update_manifest -p "$manifest" version "$middle_version" + update_manifest "$manifest" previous "$version" + done + unset IFS + update_hashes_in_mom "$mom" + + # update the new version + mom="$new_version_path"/Manifest.MoM + update_manifest -p "$mom" previous "$middle_version" + # regardless of where we found the previous version of os-core, update # the previous version to $middle_version update_manifest -p "$new_version_path"/Manifest.os-core previous "$middle_version" - # update the new version # copy all manifests in MoM to new version mapfile -t bundles < <(awk '/^M\.\.\./ { print $4 }' "$mom") IFS=$'\n' @@ -1074,32 +1106,7 @@ bump_format() { # swupd_function create_tar "$manifest" done unset IFS - update_hashes_in_mom "$mom" - - # update the middle version - sudo rm -rf "$middle_version_path"/files/* - sudo rm -f "$middle_version_path"/Manifest* - sudo rm -f "$middle_version_path"/pack* - sudo cp -r "$new_version_path"/files/* "$middle_version_path"/files/ - sudo cp "$new_version_path"/Manifest.* "$middle_version_path"/ - sudo cp "$new_version_path"/pack* "$middle_version_path"/ - mom="$middle_version_path"/Manifest.MoM - update_manifest -p "$mom" format "$((format))" - update_manifest -p "$mom" version "$middle_version" - update_manifest -p "$mom" previous "$version" - sudo sed -i "/....\\t.*\\t.*\\t.*$/s/\\(....\\t.*\\t\\).*\\(\\t\\)/\\1$middle_version\\2/g" "$mom" - mapfile -t bundles < <(awk '/^M\.\.\./ { print $4 }' "$mom") - IFS=$'\n' - for bundle in ${bundles[*]}; do - manifest="$middle_version_path"/Manifest."$bundle" - update_manifest -p "$manifest" format "$((format))" - update_manifest -p "$manifest" version "$middle_version" - update_manifest -p "$manifest" previous "$version" - sudo sed -i "/....\\t.*\\t.*\\t.*$/s/\\(....\\t.*\\t\\).*\\(\\t\\)/\\1$middle_version\\2/g" "$manifest" - sudo rm -rf "$manifest".tar - create_tar "$manifest" - done - unset IFS + update_manifest "$mom" minversion "$new_version" update_hashes_in_mom "$mom" } diff --git a/test/functional/update/update-re-update-bad-os-release.bats b/test/functional/update/update-re-update-bad-os-release.bats index fc6022d6..2551102e 100755 --- a/test/functional/update/update-re-update-bad-os-release.bats +++ b/test/functional/update/update-re-update-bad-os-release.bats @@ -29,7 +29,7 @@ test_setup() { changed bundles : 1 new bundles : 0 deleted bundles : 0 - changed files : 10 + changed files : 1 new files : 0 deleted files : 0 Starting download of remaining update content. This may take a while... diff --git a/test/functional/update/update-re-update-required.bats b/test/functional/update/update-re-update-required.bats index a0357b7f..d8cfc4fd 100755 --- a/test/functional/update/update-re-update-required.bats +++ b/test/functional/update/update-re-update-required.bats @@ -24,7 +24,7 @@ test_setup() { changed bundles : 1 new bundles : 0 deleted bundles : 0 - changed files : 11 + changed files : 2 new files : 0 deleted files : 0 Starting download of remaining update content. This may take a while...