Merge pull request #198930 from jtojnar/postgres-cleanup

postgresql: remove code for no longer supported versions
This commit is contained in:
Mario Rodas 2022-11-11 01:04:53 -05:00 committed by GitHub
commit eac4d56a92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 85 deletions

View file

@ -7,7 +7,7 @@ let
, pkg-config, libxml2, tzdata, libkrb5 , pkg-config, libxml2, tzdata, libkrb5
# This is important to obtain a version of `libpq` that does not depend on systemd. # This is important to obtain a version of `libpq` that does not depend on systemd.
, enableSystemd ? (lib.versionAtLeast version "9.6" && !stdenv.isDarwin && !stdenv.hostPlatform.isStatic) , enableSystemd ? !stdenv.isDarwin && !stdenv.hostPlatform.isStatic
, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic , gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic
# for postgresql.pkgs # for postgresql.pkgs
@ -37,14 +37,22 @@ let
outputs = [ "out" "lib" "doc" "man" ]; outputs = [ "out" "lib" "doc" "man" ];
setOutputFlags = false; # $out retains configureFlags :-/ setOutputFlags = false; # $out retains configureFlags :-/
buildInputs = buildInputs = [
[ zlib readline openssl libxml2 icu ] zlib
readline
openssl
libxml2
icu
]
++ lib.optionals lz4Enabled [ lz4 ] ++ lib.optionals lz4Enabled [ lz4 ]
++ lib.optionals enableSystemd [ systemd ] ++ lib.optionals enableSystemd [ systemd ]
++ lib.optionals gssSupport [ libkrb5 ] ++ lib.optionals gssSupport [ libkrb5 ]
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ]; ++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
nativeBuildInputs = [ makeWrapper pkg-config ]; nativeBuildInputs = [
makeWrapper
pkg-config
];
enableParallelBuilding = !stdenv.isDarwin; enableParallelBuilding = !stdenv.isDarwin;
@ -71,25 +79,24 @@ let
++ lib.optionals gssSupport [ "--with-gssapi" ] ++ lib.optionals gssSupport [ "--with-gssapi" ]
++ lib.optionals stdenv.hostPlatform.isRiscV [ "--disable-spinlocks" ]; ++ lib.optionals stdenv.hostPlatform.isRiscV [ "--disable-spinlocks" ];
patches = patches = [
[ (if atLeast "9.4" then ./patches/disable-resolve_symlinks-94.patch else ./patches/disable-resolve_symlinks.patch) ./patches/disable-resolve_symlinks.patch
(if atLeast "9.6" then ./patches/less-is-more-96.patch else ./patches/less-is-more.patch) ./patches/less-is-more.patch
(if atLeast "9.6" then ./patches/hardcode-pgxs-path-96.patch else ./patches/hardcode-pgxs-path.patch) ./patches/hardcode-pgxs-path.patch
./patches/specify_pkglibdir_at_runtime.patch ./patches/specify_pkglibdir_at_runtime.patch
./patches/findstring.patch ./patches/findstring.patch
] ] ++ lib.optionals stdenv.isLinux [
++ lib.optional stdenv.isLinux (if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch); (if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch)
];
installTargets = [ "install-world" ]; installTargets = [ "install-world" ];
LC_ALL = "C"; LC_ALL = "C";
postConfigure = postPatch = ''
let path = if atLeast "9.6" then "src/common/config_info.c" else "src/bin/pg_config/pg_config.c"; in # Hardcode the path to pgxs so pg_config returns the path in $out
'' substituteInPlace "src/common/config_info.c" --replace HARDCODED_PGXS_PATH "$out/lib"
# Hardcode the path to pgxs so pg_config returns the path in $out '';
substituteInPlace "${path}" --replace HARDCODED_PGXS_PATH $out/lib
'';
postInstall = postInstall =
'' ''
@ -162,8 +169,6 @@ let
license = licenses.postgresql; license = licenses.postgresql;
maintainers = with maintainers; [ thoughtpolice danbst globin marsam ivan ]; maintainers = with maintainers; [ thoughtpolice danbst globin marsam ivan ];
platforms = platforms.unix; platforms = platforms.unix;
knownVulnerabilities = optional (!atLeast "9.4")
"PostgreSQL versions older than 9.4 are not maintained anymore!";
}; };
}; };

View file

