[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-7-gabc6fd7

git at osgeo.org git at osgeo.org
Wed Feb 12 03:07:36 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  abc6fd77a8240fe673f5a012a97eb62a950f085e (commit)
      from  4c0a0b5665019832f502cd3dfa4286137f02db3e (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 abc6fd77a8240fe673f5a012a97eb62a950f085e
Author: Sandro Santilli <strk at kbt.io>
Date:   Wed Feb 12 12:05:53 2020 +0100

    Stub a "postgis" command

diff --git a/.gitignore b/.gitignore
index cd76069..c4388f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,6 +92,7 @@ loader/cunit/cu_tester
 loader/cunit/Makefile
 loader/Makefile
 loader/pgsql2shp
+loader/postgis
 loader/shp2pgsql
 loader/shp2pgsql-gui
 ltmain.sh
diff --git a/loader/Makefile.in b/loader/Makefile.in
index e6d1af0..96e05d7 100644
--- a/loader/Makefile.in
+++ b/loader/Makefile.in
@@ -29,6 +29,7 @@ INSTALL = @INSTALL@
 LIBTOOL = @LIBTOOL@
 
 # Filenames with extension as determined by the OS
+POSTGIS-CLI=postgis at EXESUFFIX@
 PGSQL2SHP-CLI=pgsql2shp at EXESUFFIX@
 SHP2PGSQL-CLI=shp2pgsql at EXESUFFIX@
 SHP2PGSQL-GUI=shp2pgsql-gui at EXESUFFIX@
@@ -75,7 +76,7 @@ gtk_build = @GTK_BUILD@
 SHPLIB_OBJS = shpopen.o dbfopen.o getopt.o shpcommon.o safileio.o
 
 # The real parts of the Makefile
-all: $(SHP2PGSQL-CLI) $(PGSQL2SHP-CLI) @GTK_BUILD@
+all: $(SHP2PGSQL-CLI) $(PGSQL2SHP-CLI) $(POSTGIS-CLI) @GTK_BUILD@
 
 gui: $(SHP2PGSQL-GUI) $(SHP2PGSQL-CLI) @GTK_WIN32_RES@
 
@@ -100,6 +101,9 @@ $(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
+
 $(SHP2PGSQL-CLI): $(SHPLIB_OBJS) shp2pgsql-core.o shp2pgsql-cli.o $(LIBLWGEOM)
 	$(LIBTOOL) --mode=link \
 	  $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(GETTEXT_LDFLAGS) $(ICONV_LDFLAGS)
@@ -152,6 +156,7 @@ uninstall: uninstall-desktop uninstall-icons
 	$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(bindir)/$(PGSQL2SHP-CLI)"
 	$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(bindir)/$(SHP2PGSQL-CLI)"
 	$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(bindir)/$(SHP2PGSQL-GUI)"
+	$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(bindir)/$(POSTGIS-CLI)"
 
 # TODO: move here what's currently run from regress/loader and
 # regress/dumper ?
diff --git a/loader/postgis.sh b/loader/postgis.sh
new file mode 100644
index 0000000..bb634c9
--- /dev/null
+++ b/loader/postgis.sh
@@ -0,0 +1,96 @@
+#!/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() {
+  db="$1"; shift
+  test -n "$db" || {
+    echo "Please specify a database name" >&2
+    return 1
+  }
+  echo "Upgrade is not implemented yet" >&2
+  return 1
+}
+
+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:
 .gitignore         |  1 +
 loader/Makefile.in |  7 +++-
 loader/postgis.sh  | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 loader/postgis.sh


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list