[postgis-tickets] r16530 - Do not try testing downgrades

Sandro Santilli strk at kbt.io
Fri Apr 6 03:28:01 PDT 2018


Author: strk
Date: 2018-04-06 03:28:00 -0700 (Fri, 06 Apr 2018)
New Revision: 16530

Modified:
   trunk/utils/check_all_upgrades.sh
Log:
Do not try testing downgrades

Closes #4064

Modified: trunk/utils/check_all_upgrades.sh
===================================================================
--- trunk/utils/check_all_upgrades.sh	2018-04-06 09:06:58 UTC (rev 16529)
+++ trunk/utils/check_all_upgrades.sh	2018-04-06 10:28:00 UTC (rev 16530)
@@ -6,6 +6,36 @@
 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 @@
 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}"



More information about the postgis-tickets mailing list