diff options
author | Mateusz Piotrowski <mateusz.piotrowski@klarasystems.com> | 2022-07-05 16:17:42 +0300 |
---|---|---|
committer | Kevin Lyda <lyda@titanhq.com> | 2022-07-12 13:27:06 +0300 |
commit | e485dff6ba00e2069ed6c1bfd598acb9196f4cb1 (patch) | |
tree | ee0e3c5ef7fd4f7751779f6aa335d4182fc9d783 /src/share | |
parent | c7954fc134c913a79544029db7f786fa18f513d5 (diff) |
Handle revisions in the pkg version
If the older version of pkg has a revision and the new one does not,
the comparison function is broken.
For example, pkg version 1.17.5_1 was determined to be newer than
version 1.18.3. This is due to how the version numbers are expanded
for comparison:
test 0001170501 -gt 00011803
Diffstat (limited to 'src/share')
-rwxr-xr-x | src/share/poudriere/common.sh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index c6527b80..976fb783 100755 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -3517,7 +3517,7 @@ _pkg_version_expanded() { local -; set -f [ $# -eq 1 ] || eargs pkg_ver_expanded version local ver="$1" - local epoch ver_sub IFS + local epoch revision ver_sub IFS case "${ver}" in *,*) @@ -3528,6 +3528,15 @@ _pkg_version_expanded() { epoch="0" ;; esac + case "${ver}" in + *_*) + revision="${ver##*_}" + ver="${ver%_*}" + ;; + *) + revision="0" + ;; + esac _gsub "${ver}" "[_.]" " " ver_sub set -- ${ver_sub} @@ -3536,6 +3545,7 @@ _pkg_version_expanded() { printf "%02d" "$1" shift done + printf "%04d" "${revision}" printf "\n" } |