@ -1,12 +0,0 @@
--- a/src/common/exec.c 2014-09-04 20:19:12.236057588 +0200
+++ b/src/common/exec.c 2014-09-04 20:19:50.550251633 +0200
@@ -218,6 +218,9 @@
static int
resolve_symlinks(char *path)
{
+ // On NixOS we *want* stuff relative to symlinks.
+ return 0;
+
#ifdef HAVE_READLINK
struct stat buf;
char orig_wd[MAXPGPATH],

View file

@ -1,13 +1,11 @@
diff --git a/src/port/exec.c b/src/port/exec.c --- a/src/common/exec.c 2014-09-04 20:19:12.236057588 +0200
index c79e8ba..42c4091 100644 +++ b/src/common/exec.c 2014-09-04 20:19:50.550251633 +0200
--- a/src/port/exec.c @@ -218,6 +218,9 @@
+++ b/src/port/exec.c
@@ -216,6 +216,9 @@ find_my_exec(const char *argv0, char *retpath)
static int static int
resolve_symlinks(char *path) resolve_symlinks(char *path)
{ {
+ // On NixOS we *want* stuff relative to symlinks. + // On NixOS we *want* stuff relative to symlinks.
+ return 0; + return 0;
+ +
#ifdef HAVE_READLINK #ifdef HAVE_READLINK
struct stat buf; struct stat buf;

View file

@ -1,14 +0,0 @@
diff -Naur postgresql-9.6.1-orig/src/common/config_info.c postgresql-9.6.1/src/common/config_info.c
--- postgresql-9.6.1-orig/src/common/config_info.c 2016-11-22 21:39:29.231929261 +0100
+++ postgresql-9.6.1/src/common/config_info.c 2016-11-22 23:36:53.685163543 +0100
@@ -118,7 +118,10 @@
i++;
configdata[i].name = pstrdup("PGXS");
+ strlcpy(path, "HARDCODED_PGXS_PATH", sizeof(path));
+/* commented out to be able to point to nix $out path
get_pkglib_path(my_exec_path, path);
+*/
strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
cleanup_path(path);
configdata[i].setting = pstrdup(path);

View file

@ -1,17 +1,14 @@
--- a/src/bin/pg_config/pg_config.c diff -Naur postgresql-9.6.1-orig/src/common/config_info.c postgresql-9.6.1/src/common/config_info.c
+++ b/src/bin/pg_config/pg_config.c --- postgresql-9.6.1-orig/src/common/config_info.c 2016-11-22 21:39:29.231929261 +0100
@@ -220,11 +220,13 @@ show_sysconfdir(bool all) +++ postgresql-9.6.1/src/common/config_info.c 2016-11-22 23:36:53.685163543 +0100
static void @@ -118,7 +118,10 @@
show_pgxs(bool all) i++;
{
- char path[MAXPGPATH]; configdata[i].name = pstrdup("PGXS");
+ char path[MAXPGPATH] = "HARDCODED_PGXS_PATH"; + strlcpy(path, "HARDCODED_PGXS_PATH", sizeof(path));
+/* commented out to be able to point to nix $out path
if (all) get_pkglib_path(my_exec_path, path);
printf("PGXS = "); +*/
+ /* commented out to be able to point to nix $out path
get_pkglib_path(mypath, path);
+ */
strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path)); strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
cleanup_path(path); cleanup_path(path);
printf("%s\n", path); configdata[i].setting = pstrdup(path);

View file

@ -1,12 +0,0 @@
diff -Naur postgresql-9.6.1-orig/src/include/fe_utils/print.h postgresql-9.6.1/src/include/fe_utils/print.h
--- postgresql-9.6.1-orig/src/include/fe_utils/print.h 2016-11-22 21:39:29.148932827 +0100
+++ postgresql-9.6.1/src/include/fe_utils/print.h 2016-11-22 21:39:36.283626258 +0100
@@ -18,7 +18,7 @@
/* This is not a particularly great place for this ... */
#ifndef __CYGWIN__
-#define DEFAULT_PAGER "more"
+#define DEFAULT_PAGER "less"
#else
#define DEFAULT_PAGER "less"
#endif

View file

@ -1,9 +1,9 @@
diff -Naur postgresql-9.2.7-orig/src/bin/psql/print.h postgresql-9.2.7/src/bin/psql/print.h diff -Naur postgresql-9.6.1-orig/src/include/fe_utils/print.h postgresql-9.6.1/src/include/fe_utils/print.h
--- postgresql-9.2.7-orig/src/bin/psql/print.h 2014-02-17 14:38:15.000000000 -0500 --- postgresql-9.6.1-orig/src/include/fe_utils/print.h 2016-11-22 21:39:29.148932827 +0100
+++ postgresql-9.2.7/src/bin/psql/print.h 2014-03-04 14:42:28.874014415 -0500 +++ postgresql-9.6.1/src/include/fe_utils/print.h 2016-11-22 21:39:36.283626258 +0100
@@ -178,7 +178,7 @@ @@ -18,7 +18,7 @@
extern const printTextFormat *get_line_style(const printTableOpt *opt);
/* This is not a particularly great place for this ... */
#ifndef __CYGWIN__ #ifndef __CYGWIN__
-#define DEFAULT_PAGER "more" -#define DEFAULT_PAGER "more"
+#define DEFAULT_PAGER "less" +#define DEFAULT_PAGER "less"