From: Sandro Santilli Date: Tue, 17 Jan 2012 17:13:32 +0000 (+0000) Subject: Enhance staged install to include raster, topology and all scripts X-Git-Tag: 2.0.0alpha1~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=419470fc8686f3bf11d2856dd7a1ae489ec5ae78;p=postgis Enhance staged install to include raster, topology and all scripts Add an --upgrade switch to regress/run_test in preparation of regress testing upgrade scripts (#1326) git-svn-id: http://svn.osgeo.org/postgis/trunk@8853 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/Makefile.in b/postgis/Makefile.in index a07d86963..e359fb049 100644 --- a/postgis/Makefile.in +++ b/postgis/Makefile.in @@ -104,6 +104,7 @@ ifeq ($(REGRESS),1) bindir=/bin pkglibdir=/lib datadir=/share + MODULEDIR=contrib/postgis endif # Make all PostGIS objects depend upon liblwgeom, so that if an underlying diff --git a/raster/rt_pg/Makefile.in b/raster/rt_pg/Makefile.in index c2e51096f..df44b9e0f 100644 --- a/raster/rt_pg/Makefile.in +++ b/raster/rt_pg/Makefile.in @@ -77,6 +77,7 @@ ifeq ($(REGRESS),1) bindir=/bin pkglibdir=/lib datadir=/share + MODULEDIR=contrib/postgis endif # Borrow the $libdir substitution from PGXS but customise by adding the version number diff --git a/raster/test/regress/Makefile.in b/raster/test/regress/Makefile.in index 5bb4ac102..8af8245b7 100644 --- a/raster/test/regress/Makefile.in +++ b/raster/test/regress/Makefile.in @@ -140,9 +140,8 @@ rtpostgis.sql: ../../rt_pg/rtpostgis.sql sed 's,$$libdir,$(REGRESS_INSTALLDIR)/lib,g' ../../rt_pg/rtpostgis.sql > rtpostgis.sql -check: rtpostgis.sql - $(MAKE) -C ../../../regress postgis.sql staged-install - $(MAKE) -C ../../rt_pg REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install +check: + $(MAKE) -C ../../../regress staged-install ../../../regress/run_test $(RUNTESTFLAGS) --raster $(TESTS) #all: run_test diff --git a/regress/Makefile.in b/regress/Makefile.in index 5bf372e3e..2deed9178 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -1,3 +1,18 @@ +# ********************************************************************** +# * +# * PostGIS - Spatial Types for PostgreSQL +# * http://postgis.refractions.net +# * +# * Copyright (C) 2011-2012 Sandro Santilli +# * Copyright (C) 2009-2011 Paul Ramsey +# * Copyright (C) 2008-2009 Mark Cave-Ayland +# * +# * This is free software; you can redistribute and/or modify it under +# * the terms of the GNU General Public Licence. See the COPYING file. +# * +# ********************************************************************** + +PERL=@PERL@ TMPDIR?=/tmp POSTGIS_PGSQL_VERSION=@POSTGIS_PGSQL_VERSION@ @@ -129,14 +144,19 @@ endif all install uninstall distclean: -postgis.sql: $(REGRESS_INSTALLDIR)/postgis.sql +staged-install-topology: + @if test x"@TOPOLOGY@" != "x"; then \ + $(MAKE) -C ../topology REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install; \ + fi -$(REGRESS_INSTALLDIR)/postgis.sql: ../postgis/postgis.sql - mkdir -p $(REGRESS_INSTALLDIR) - sed 's,$$libdir,$(REGRESS_INSTALLDIR)/lib,g' ../postgis/postgis.sql > $@ +staged-install-raster: + @if test x"@RASTER@" != "x"; then \ + $(MAKE) -C ../raster/rt_pg REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install; \ + fi -staged-install: postgis.sql +staged-install: staged-install-raster staged-install-topology $(MAKE) -C ../postgis REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install + $(PERL) -pi -e 's,\$$libdir,$(REGRESS_INSTALLDIR)/lib,g' $(REGRESS_INSTALLDIR)/share/contrib/postgis/*.sql #$(MAKE) -C ../loader REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install test check: staged-install diff --git a/regress/run_test b/regress/run_test index 87ad26c26..3cf0f31fe 100755 --- a/regress/run_test +++ b/regress/run_test @@ -34,6 +34,8 @@ export PGOPTIONS REGDIR=`dirname $0` REGDIR=`cd "${REGDIR}" && pwd` +STAGED_INSTALL_DIR="${REGDIR}/00-regress-install" +STAGED_SCRIPTS_DIR="${STAGED_INSTALL_DIR}/share/contrib/postgis" PSQL="psql" @@ -47,6 +49,7 @@ VERBOSE=0 OPT_CLEAN=no OPT_DROP=yes OPT_CREATE=yes +OPT_UPGRADE=no OPT_WITH_TOPO=no OPT_WITH_RASTER=no @@ -434,9 +437,9 @@ init_db_error () echo "-----------------------------------------------------------------------------" tail -5 ${TMPDIR}/regress_log echo "-----------------------------------------------------------------------------" - else + else echo " For details, check ${TMPDIR}/regress_log" - fi + fi echo if test x"$OPT_DROP" = "xyes" -a x"$OPT_CREATE" = "xyes"; then @@ -485,6 +488,10 @@ while [ -n "$1" ]; do OPT_CREATE=no shift continue + elif test "$1" = "--upgrade"; then + OPT_UPGRADE=yes + shift + continue elif test "$1" = "--topology"; then OPT_WITH_TOPO=yes shift @@ -507,6 +514,7 @@ if [ -z "$1" ]; then echo "Options:" >&2 echo " -v be verbose about failures" >&2 echo " --nocreate do not create the regression database on start" >&2 + echo " --upgrade source the upgrade scripts on start" >&2 echo " --nodrop do not drop the regression database on exit" >&2 echo " --raster load also topology extension" >&2 echo " --topology load also topology extension" >&2 @@ -536,23 +544,26 @@ if test -z "$db_exists"; then # Count database objects before installing anything object_count_pre=$(count_db_objects "counting object before postgis install") - ${PSQL} ${_psql_opts} -Xf ${REGDIR}/00-regress-install/postgis.sql "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "core module" + ${PSQL} ${_psql_opts} -Xf ${STAGED_SCRIPTS_DIR}/postgis.sql "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "core module" if test x"$OPT_WITH_TOPO" = "xyes"; then - if test -e ${REGDIR}/../topology/topology.sql; then + SCRIPT=${STAGED_SCRIPTS_DIR}/topology.sql + if test -e ${SCRIPT}; then echo "Adding topology support" ${PSQL} ${_psql_opts} -Xf ${REGDIR}/../topology/topology.sql "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "topology module" else - echo "Topology support skipped (topology.sql not found)" + echo "${SCRIPT} not found" >&2 + exit 1 fi fi if test x"$OPT_WITH_RASTER" = "xyes"; then - SCRIPT=${REGDIR}/../raster/test/regress/rtpostgis.sql + SCRIPT=${STAGED_SCRIPTS_DIR}/rtpostgis.sql if test -e ${SCRIPT}; then echo "Adding raster support" ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "raster module" else - echo "Raster support skipped (rtpostgis.sql not found)" + echo "${SCRIPT} not found" >&2 + exit 1 fi fi else @@ -572,6 +583,39 @@ else fi fi +if test x"$OPT_UPGRADE" = "xyes"; then + SCRIPT=${STAGED_SCRIPTS_DIR}/postgis_upgrade_*_minor.sql + if test -e ${SCRIPT}; then + echo "Loading ${SCRIPT}" + ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "core upgrade" + else + echo "${SCRIPT} not found" >&2 + exit 1 + fi + + if test x"$OPT_WITH_TOPO" = "xyes"; then + SCRIPT=${STAGED_SCRIPTS_DIR}/topology_upgrade_*_minor.sql + if test -e ${SCRIPT}; then + echo "Loading ${SCRIPT}" + ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "topology upgrade" + else + echo "${SCRIPT} not found" >&2 + exit 1 + fi + fi + + if test x"$OPT_WITH_RASTER" = "xyes"; then + SCRIPT=${STAGED_SCRIPTS_DIR}/rtpostgis_upgrade_*_minor.sql + if test -e ${SCRIPT}; then + echo "Loading ${SCRIPT}" + ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "raster upgrade" + else + echo "${SCRIPT} not found" >&2 + exit 1 + fi + fi +fi + libver=`${PSQL} -tAc "select postgis_lib_version()" "${DB}"` if [ -z "$libver" ]; then diff --git a/topology/Makefile.in b/topology/Makefile.in index d862d3c78..cd76a442f 100644 --- a/topology/Makefile.in +++ b/topology/Makefile.in @@ -52,6 +52,17 @@ ifeq ($(PGXSOVERRIDE),1) include ../postgis/Makefile.pgxs endif +# If REGRESS=1 passed as a parameter, change the default install paths +# so that no prefix is included. This allows us to relocate to a temporary +# directory for regression testing. +ifeq ($(REGRESS),1) + bindir=/bin + pkglibdir=/lib + datadir=/share + MODULEDIR=contrib/postgis +endif + + # Unfortunately we have to copy this from the PGXS Makefile as it only gets picked up # if MODULE_big is defined diff --git a/topology/test/Makefile b/topology/test/Makefile index 3dc48fb61..6f8aba8a6 100644 --- a/topology/test/Makefile +++ b/topology/test/Makefile @@ -61,5 +61,5 @@ TESTS = regress/legacy_validate.sql regress/legacy_predicate.sql \ regress/layertrigger.sql check: topo_predicates.sql load_topology.sql load_topology-4326.sql - $(MAKE) -C ../../regress postgis.sql staged-install + $(MAKE) -C ../../regress staged-install ../../regress/run_test $(RUNTESTFLAGS) --topology $(TESTS)