]> granicus.if.org Git - postgis/commitdiff
Do not try testing downgrades
authorSandro Santilli <strk@kbt.io>
Fri, 6 Apr 2018 10:28:00 +0000 (10:28 +0000)
committerSandro Santilli <strk@kbt.io>
Fri, 6 Apr 2018 10:28:00 +0000 (10:28 +0000)
Closes #4064

git-svn-id: http://svn.osgeo.org/postgis/trunk@16530 b70326c6-7e19-0410-871a-916f4a2858ee

utils/check_all_upgrades.sh

index b69b477c11d18b5d1a9209b2ea88d604554cff7a..38f07b633cb80551037e713eba5574cabe102a49 100755 (executable)
@@ -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}"