postgresql: fix pgxs Makefile for darwin

The darwin specific Makefile contains a reference to the postgres
binary. Some extensions are able to set bindir to their own output
correctly for installation and will then fail to find the postgres
binaryin their own output during linking.

PostGIS worked around this by faking a postgres binary in their own
output, but we can do better by hardcoding the proper path in the
Makefile when PostgreSQL is built.
This commit is contained in:
Wolfgang Walther
2024-09-23 22:00:29 +02:00
parent 5ec5cdaffa
commit b924334c41
2 changed files with 6 additions and 11 deletions

View File

@@ -89,14 +89,6 @@ buildPostgresqlExtension (finalAttrs: {
"--disable-extension-upgrades-install"
];
postConfigure = ''
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
'';
makeFlags = [
"PERL=${perl}/bin/perl"
];
@@ -111,9 +103,6 @@ buildPostgresqlExtension (finalAttrs: {
# 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-${finalAttrs.version}
done

View File

@@ -284,6 +284,12 @@ let
# Stop lib depending on the -dev output of llvm
remove-references-to -t ${llvmPackages.llvm.dev} "$out/lib/llvmjit${dlSuffix}"
'' + lib.optionalString stdenv'.hostPlatform.isDarwin ''
# The darwin specific Makefile for PGXS contains a reference to the postgres
# binary. Some extensions (here: postgis), which are able to set bindir correctly
# to their own output for installation, will then fail to find "postgres" during linking.
substituteInPlace "$dev/lib/pgxs/src/Makefile.port" \
--replace-fail '-bundle_loader $(bindir)/postgres' "-bundle_loader $out/bin/postgres"
'';
postFixup = lib.optionalString stdenv'.hostPlatform.isGnu