[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-30-gaf7bb36

git at osgeo.org git at osgeo.org
Wed Mar 4 07:54:39 PST 2020


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  af7bb360b5d9cc02dbf04f6dd395e0706536b5a4 (commit)
      from  d1a929f3c9557156c2a4d4c1606487f4fe80b0cd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit af7bb360b5d9cc02dbf04f6dd395e0706536b5a4
Author: Sandro Santilli <strk at kbt.io>
Date:   Wed Mar 4 15:40:19 2020 +0100

    Use Perl for the "postgis" command

diff --git a/loader/Makefile.in b/loader/Makefile.in
index 96e05d7..9aebfe0 100644
--- a/loader/Makefile.in
+++ b/loader/Makefile.in
@@ -101,8 +101,8 @@ $(PGSQL2SHP-CLI): $(SHPLIB_OBJS) pgsql2shp-core.o pgsql2shp-cli.o $(LIBLWGEOM)
 	$(LIBTOOL) --mode=link \
 	  $(CC) $(CFLAGS) $^ $(LDFLAGS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) $(GETTEXT_LDFLAGS) -o $@
 
-$(POSTGIS-CLI): postgis.sh
-	cp postgis.sh postgis; chmod +x postgis
+$(POSTGIS-CLI): postgis.pl
+	cp postgis.pl postgis; chmod +x postgis
 
 $(SHP2PGSQL-CLI): $(SHPLIB_OBJS) shp2pgsql-core.o shp2pgsql-cli.o $(LIBLWGEOM)
 	$(LIBTOOL) --mode=link \
diff --git a/loader/postgis.pl b/loader/postgis.pl
new file mode 100644
index 0000000..925b7a3
--- /dev/null
+++ b/loader/postgis.pl
@@ -0,0 +1,123 @@
+#!/usr/bin/perl
+
+#
+# PostGIS - Spatial Types for PostgreSQL
+# http://postgis.net
+#
+# Copyright (C) 2020 Sandro Santilli <strk at kbt.io>
+#
+# This is free software; you can redistribute and/or modify it under
+# the terms of the GNU General Public Licence. See the COPYING file.
+#
+
+
+sub usage
+{
+	print qq{Usage: $0 <command> [<args>]
+Commands:
+  help               print this message and exits
+  enable <database>  enable postgis in given database
+  upgrade <database>  enable postgis in given database
+  status <database>  prints postgis status in given database
+};
+
+}
+
+
+sub enable
+{
+	print "Enable called with args: @_\n";
+  my $db = shift;
+  die "Please specify a database name" unless "$db";
+  die "Enable is not implemented yet";
+}
+
+sub upgrade
+{
+  die "Please specify at least a database name" unless @_;
+
+  foreach my $db (@_)
+  {
+    print "upgrading db $db\n";
+    my $LOG=`cat <<EOF | psql -XtA ${db}
+BEGIN;
+UPDATE pg_catalog.pg_extension SET extversion = 'ANY'
+ WHERE extname IN (
+			'postgis',
+			'postgis_raster',
+			'postgis_sfcgal',
+			'postgis_topology',
+			'postgis_tiger_geocoder'
+  );
+SELECT postgis_extensions_upgrade();
+COMMIT;
+EOF`;
+  }
+}
+
+sub status
+{
+  die "Please specify at least a database name" unless @_;
+
+  foreach my $db (@_)
+  {
+    my $sql = "
+SELECT n.nspname
+  FROM pg_namespace n, pg_proc p
+  WHERE n.oid = p.pronamespace
+    AND p.proname = 'postgis_full_version'
+";
+
+		my $SCHEMA=`psql -XtA ${db} -c "${sql}"`;
+		chop($SCHEMA);
+    if ( ! "$SCHEMA" )
+		{
+      print "db $db does not have postgis enabled\n";
+      next;
+    }
+
+    $sql="SELECT ${SCHEMA}.postgis_full_version()";
+    my $FULL_VERSION=`psql -XtA ${db} -c "${sql}"`;
+		#print "FULL_VERSION: ${FULL_VERSION}\n";
+
+    #POSTGIS="3.1.0dev r3.1.0alpha1-3-gfc5392de7"
+    my $VERSION="unknown";
+    if ( $FULL_VERSION =~ /POSTGIS="([^ ]*).*/ )
+		{
+			$VERSION=$1;
+		}
+
+    my $EXTENSION='';
+    if ( $FULL_VERSION =~ /\[EXTENSION\]/ )
+		{
+      $EXTENSION=" as extension";
+    }
+    my $NEED_UPGRADE='';
+    if ( $FULL_VERSION =~ /need upgrade/ )
+		{
+      $NEED_UPGRADE=" - NEEDS UPGRADE";
+    }
+
+    print "db $db has postgis ${VERSION}${EXTENSION} in schema ${SCHEMA}${NEED_UPGRADE}\n";
+  }
+}
+
+my $cmd = shift;
+if ( $cmd eq "help" ) {
+	usage(STDOUT);
+	exit 0;
+}
+elsif ( $cmd eq "enable" ) {
+	exit enable(@ARGV);
+}
+elsif ( $cmd eq "upgrade" ) {
+	exit upgrade(@ARGV);
+}
+elsif ( $cmd eq "status" ) {
+	exit status(@ARGV);
+}
+else {
+	print STDERR "Unrecognized command: $cmd\n";
+  usage(STDERR);
+  exit 1
+}
diff --git a/loader/postgis.sh b/loader/postgis.sh
deleted file mode 100644
index 9378715..0000000
--- a/loader/postgis.sh
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/bin/sh
-
-usage() {
-
-  echo "Usage: $0 <command> [<args>]"
-  echo "Commands:"
-  echo "  help               print this message and exits"
-  echo "  enable <database>  enable postgis in given database"
-  echo "  upgrade <database>  enable postgis in given database"
-  echo "  status <database>  prints postgis status in given database"
-
-}
-
-enable() {
-  db="$1"; shift
-  test -n "$db" || {
-    echo "Please specify a database name" >&2
-    return 1
-  }
-  echo "Enable is not implemented yet" >&2
-  return 1
-}
-
-upgrade() {
-  test -n "$1" || {
-    echo "Please specify at least a database name" >&2
-    return 1
-  }
-  for db in $@; do
-    echo "upgrading db $db"
-    LOG=`cat <<EOF | psql -XtA ${db}
-BEGIN;
-UPDATE pg_catalog.pg_extension SET extversion = 'ANY'
- WHERE extname IN (
-			'postgis',
-			'postgis_raster',
-			'postgis_sfcgal',
-			'postgis_topology',
-			'postgis_tiger_geocoder'
-  );
-SELECT postgis_extensions_upgrade();
-COMMIT;
-EOF`
-    #sh $0 status ${db}
-  done
-}
-
-status() {
-  test -n "$1" || {
-    echo "Please specify at least a database name" >&2
-    return 1
-  }
-  for db in $@; do
-    SCHEMA=`cat <<EOF | psql -XtA ${db}
-SELECT n.nspname
-  FROM pg_namespace n, pg_proc p
-  WHERE n.oid = p.pronamespace
-    AND p.proname = 'postgis_full_version'
-EOF
-`
-    if test -z "$SCHEMA"; then
-      echo "db $db does not have postgis enabled"
-      continue
-    fi
-    FULL_VERSION=`cat <<EOF | psql -XtA ${db}
-SELECT ${SCHEMA}.postgis_full_version()
-EOF
-`
-    #POSTGIS="3.1.0dev r3.1.0alpha1-3-gfc5392de7"
-    VERSION=`echo "$FULL_VERSION" | sed 's/POSTGIS="\([^ ]*\).*/\1/'`
-    EXTENSION=
-    if expr "$FULL_VERSION" : '.*\[EXTENSION\]' > /dev/null; then
-      EXTENSION=" as extension"
-    fi
-    NEED_UPGRADE=
-    if expr "$FULL_VERSION" : '.*need upgrade' > /dev/null; then
-      NEED_UPGRADE=" - NEEDS UPGRADE"
-    fi
-
-    echo "db $db has postgis ${VERSION}${EXTENSION} in schema ${SCHEMA}${NEED_UPGRADE}"
-  done
-}
-
-test -n "$1" || {
-  usage >&2
-  exit 1
-}
-
-while test -n "$1"; do
-  if test "$1" = "help"; then
-    usage 0
-  elif test "$1" = "enable"; then
-    shift
-    enable $@
-    exit $?
-  elif test "$1" = "upgrade"; then
-    shift
-    upgrade $@
-    exit $?
-  elif test "$1" = "status"; then
-    shift
-    status $@
-    exit $?
-  else
-    echo "Unrecognized command: $1" >&2
-    usage >&2
-    exit 1
-  fi
-  shift
-done

-----------------------------------------------------------------------

Summary of changes:
 loader/Makefile.in |   4 +-
 loader/postgis.pl  | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 loader/postgis.sh  | 110 -----------------------------------------------
 3 files changed, 125 insertions(+), 112 deletions(-)
 create mode 100644 loader/postgis.pl
 delete mode 100644 loader/postgis.sh


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list