postgresql.pg_config: add check to confirm output is correct

This is only tested on native builds against the output of the original
pg_config, which should be enough.
This commit is contained in:
Wolfgang Walther 2025-03-23 16:24:51 +01:00
parent 5449a0ea74
commit 6db5dcc013
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
2 changed files with 17 additions and 1 deletions

View File

@ -366,6 +366,7 @@ let
postPatch = ''
substituteInPlace "src/Makefile.global.in" --subst-var out
substituteInPlace "src/common/config_info.c" --subst-var dev
cat ${./pg_config.env.mk} >> src/common/Makefile
'';
@ -373,7 +374,12 @@ let
''
moveToOutput "bin/ecpg" "$dev"
moveToOutput "lib/pgxs" "$dev"
''
+ lib.optionalString (stdenv'.buildPlatform.canExecute stdenv'.hostPlatform) ''
mkdir -p "$dev/nix-support"
"$out/bin/pg_config" > "$dev/nix-support/pg_config.expected"
''
+ ''
rm "$out/bin/pg_config"
make -C src/common pg_config.env
install -D src/common/pg_config.env "$dev/nix-support/pg_config.env"

View File

@ -1,7 +1,9 @@
{
diffutils,
lib,
replaceVarsWith,
runtimeShell,
stdenv,
# PostgreSQL package
finalPackage,
}:
@ -15,4 +17,12 @@ replaceVarsWith {
inherit runtimeShell;
postgresql-dev = lib.getDev finalPackage;
};
nativeCheckInputs = [
diffutils
];
postCheck = ''
if [ -e ${lib.getDev finalPackage}/nix-support/pg_config.expected ]; then
diff ${lib.getDev finalPackage}/nix-support/pg_config.expected <($out/bin/pg_config)
fi
'';
}