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
1diff --git a/package-tools/check-source-package b/package-tools/check-source-package
2index 18fe688..a420b19 100755
3--- a/package-tools/check-source-package
4+++ b/package-tools/check-source-package
5@@ -655,6 +655,31 @@ check_origtargz() {
6 fi
7 }
8
9+pick_latest_version_helper() {
10+ declare -A results
11+ # read versions and releases from the original $rmadout
12+ while read -r incoming_ver release; do
13+ # reduce to base release names (e.g. lunar-security/universe to lunar)
14+ local base_rel=${release%%[-/]*}
15+ # if the base_rel is never seen before, add it to the array
16+ if [ -z "${results[$base_rel]}" ]; then
17+ results["$base_rel"]="$incoming_ver $release"
18+ else # if seen before, compare the versions
19+ local cur_ver=$(echo "${results[$base_rel]}" | awk '{print $1}')
20+ # if the versions are the same, append it to the output line
21+ # if the incoming version is greater, replace the output line
22+ if dpkg --compare-versions "$cur_ver" eq "$incoming_ver"; then
23+ results["$base_rel"]="$incoming_ver $release"";""${results[$base_rel]}"
24+ elif dpkg --compare-versions "$cur_ver" lt "$incoming_ver"; then
25+ results["$base_rel"]="$incoming_ver $release"
26+ fi
27+ fi
28+ done < <(echo "$1" | awk '{print $3 " " $5}')
29+
30+ # print to stdout and expand the line with multiple entries
31+ printf "%s\n" "${results[@]}" | tr ';' '\n'
32+}
33+
34 check_version() {
35 format_test_name "Version"
36 dist=$(awk '/^Distribution: / {print $2}' "$schanges")
37@@ -748,7 +773,7 @@ check_version() {
38 else
39 echo "SKIP: Unable to get date_created for old release $olddist"
40 fi
41- done < <(echo "$rmadout" | awk '{print $3 " " $5}')
42+ done < <(pick_latest_version_helper "$rmadout")
43 if [ -n "$superceded" ]; then
44 failed "FAIL"
45 echo " Current: $version in $dist"

Subscribers

People subscribed via source and target branches