GoboLinux Downloads Documentation Community Recipes Screenshots

GoboLinux Recipe & Package Search Tool

15 versions of PostgreSQL.

ProgramAgeSizeByWWWSummary
PostgreSQL 9.6.4-r1 654  3175 Hish...
PostgreSQL - the Database
PostgreSQL 9.6.1-r5 834  3150 Ivan
PostgreSQL - the Database
view entry at GitHub | download recipe.bz2 file
01-system_index.patch
Recipe
Resources/BuildInformation
Resources/Dependencies
Resources/Description
Resources/Environment
Resources/Tasks/PostgreSQL
PostgreSQL has a built-in relocation code to support varied installation paths.
At runtime, lookup of extensions and other executables is performed by taking
the absolute/real path of the calling program, and then walking up the directory
structure to determine the lookup path. For example, extensions of a PostgreSQL
instance launched by /opt/postgresql/bin/postgres would be searched under
/opt/postgresql/bin/../share/postgresql/extensions.

The aforementioned relocation scheme works perfectly fine if both PostgreSQL
and all subsequent extensions are installed under the same prefix. Projects
such as GoboLinux, however, install them under different prefixes (such as
/Programs/PostgreSQL and /Programs/PostGIS), resulting in lookup problems
when the relocation code path is taken.

This patch disables the relocation code so that PostgreSQL is able to find
extensions on said projects and also introduces a GoboLinux specific change
that causes lookups on /Programs/PostgreSQL/<version> to be redirected to
the multiplexed /System/Index tree.

Signed-off-by: Lucas C. Villa Real <lucasvr@gobolinux.org>

--- postgresql-9.6.1/src/port/path.c.orig	2017-03-22 21:03:50.220969341 -0300
+++ postgresql-9.6.1/src/port/path.c	2017-03-22 22:14:35.471048984 -0300
@@ -539,6 +539,9 @@ static void
 make_relative_path(char *ret_path, const char *target_path,
 				   const char *bin_path, const char *my_exec_path)
 {
+#if 1
+	strncpy(ret_path, target_path, MAXPGPATH-1);
+#else
 	int			prefix_len;
 	int			tail_start;
 	int			tail_len;
@@ -586,6 +589,7 @@ make_relative_path(char *ret_path, const
 no_match:
 	strlcpy(ret_path, target_path, MAXPGPATH);
 	canonicalize_path(ret_path);
+#endif
 }
 
 
--- postgresql-9.6.1/src/common/exec.c.orig	2017-03-22 23:20:47.166123496 -0300
+++ postgresql-9.6.1/src/common/exec.c	2017-03-22 23:13:23.057115164 -0300
@@ -203,6 +203,39 @@ find_my_exec(const char *argv0, char *re
 	return -1;
 }
 
+/*
+ * to_system_index - converts an absolute path under /Programs/PostgreSQL
+ * into its symbolic link on /System/Index.
+ */
+static int
+to_system_index(char *path)
+{
+	if (strstr(path, "/Programs/PostgreSQL/") == path)
+	{
+		/*
+		 * Use the multiplexed /System/Index tree rather than /Programs.
+		 * This fixes access to extensions installed under other programs'
+		 * share/postgresql/extensions.
+		 */
+		size_t pgsql = strlen("/Programs/PostgreSQL/");
+		char *pstart = &path[pgsql+1];
+		char *pslash = strchr(pstart, '/');
+		if (pslash)
+		{
+			struct stat statbuf;
+			char *path_copy = strdup(path);
+			size_t sysindexlen = strlen("/System/Index");
+			sprintf(path, "/System/Index");
+			memmove(&path[sysindexlen], pslash, strlen(pslash));
+			path[sysindexlen+strlen(pslash)] = '\0';
+			if (stat(path, &statbuf) != 0)
+				/* Rollback */
+				strcpy(path, path_copy);
+			free(path_copy);
+		}
+	}
+	return 0;
+}
 
 /*
  * resolve_symlinks - resolve symlinks to the underlying file
@@ -295,7 +328,7 @@ resolve_symlinks(char *path)
 	}
 #endif   /* HAVE_READLINK */
 
-	return 0;
+	return to_system_index(path);
 }
 
 
PostgreSQL 9.1.4-r1 2529  1778 Luca...
PostgreSQL - the Database
PostgreSQL 8.3.14-r1 3073  1768 Luca...
PostgreSQL - the Database
PostgreSQL 8.3.11-r1 3212  1788 Fabi...
PostgreSQL - the Database
PostgreSQL 8.3.9-r1 3419  1808 RedU...
PostgreSQL - the Database
PostgreSQL 8.3.4-r1 3791  1808 Fabi...
PostgreSQL - the Database
PostgreSQL 8.3.1-r1 3791  1821 Demi...
PostgreSQL - the Database
PostgreSQL 8.2.11-r1 3791  1839 Fabi...
PostgreSQL - the Database
PostgreSQL 8.2.10-r1 3791  1745 Magl...
PostgreSQL - the Database
PostgreSQL 8.2.9-r1 3791  1805 Fabi...
PostgreSQL - the Database
PostgreSQL 8.2.4-r1 3791  1802 Hish...
PostgreSQL - the Database
PostgreSQL 8.1.0-r2 3791  1724 Magl...
PostgreSQL - the Database
PostgreSQL 8.0.3-r1 3791  1126 Rafa...
PostgreSQL - the Database
PostgreSQL 7.4.3-r1 3791  1101
PostgreSQL - the Database