Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 461736

Summary: dev-db/postgresql-server-9.2.3-r1 uses incorrect paths for the datadir/config files when ROOT is not /
Product: Gentoo Linux Reporter: smkbot
Component: [OLD] DevelopmentAssignee: PgSQL Bugs <pgsql-bugs>
Status: UNCONFIRMED ---    
Severity: normal CC: smkbot
Priority: Normal Keywords: PATCH
Version: autobuilds   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: bug.461736.patch

Description smkbot 2013-03-14 16:51:33 UTC
When installing dev-db/postgresql-server with ROOT=/somewhere, the config files and datadir are setup in /etc and /var/lib instead of /somewhere/etc and /somewhere/var/lib.

Reproducible: Always

Steps to Reproduce:
1. ROOT=/somewhere emerge postgresql-server eselect-postgresql
2. ROOT=/somewhere emerge --config postgresql-server

Actual Results:  
machine / # ls -l {,/somewhere}{/var/lib/postgresql/9.2/data/,/etc/postgresql-9.2}
ls: cannot access /somewhere/var/lib/postgresql/9.2/data/: No such file or directory
ls: cannot access /somewhere/etc/postgresql-9.2: No such file or directory

/etc/postgresql-9.2:
total 32
-rw------- 1 postgres postgres  4476 Mar 13 14:49 pg_hba.conf
-rw------- 1 postgres postgres  1636 Mar 13 14:49 pg_ident.conf
-rw------- 1 postgres postgres 19624 Mar 13 14:49 postgresql.conf

/var/lib/postgresql/9.2/data/:
total 52
drwx------ 5 postgres postgres 4096 Mar 13 14:49 base
drwx------ 2 postgres postgres 4096 Mar 13 14:49 global
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_clog
drwx------ 4 postgres postgres 4096 Mar 13 14:49 pg_multixact
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_notify
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_serial
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_snapshots
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_subtrans
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_tblspc
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_twophase
-rw------- 1 postgres postgres    4 Mar 13 14:49 PG_VERSION
drwx------ 3 postgres postgres 4096 Mar 13 14:49 pg_xlog


Expected Results:  
machine / # ls -l {,/somewhere}{/var/lib/postgresql/9.2/data/,/etc/postgresql-9.2}
ls: cannot access /var/lib/postgresql/9.2/data/: No such file or directory
ls: cannot access /etc/postgresql-9.2: No such file or directory

/somewhere/etc/postgresql-9.2:
total 32
-rw------- 1 postgres postgres  4476 Mar 13 14:49 pg_hba.conf
-rw------- 1 postgres postgres  1636 Mar 13 14:49 pg_ident.conf
-rw------- 1 postgres postgres 19624 Mar 13 14:49 postgresql.conf

/somewhere/var/lib/postgresql/9.2/data/:
total 52
drwx------ 5 postgres postgres 4096 Mar 13 14:49 base
drwx------ 2 postgres postgres 4096 Mar 13 14:49 global
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_clog
drwx------ 4 postgres postgres 4096 Mar 13 14:49 pg_multixact
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_notify
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_serial
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_snapshots
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_subtrans
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_tblspc
drwx------ 2 postgres postgres 4096 Mar 13 14:49 pg_twophase
-rw------- 1 postgres postgres    4 Mar 13 14:49 PG_VERSION
drwx------ 3 postgres postgres 4096 Mar 13 14:49 pg_xlog


I'm using the following patch to correct this:

Patch for postgresql-server-9.2.3-r1.ebuild:

diff --git a/dev-db/postgresql-server/postgresql-server-9.2.3-r1.ebuild b/dev-db/postgresql-server/postgresql-server-9.2.3-r1.ebuild
index ff9df97..3b23836 100644
--- a/dev-db/postgresql-server/postgresql-server-9.2.3-r1.ebuild
+++ b/dev-db/postgresql-server/postgresql-server-9.2.3-r1.ebuild
@@ -197,6 +197,12 @@ pkg_postrm() {
 
 pkg_config() {
        [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+ if [ "${PGDATA}" != "" ]; then
+         PGDATA="${EROOT%/}${PGDATA}"
+ fi
+ if [ "${DATA_DIR}" != "" ]; then
+         DATA_DIR="${EROOT%/}${DATA_DIR}"
+ fi
        [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
        [[ -z "${DATA_DIR}" ]] && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
Comment 1 Tom Wijsman (TomWij) (RETIRED) gentoo-dev 2013-03-15 18:58:01 UTC
Created attachment 342154 [details]
bug.461736.patch

Attached your patch.