From: Sandro Santilli Date: Fri, 6 Apr 2018 10:28:00 +0000 (+0000) Subject: Do not try testing downgrades X-Git-Tag: 2.5.0alpha~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37c872e60cb6fbd467abcd2ebb62a245ae051eb6;p=postgis Do not try testing downgrades Closes #4064 git-svn-id: http://svn.osgeo.org/postgis/trunk@16530 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/utils/check_all_upgrades.sh b/utils/check_all_upgrades.sh index b69b477c1..38f07b633 100755 --- a/utils/check_all_upgrades.sh +++ b/utils/check_all_upgrades.sh @@ -6,6 +6,36 @@ if test -z "$1"; then fi to_version="$1" +# Return -1, 1 or 0 if the first version +# is respectively smaller, greater or equal +# to the second version +semver_compare() +{ + V1=`echo "$1" | tr '.' ' '` + V2=$2 + # echo "V1: $V1" >&2 + # echo "V2: $V2" >&2 + for v1 in $V1; do + v2=`echo "$V2" | cut -d. -f1` + if [ -z "$v2" ]; then + echo 1; return; + fi + V2=`echo "$V2" | cut -d. -sf2-` + # echo "v: $v1 - $v2" >&2 + if expr "$v1" '<' "$v2" > /dev/null; then + echo -1; return; + fi + if expr "$v1" '>' "$v2" > /dev/null; then + echo 1; return; + fi + done + if [ -n "$V2" ]; then + echo -1; return; + fi + echo 0; return; +} + + BUILDDIR=$PWD EXTDIR=`pg_config --sharedir`/extension/ @@ -14,8 +44,9 @@ failures=0 files=`'ls' postgis--* | grep -v -- '--.*--' | sed 's/^postgis--\(.*\)\.sql/\1/'` for fname in unpackaged $files; do from_version="$fname" - if test "${from_version}" = "${to_version}"; then - # TODO: upgrade to ${from_version}next instead ? + # only consider versions older than ${to_version} + cmp=`semver_compare "${from_version}" "${to_version}"` + if test $cmp -ge 0; then continue fi UPGRADE_PATH="${from_version}--${to_version}"