Skip to content

Commit

Permalink
Postgis 17 (#34196)
Browse files Browse the repository at this point in the history
Signed-off-by: Jamon <[email protected]>
  • Loading branch information
jamonation authored Nov 16, 2024
1 parent 9e12dd2 commit 5407aed
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
1 change: 1 addition & 0 deletions postgis-17
34 changes: 32 additions & 2 deletions postgis.yaml → postgis-17.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions postgis/initdb-postgis.sh
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions postgis/update-postgis.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5407aed

Please sign in to comment.