diff options
author | Erich Eckner <git@eckner.net> | 2017-09-15 09:08:33 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-09-15 09:08:33 +0200 |
commit | 00d37e50f3701448f163da7b3211694a6e5d20b0 (patch) | |
tree | 083153e05abd844a91a0de7a3a5e9931f358beb4 /bin | |
parent | 5163c6e3912f6982b02b9c6b59954640eda9a93c (diff) | |
download | builder-00d37e50f3701448f163da7b3211694a6e5d20b0.tar.xz |
bin/seed-build-list: expand_version and shrink_version new to correct misbehaving "sort -V" (vs. "vercmp")
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/common-functions | 26 | ||||
-rwxr-xr-x | bin/seed-build-list | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/bin/common-functions b/bin/common-functions index f255bb6..350e0b6 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -487,7 +487,9 @@ remove_old_package_versions() { echo "${package%-*}" | \ sed 's|^.*-\([^-]\+-[^-]\+\)$|1 %cut% %it% %here% \1|' } | \ + expand_version 5 | \ sort -k5V,5 -k1n,1 | \ + shrink_version 5 | \ sed -n ' /^1 %cut% %it% %here% /q s/^[02] // @@ -893,3 +895,27 @@ download_sources_by_hash() { return ${return_value} } + +# expand_version $column_num +# add "+0" to version in $colum_num-th column if no "+" is there + +expand_version() { + local column_num + column_num="$1" + + sed ' + /^\(\S\+\s\+\)\{'"$((column_num-1))"'\}\S*+/! s/^\(\(\S\+\s\+\)\{'"$((column_num-1))"'\}\S*\)-/\1+0-/ + ' +} + +# shrink_version $column_num +# remove "+0" from version in $colum_num-th column + +shrink_version() { + local column_num + column_num="$1" + + sed ' + s/^\(\(\S\+\s\+\)\{'"$((column_num-1))"'\}\S*\)+0-/\1-/ + ' +} diff --git a/bin/seed-build-list b/bin/seed-build-list index 4067ed0..d58c1f9 100755 --- a/bin/seed-build-list +++ b/bin/seed-build-list @@ -173,7 +173,9 @@ while read -r mirror; do s|^\(.*\)-\([^-]\+-[^-]\+\)|ours \1-\2 \2 \1| ' ) | \ + expand_version 3 | \ sort -k4,4 -k3Vr,3 -k1,1 | \ + shrink_version 3 | \ uniq -f3 | \ grep '^theirs ' | \ awk '{print $4}' | \ |