diff --git a/postgis-17 b/postgis-17 new file mode 120000 index 00000000000..928a3a19b38 --- /dev/null +++ b/postgis-17 @@ -0,0 +1 @@ +postgis \ No newline at end of file diff --git a/postgis.yaml b/postgis-17.yaml similarity index 57% rename from postgis.yaml rename to postgis-17.yaml index 32fa505a122..c5842431e7c 100644 --- a/postgis.yaml +++ b/postgis-17.yaml @@ -1,7 +1,7 @@ package: - name: postgis + name: postgis-17 version: 3.5.0 - epoch: 1 + epoch: 0 description: Geographic Information Systems Extensions to PostgreSQL copyright: - license: GPL-2.0-or-later @@ -18,12 +18,19 @@ environment: - json-c-dev - libxml2-dev - make + - pcre-dev - perl-dev - postgresql-dev - proj-dev - protobuf-c-dev - protoc +var-transforms: + - from: ${{package.name}} + match: "postgis-(.+)" + replace: "$1" + to: postgresql-version + pipeline: - uses: fetch with: @@ -41,6 +48,25 @@ pipeline: - runs: | make install DESTDIR="${{targets.destdir}}" + - runs: | + cd extensions + make + make install DESTDIR="${{targets.destdir}}" + +subpackages: + - name: ${{package.name}}-compat + pipeline: + - runs: | + mkdir -p ${{targets.subpkgdir}}/usr/libexec/postgresql${{vars.postgresql-version}}/ + install -m755 update-postgis.sh ${{targets.subpkgdir}}/usr/libexec/postgresql${{vars.postgresql-version}}/ + sed -i "s|/docker-entrypoint-initdb.d|/var/lib/postgres/initdb|g" ${{targets.subpkgdir}}/usr/libexec/postgresql${{vars.postgresql-version}}/*.sh + sed -i "s|/usr/local|/usr|g" ${{targets.subpkgdir}}/usr/libexec/postgresql${{vars.postgresql-version}}/*.sh + + mkdir -p ${{targets.subpkgdir}}/var/lib/postgres/initdb/ + # 644 is important! docker-entrypoint execs 755 files, but sources if there are no exec bits set + install -m644 initdb-postgis.sh ${{targets.subpkgdir}}/usr/libexec/postgresql${{vars.postgresql-version}}/initdb-postgis.sh + ln -sf /usr/libexec/postgresql${{vars.postgresql-version}}/initdb-postgis.sh ${{targets.subpkgdir}}/var/lib/postgres/initdb/10_postgis.sh + test: environment: contents: @@ -76,6 +102,10 @@ test: runs: | psql -d testdb -c "CREATE EXTENSION postgis;" psql -d testdb -c "SELECT PostGIS_Full_Version();" | grep -q "POSTGIS=" + - name: "Test PostGIS extension is installed and working" + runs: | + psql -d testdb -c "CREATE EXTENSION address_standardizer;" + psql -d testdb -c "SELECT num, street, city, state, zip FROM parse_address('1 Devonshire Place PH301, Boston, MA 02109');" |grep 'Devonshire Place PH301' update: enabled: true diff --git a/postgis/initdb-postgis.sh b/postgis/initdb-postgis.sh new file mode 100644 index 00000000000..ad293873bb2 --- /dev/null +++ b/postgis/initdb-postgis.sh @@ -0,0 +1,27 @@ +# COPIED FROM https://github.com/postgis/docker-postgis/blob/master/17-3.5/initdb-postgis.sh + +#!/bin/bash + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<- 'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/postgis/update-postgis.sh b/postgis/update-postgis.sh new file mode 100644 index 00000000000..a0327dd117d --- /dev/null +++ b/postgis/update-postgis.sh @@ -0,0 +1,30 @@ +# COPIED FROM https://github.com/postgis/docker-postgis/blob/master/17-3.5/update-postgis.sh + +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done