From 99b13257066833feab4cca2704b0774ff9ad51af Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Mon, 19 Oct 2020 20:26:59 +0300 Subject: [PATCH] postgresql: update patch for hardcoded paths --- packages/postgresql/fix-hardcoded-paths.patch | 99 +++++++++++++++++++ .../postgresql/src-bin-pg_ctl-pg_ctl.c.patch | 12 --- .../src-bin-pg_upgrade-check.c.patch | 21 ---- .../postgresql/src-bin-psql-command.c.patch | 21 ---- .../src-include-pg_config_manual.h.patch | 24 ----- 5 files changed, 99 insertions(+), 78 deletions(-) create mode 100644 packages/postgresql/fix-hardcoded-paths.patch delete mode 100644 packages/postgresql/src-bin-pg_ctl-pg_ctl.c.patch delete mode 100644 packages/postgresql/src-bin-pg_upgrade-check.c.patch delete mode 100644 packages/postgresql/src-bin-psql-command.c.patch delete mode 100644 packages/postgresql/src-include-pg_config_manual.h.patch diff --git a/packages/postgresql/fix-hardcoded-paths.patch b/packages/postgresql/fix-hardcoded-paths.patch new file mode 100644 index 000000000..89cf58b81 --- /dev/null +++ b/packages/postgresql/fix-hardcoded-paths.patch @@ -0,0 +1,99 @@ +diff -uNr postgresql-13.0/contrib/pg_trgm/trgm_regexp.c postgresql-13.0.mod/contrib/pg_trgm/trgm_regexp.c +--- postgresql-13.0/contrib/pg_trgm/trgm_regexp.c 2020-09-21 23:47:36.000000000 +0300 ++++ postgresql-13.0.mod/contrib/pg_trgm/trgm_regexp.c 2020-10-19 20:20:32.875091545 +0300 +@@ -2173,7 +2173,7 @@ + + { + /* dot -Tpng -o /tmp/source.png < /tmp/source.gv */ +- FILE *fp = fopen("/tmp/source.gv", "w"); ++ FILE *fp = fopen("@TERMUX_PREFIX@/tmp/source.gv", "w"); + + fprintf(fp, "%s", buf.data); + fclose(fp); +diff -uNr postgresql-13.0/src/bin/initdb/initdb.c postgresql-13.0.mod/src/bin/initdb/initdb.c +--- postgresql-13.0/src/bin/initdb/initdb.c 2020-09-21 23:47:36.000000000 +0300 ++++ postgresql-13.0.mod/src/bin/initdb/initdb.c 2020-10-19 20:20:44.907210164 +0300 +@@ -1095,7 +1095,7 @@ + #else + snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''"); + #endif +- conflines = replace_token(conflines, "#unix_socket_directories = '/tmp'", ++ conflines = replace_token(conflines, "#unix_socket_directories = '@TERMUX_PREFIX@/tmp'", + repltok); + + #if DEF_PGPORT != 5432 +diff -uNr postgresql-13.0/src/bin/pg_ctl/pg_ctl.c postgresql-13.0.mod/src/bin/pg_ctl/pg_ctl.c +--- postgresql-13.0/src/bin/pg_ctl/pg_ctl.c 2020-09-21 23:47:36.000000000 +0300 ++++ postgresql-13.0.mod/src/bin/pg_ctl/pg_ctl.c 2020-10-19 20:17:25.837231316 +0300 +@@ -494,7 +494,7 @@ + snprintf(cmd, MAXPGPATH, "exec \"%s\" %s%s < \"%s\" 2>&1", + exec_path, pgdata_opt, post_opts, DEVNULL); + +- (void) execl("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL); ++ (void) execl("@TERMUX_PREFIX@/bin/sh", "sh", "-c", cmd, (char *) NULL); + + /* exec failed */ + write_stderr(_("%s: could not start server: %s\n"), +diff -uNr postgresql-13.0/src/bin/pg_upgrade/check.c postgresql-13.0.mod/src/bin/pg_upgrade/check.c +--- postgresql-13.0/src/bin/pg_upgrade/check.c 2020-09-21 23:47:36.000000000 +0300 ++++ postgresql-13.0.mod/src/bin/pg_upgrade/check.c 2020-10-19 20:17:25.837231316 +0300 +@@ -474,7 +474,7 @@ + + #ifndef WIN32 + /* add shebang header */ +- fprintf(script, "#!/bin/sh\n\n"); ++ fprintf(script, "#!@TERMUX_PREFIX@/bin/sh\n\n"); + #else + /* suppress command echoing */ + fprintf(script, "@echo off\n"); +@@ -602,7 +602,7 @@ + + #ifndef WIN32 + /* add shebang header */ +- fprintf(script, "#!/bin/sh\n\n"); ++ fprintf(script, "#!@TERMUX_PREFIX@/bin/sh\n\n"); + #endif + + /* delete old cluster's default tablespace */ +diff -uNr postgresql-13.0/src/bin/psql/command.c postgresql-13.0.mod/src/bin/psql/command.c +--- postgresql-13.0/src/bin/psql/command.c 2020-09-21 23:47:36.000000000 +0300 ++++ postgresql-13.0.mod/src/bin/psql/command.c 2020-10-19 20:18:07.733650936 +0300 +@@ -3577,7 +3577,7 @@ + if (result == -1) + pg_log_error("could not start editor \"%s\"", editorName); + else if (result == 127) +- pg_log_error("could not start /bin/sh"); ++ pg_log_error("could not start @TERMUX_PREFIX@/bin/sh"); + free(sys); + + return result == 0; +@@ -3607,7 +3607,7 @@ + const char *tmpdir = getenv("TMPDIR"); + + if (!tmpdir) +- tmpdir = "/tmp"; ++ tmpdir = "@TERMUX_PREFIX@/tmp"; + #else + char tmpdir[MAXPGPATH]; + int ret; +@@ -4590,7 +4590,7 @@ + + + #ifndef WIN32 +-#define DEFAULT_SHELL "/bin/sh" ++#define DEFAULT_SHELL "@TERMUX_PREFIX@/bin/sh" + #else + /* + * CMD.EXE is in different places in different Win32 releases so we +diff -uNr postgresql-13.0/src/include/pg_config_manual.h postgresql-13.0.mod/src/include/pg_config_manual.h +--- postgresql-13.0/src/include/pg_config_manual.h 2020-09-21 23:47:36.000000000 +0300 ++++ postgresql-13.0.mod/src/include/pg_config_manual.h 2020-10-19 20:22:20.620150044 +0300 +@@ -203,7 +203,7 @@ + #ifndef WIN32 + #define DEFAULT_PGSOCKET_DIR "/tmp" + #else +-#define DEFAULT_PGSOCKET_DIR "" ++#define DEFAULT_PGSOCKET_DIR "@TERMUX_PREFIX@/tmp" + #endif + + /* diff --git a/packages/postgresql/src-bin-pg_ctl-pg_ctl.c.patch b/packages/postgresql/src-bin-pg_ctl-pg_ctl.c.patch deleted file mode 100644 index b1129b7bb..000000000 --- a/packages/postgresql/src-bin-pg_ctl-pg_ctl.c.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -u -r ../postgresql-9.6.2/src/bin/pg_ctl/pg_ctl.c ./src/bin/pg_ctl/pg_ctl.c ---- ../postgresql-9.6.2/src/bin/pg_ctl/pg_ctl.c 2017-02-06 22:45:25.000000000 +0100 -+++ ./src/bin/pg_ctl/pg_ctl.c 2017-03-05 14:47:06.985823535 +0100 -@@ -466,7 +466,7 @@ - snprintf(cmd, MAXPGPATH, "exec \"%s\" %s%s < \"%s\" 2>&1", - exec_path, pgdata_opt, post_opts, DEVNULL); - -- (void) execl("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL); -+ (void) execl("@TERMUX_PREFIX@/bin/sh", "sh", "-c", cmd, (char *) NULL); - - /* exec failed */ - write_stderr(_("%s: could not start server: %s\n"), diff --git a/packages/postgresql/src-bin-pg_upgrade-check.c.patch b/packages/postgresql/src-bin-pg_upgrade-check.c.patch deleted file mode 100644 index ac482847b..000000000 --- a/packages/postgresql/src-bin-pg_upgrade-check.c.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff -u -r ../postgresql-9.6.2/src/bin/pg_upgrade/check.c ./src/bin/pg_upgrade/check.c ---- ../postgresql-9.6.2/src/bin/pg_upgrade/check.c 2017-02-06 22:45:25.000000000 +0100 -+++ ./src/bin/pg_upgrade/check.c 2017-03-05 14:47:58.793188439 +0100 -@@ -436,7 +436,7 @@ - - #ifndef WIN32 - /* add shebang header */ -- fprintf(script, "#!/bin/sh\n\n"); -+ fprintf(script, "#!@TERMUX_PREFIX@/bin/sh\n\n"); - #else - /* suppress command echoing */ - fprintf(script, "@echo off\n"); -@@ -564,7 +564,7 @@ - - #ifndef WIN32 - /* add shebang header */ -- fprintf(script, "#!/bin/sh\n\n"); -+ fprintf(script, "#!@TERMUX_PREFIX@/bin/sh\n\n"); - #endif - - /* delete old cluster's default tablespace */ diff --git a/packages/postgresql/src-bin-psql-command.c.patch b/packages/postgresql/src-bin-psql-command.c.patch deleted file mode 100644 index d1ef3af02..000000000 --- a/packages/postgresql/src-bin-psql-command.c.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff -u -r ../postgresql-9.6.2/src/bin/psql/command.c ./src/bin/psql/command.c ---- ../postgresql-9.6.2/src/bin/psql/command.c 2017-02-06 22:45:25.000000000 +0100 -+++ ./src/bin/psql/command.c 2017-03-05 15:33:33.579755248 +0100 -@@ -2258,7 +2258,7 @@ - const char *tmpdir = getenv("TMPDIR"); - - if (!tmpdir) -- tmpdir = "/tmp"; -+ tmpdir = "@TERMUX_PREFIX@/tmp"; - #else - char tmpdir[MAXPGPATH]; - int ret; -@@ -3076,7 +3076,7 @@ - - - #ifndef WIN32 --#define DEFAULT_SHELL "/bin/sh" -+#define DEFAULT_SHELL "@TERMUX_PREFIX@/bin/sh" - #else - /* - * CMD.EXE is in different places in different Win32 releases so we diff --git a/packages/postgresql/src-include-pg_config_manual.h.patch b/packages/postgresql/src-include-pg_config_manual.h.patch deleted file mode 100644 index ddf254e07..000000000 --- a/packages/postgresql/src-include-pg_config_manual.h.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- ./src/include/pg_config_manual.h.orig 2020-09-21 22:47:36.000000000 +0200 -+++ ./src/include/pg_config_manual.h 2020-10-18 10:17:39.656801301 +0200 -@@ -13,6 +13,8 @@ - *------------------------------------------------------------------------ - */ - -+#include -+ - /* - * This is the default value for wal_segment_size to be used when initdb is run - * without the --wal-segsize option. It must be a valid segment size. -@@ -203,8 +205,12 @@ - #ifndef WIN32 - #define DEFAULT_PGSOCKET_DIR "/tmp" - #else -+#ifdef _PATH_TMP -+#define DEFAULT_PGSOCKET_DIR _PATH_TMP -+#else - #define DEFAULT_PGSOCKET_DIR "" - #endif -+#endif - - /* - * This is the default event source for Windows event log.