Skip to content

Commit

Permalink
Sam/postgis tiger fix (#1413)
Browse files Browse the repository at this point in the history
* chore: wip attempt to fix search paths for postgis_tiger_geocoder

* chore: suffix for staging AMI

* chore: newline

* chore: fix pg_regress

* fix: use postgis_extension_AddToSearchPath for extensions schema

* chore: bump staging suffix

* chore: resolve quotes to test

* chore: bump versions
  • Loading branch information
samrose authored Jan 21, 2025
1 parent 66fb5c1 commit 0dfeaae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ postgres_major:

# Full version strings for each major version
postgres_release:
postgresorioledb-17: "17.0.1.020-orioledb"
postgres15: "15.8.1.030"
postgresorioledb-17: "17.0.1.021-orioledb"
postgres15: "15.8.1.031"

# Non Postgres Extensions
pgbouncer_release: "1.19.0"
Expand Down
39 changes: 18 additions & 21 deletions nix/ext/postgis.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ perl pkg-config ];
dontDisableStatic = true;

# postgis config directory assumes /include /lib from the same root for json-c library
env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";

env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";

preConfigure = ''
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${pname} --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev} --disable-extension-upgrades-install --with-sfcgal"
makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${pname}"
'';

postConfigure = ''
sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
Expand All @@ -54,28 +54,25 @@ stdenv.mkDerivation rec {
" \
"raster/scripts/python/Makefile";
mkdir -p $out/bin
# postgis' build system assumes it is being installed to the same place as postgresql, and looks
# for the postgres binary relative to $PREFIX. We gently support this system using an illusion.
ln -s ${postgresql}/bin/postgres $out/bin/postgres
'';

# create aliases for all commands adding version information
postInstall = ''
# Teardown the illusory postgres used for building; see postConfigure.
rm $out/bin/postgres
for prog in $out/bin/*; do # */
ln -s $prog $prog-${version}
done
for file in $out/share/postgresql/extension/postgis_topology*--${version}.sql; do
sed -i "/SELECT topology.AddToSearchPath('topology');/i SELECT topology.AddToSearchPath('extensions');" "$file"
done
mkdir -p $doc/share/doc/postgis
mv doc/* $doc/share/doc/postgis/
'';
postInstall = ''
rm $out/bin/postgres
for prog in $out/bin/*; do # */
ln -s $prog $prog-${version}
done
# Add function definition and usage to tiger geocoder files
for file in $out/share/postgresql/extension/postgis_tiger_geocoder*--${version}.sql; do
sed -i "/SELECT postgis_extension_AddToSearchPath('tiger');/a SELECT postgis_extension_AddToSearchPath('extensions');" "$file"
done
# Original topology patching
for file in $out/share/postgresql/extension/postgis_topology*--${version}.sql; do
sed -i "/SELECT topology.AddToSearchPath('topology');/i SELECT topology.AddToSearchPath('extensions');" "$file"
done
mkdir -p $doc/share/doc/postgis
mv doc/* $doc/share/doc/postgis/
'';

passthru.tests.postgis = nixosTests.postgis;

Expand Down

0 comments on commit 0dfeaae

Please sign in to comment.