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
# 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
# for postgresql.pkgs
@ -37,14 +37,22 @@ let
outputs = [ "out" "lib" "doc" "man" ];
setOutputFlags = false; # $out retains configureFlags :-/
buildInputs =
[ zlib readline openssl libxml2 icu ]
buildInputs = [
zlib
readline
openssl
libxml2
icu
]
++ lib.optionals lz4Enabled [ lz4 ]
++ lib.optionals enableSystemd [ systemd ]
++ lib.optionals gssSupport [ libkrb5 ]
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
nativeBuildInputs = [ makeWrapper pkg-config ];
nativeBuildInputs = [
makeWrapper
pkg-config
];
enableParallelBuilding = !stdenv.isDarwin;
@ -71,25 +79,24 @@ let
++ lib.optionals gssSupport [ "--with-gssapi" ]
++ lib.optionals stdenv.hostPlatform.isRiscV [ "--disable-spinlocks" ];
patches =
[ (if atLeast "9.4" then ./patches/disable-resolve_symlinks-94.patch else ./patches/disable-resolve_symlinks.patch)
(if atLeast "9.6" then ./patches/less-is-more-96.patch else ./patches/less-is-more.patch)
(if atLeast "9.6" then ./patches/hardcode-pgxs-path-96.patch else ./patches/hardcode-pgxs-path.patch)
./patches/specify_pkglibdir_at_runtime.patch
./patches/findstring.patch
]
++ lib.optional stdenv.isLinux (if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch);
patches = [
./patches/disable-resolve_symlinks.patch
./patches/less-is-more.patch
./patches/hardcode-pgxs-path.patch
./patches/specify_pkglibdir_at_runtime.patch
./patches/findstring.patch
] ++ lib.optionals stdenv.isLinux [
(if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch)
];
installTargets = [ "install-world" ];
LC_ALL = "C";
postConfigure =
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 "${path}" --replace HARDCODED_PGXS_PATH $out/lib
'';
postPatch = ''
# 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"
'';
postInstall =
''
@ -162,8 +169,6 @@ let
license = licenses.postgresql;
maintainers = with maintainers; [ thoughtpolice danbst globin marsam ivan ];
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
index c79e8ba..42c4091 100644
--- a/src/port/exec.c
+++ b/src/port/exec.c
@@ -216,6 +216,9 @@ find_my_exec(const char *argv0, char *retpath)
--- 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;
+ // On NixOS we *want* stuff relative to symlinks.
+ return 0;
+
#ifdef HAVE_READLINK
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
+++ b/src/bin/pg_config/pg_config.c
@@ -220,11 +220,13 @@ show_sysconfdir(bool all)
static void
show_pgxs(bool all)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH] = "HARDCODED_PGXS_PATH";
if (all)
printf("PGXS = ");
+ /* commented out to be able to point to nix $out path
get_pkglib_path(mypath, path);
+ */
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);
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
--- postgresql-9.2.7-orig/src/bin/psql/print.h 2014-02-17 14:38:15.000000000 -0500
+++ postgresql-9.2.7/src/bin/psql/print.h 2014-03-04 14:42:28.874014415 -0500
@@ -178,7 +178,7 @@
extern const printTextFormat *get_line_style(const printTableOpt *opt);
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"