Merge ~allenpthuang/ubuntu-security-tools:umt-check-latest-versions into ubuntu-security-tools:master

Proposed by Allen Huang
Status: Merged
Merged at revision: 9f870d975b6086db4747aa004b86080ab7196623
Proposed branch: ~allenpthuang/ubuntu-security-tools:umt-check-latest-versions
Merge into: ubuntu-security-tools:master
Diff against target: 45 lines (+26/-1)
1 file modified
package-tools/check-source-package (+26/-1)
Reviewer Review Type Date Requested Status
David Fernandez Gonzalez Approve
Review via email: mp+452538@code.launchpad.net

Description of the change

This change makes `umt check` show more accurate results in the section of "Upgradeable version" of its report.

The result in the Upgradeable version section is generated by `package-tools/check-source-package`. It did not always compare against the most updated versions from `-updates` and `-security`.
In this change, a helper function `pick_latest_version_helper()` is added to pick the latest version for comparisons in `check_version()`. The function keeps the newest version it has seen in pockets of every release (e.g. `jammy`, `jammy-security` and `jammy-updates`) and passes it to `compare_version()`. It keeps all versions from every pocket of a release if the versions are equally new.

To post a comment you must log in.
Revision history for this message
David Fernandez Gonzalez (litios) wrote :

LGTM! Working as expected, thanks for doing this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/package-tools/check-source-package b/package-tools/check-source-package
index 18fe688..a420b19 100755
--- a/package-tools/check-source-package
+++ b/package-tools/check-source-package
@@ -655,6 +655,31 @@ check_origtargz() {
655 fi655 fi
656}656}
657657
658pick_latest_version_helper() {
659 declare -A results
660 # read versions and releases from the original $rmadout
661 while read -r incoming_ver release; do
662 # reduce to base release names (e.g. lunar-security/universe to lunar)
663 local base_rel=${release%%[-/]*}
664 # if the base_rel is never seen before, add it to the array
665 if [ -z "${results[$base_rel]}" ]; then
666 results["$base_rel"]="$incoming_ver $release"
667 else # if seen before, compare the versions
668 local cur_ver=$(echo "${results[$base_rel]}" | awk '{print $1}')
669 # if the versions are the same, append it to the output line
670 # if the incoming version is greater, replace the output line
671 if dpkg --compare-versions "$cur_ver" eq "$incoming_ver"; then
672 results["$base_rel"]="$incoming_ver $release"";""${results[$base_rel]}"
673 elif dpkg --compare-versions "$cur_ver" lt "$incoming_ver"; then
674 results["$base_rel"]="$incoming_ver $release"
675 fi
676 fi
677 done < <(echo "$1" | awk '{print $3 " " $5}')
678
679 # print to stdout and expand the line with multiple entries
680 printf "%s\n" "${results[@]}" | tr ';' '\n'
681}
682
658check_version() {683check_version() {
659 format_test_name "Version"684 format_test_name "Version"
660 dist=$(awk '/^Distribution: / {print $2}' "$schanges")685 dist=$(awk '/^Distribution: / {print $2}' "$schanges")
@@ -748,7 +773,7 @@ check_version() {
748 else773 else
749 echo "SKIP: Unable to get date_created for old release $olddist"774 echo "SKIP: Unable to get date_created for old release $olddist"
750 fi775 fi
751 done < <(echo "$rmadout" | awk '{print $3 " " $5}')776 done < <(pick_latest_version_helper "$rmadout")
752 if [ -n "$superceded" ]; then777 if [ -n "$superceded" ]; then
753 failed "FAIL"778 failed "FAIL"
754 echo " Current: $version in $dist"779 echo " Current: $version in $dist"

Subscribers

People subscribed via source and target branches