summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /dev-db/postgresql/files
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'dev-db/postgresql/files')
-rw-r--r--dev-db/postgresql/files/pg_ctl-exit-status.patch12
-rw-r--r--dev-db/postgresql/files/postgresql-9.0-no-server.patch135
-rw-r--r--dev-db/postgresql/files/postgresql-9.1-no-server.patch141
-rw-r--r--dev-db/postgresql/files/postgresql-9.1-tz-dir-overflow.patch29
-rw-r--r--dev-db/postgresql/files/postgresql-9.2-9.4-tz-dir-overflow.patch16
-rw-r--r--dev-db/postgresql/files/postgresql-9.2-no-server.patch143
-rw-r--r--dev-db/postgresql/files/postgresql-9.3-no-server.patch148
-rw-r--r--dev-db/postgresql/files/postgresql-9.4-no-server.patch151
-rw-r--r--dev-db/postgresql/files/postgresql-9.5-no-server.patch152
-rw-r--r--dev-db/postgresql/files/postgresql-check-db-dir36
-rw-r--r--dev-db/postgresql/files/postgresql.confd58
-rw-r--r--dev-db/postgresql/files/postgresql.init138
-rw-r--r--dev-db/postgresql/files/postgresql.init-9.3143
-rw-r--r--dev-db/postgresql/files/postgresql.init-pre_9.2140
-rw-r--r--dev-db/postgresql/files/postgresql.service51
-rw-r--r--dev-db/postgresql/files/postgresql.tmpfilesd1
16 files changed, 1494 insertions, 0 deletions
diff --git a/dev-db/postgresql/files/pg_ctl-exit-status.patch b/dev-db/postgresql/files/pg_ctl-exit-status.patch
new file mode 100644
index 000000000000..bbbd4498555d
--- /dev/null
+++ b/dev-db/postgresql/files/pg_ctl-exit-status.patch
@@ -0,0 +1,12 @@
+diff -Naur a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
+--- a/src/bin/pg_ctl/pg_ctl.c 2011-04-14 23:18:15 -0400
++++ b/src/bin/pg_ctl/pg_ctl.c 2011-08-01 19:44:54 -0400
+@@ -975,7 +975,7 @@
+ }
+ }
+ printf(_("%s: no server running\n"), progname);
+- exit(1);
++ exit(3);
+ }
+
+
diff --git a/dev-db/postgresql/files/postgresql-9.0-no-server.patch b/dev-db/postgresql/files/postgresql-9.0-no-server.patch
new file mode 100644
index 000000000000..1b45cd954c5e
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.0-no-server.patch
@@ -0,0 +1,135 @@
+diff -Naur a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2011-02-02 07:37:16.654175660 -0500
++++ b/contrib/Makefile 2011-02-08 05:54:00.145582001 -0500
+@@ -5,51 +5,10 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- earthdistance \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_archivecleanup \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_standby \
+- pg_stat_statements \
+- pg_trgm \
+- pg_upgrade \
+- pg_upgrade_support \
+ pgbench \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- seg \
+- spi \
+- tablefunc \
+- test_parser \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-endif
+-
+ ifeq ($(with_ossp_uuid),yes)
+ SUBDIRS += uuid-ossp
+ endif
+diff -Naur a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2011-02-02 07:37:56.403870592 -0500
++++ b/src/backend/Makefile 2011-02-08 05:57:26.078497002 -0500
+@@ -45,7 +45,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -114,7 +114,7 @@
+ endif # aix
+
+ # Update the commonly used headers before building the subdirectories
+-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h
++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h
+
+ # run this unconditionally to avoid needing to know its dependencies here:
+ submake-schemapg:
+@@ -191,23 +191,7 @@
+
+ ##########################################################################
+
+-install: all installdirs install-bin
+-ifeq ($(PORTNAME), cygwin)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+-ifeq ($(PORTNAME), win32)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+- $(MAKE) -C catalog install-data
+- $(MAKE) -C tsearch install-data
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
++install:
+
+ install-bin: postgres $(POSTGRES_IMP) installdirs
+ $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
+diff -Naur a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2011-02-02 07:38:35.133570047 -0500
++++ b/src/bin/Makefile 2011-02-08 05:58:48.819847001 -0500
+@@ -13,8 +13,7 @@
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+
+-SUBDIRS = initdb pg_ctl pg_dump \
+- psql scripts pg_config pg_controldata pg_resetxlog
++SUBDIRS = pg_dump psql scripts pg_config
+ ifeq ($(PORTNAME), win32)
+ SUBDIRS+=pgevent
+ endif
+diff -Naur a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2011-02-02 07:37:56.283870942 -0500
++++ b/src/Makefile 2011-02-08 06:00:51.591202002 -0500
+@@ -15,17 +15,11 @@
+
+ all install installdirs uninstall distprep:
+ $(MAKE) -C port $@
+- $(MAKE) -C timezone $@
+ $(MAKE) -C backend $@
+- $(MAKE) -C backend/utils/mb/conversion_procs $@
+- $(MAKE) -C backend/snowball $@
+ $(MAKE) -C include $@
+ $(MAKE) -C interfaces $@
+- $(MAKE) -C backend/replication/libpqwalreceiver $@
+ $(MAKE) -C bin $@
+- $(MAKE) -C pl $@
+ $(MAKE) -C makefiles $@
+- $(MAKE) -C test/regress $@
+
+ install: install-local
+
diff --git a/dev-db/postgresql/files/postgresql-9.1-no-server.patch b/dev-db/postgresql/files/postgresql-9.1-no-server.patch
new file mode 100644
index 000000000000..64363a0f4112
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.1-no-server.patch
@@ -0,0 +1,141 @@
+diff -Naur a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2011-09-08 17:13:27.000000000 -0400
++++ b/contrib/Makefile 2011-09-16 21:58:34.080579316 -0400
+@@ -5,56 +5,10 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- dummy_seclabel \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_archivecleanup \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_standby \
+- pg_stat_statements \
+- pg_test_fsync \
+- pg_trgm \
+- pg_upgrade \
+- pg_upgrade_support \
+ pgbench \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- seg \
+- spi \
+- tablefunc \
+- test_parser \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+
+ ifeq ($(with_ossp_uuid),yes)
+ SUBDIRS += uuid-ossp
+diff -Naur a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2011-09-08 17:13:27.000000000 -0400
++++ b/src/backend/Makefile 2011-09-16 22:01:48.400579314 -0400
+@@ -45,7 +45,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -114,7 +114,7 @@
+ endif # aix
+
+ # Update the commonly used headers before building the subdirectories
+-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
+
+ # run this unconditionally to avoid needing to know its dependencies here:
+ submake-schemapg:
+@@ -206,23 +206,7 @@
+
+ ##########################################################################
+
+-install: all installdirs install-bin
+-ifeq ($(PORTNAME), cygwin)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+-ifeq ($(PORTNAME), win32)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+- $(MAKE) -C catalog install-data
+- $(MAKE) -C tsearch install-data
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
++install:
+
+ install-bin: postgres $(POSTGRES_IMP) installdirs
+ $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
+diff -Naur a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2011-09-08 17:13:27.000000000 -0400
++++ b/src/bin/Makefile 2011-09-16 22:03:48.250579314 -0400
+@@ -13,8 +13,7 @@
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+
+-SUBDIRS = initdb pg_ctl pg_dump \
+- psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup
++SUBDIRS = pg_dump psql scripts pg_config
+
+ ifeq ($(PORTNAME), win32)
+ SUBDIRS += pgevent
+diff -Naur a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2011-09-08 17:13:27.000000000 -0400
++++ b/src/Makefile 2011-09-16 22:29:17.650579302 -0400
+@@ -14,17 +14,11 @@
+
+ SUBDIRS = \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ bin \
+- pl \
+- makefiles \
+- test/regress
++ makefiles
+
+ # There are too many interdependencies between the subdirectories, so
+ # don't attempt parallel make here.
diff --git a/dev-db/postgresql/files/postgresql-9.1-tz-dir-overflow.patch b/dev-db/postgresql/files/postgresql-9.1-tz-dir-overflow.patch
new file mode 100644
index 000000000000..9d12c57ecc3a
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.1-tz-dir-overflow.patch
@@ -0,0 +1,29 @@
+--- a/src/timezone/pgtz.c 2015-02-02 15:45:23.000000000 -0500
++++ b/src/timezone/pgtz.c 2015-04-07 14:21:22.341832190 -0400
+@@ -586,6 +586,12 @@
+ if (direntry->d_name[0] == '.')
+ continue;
+
++ /* if current working directory has the same name as current direntry name,
++ * then skip as this is a recursive fs loop
++ */
++ if (strncmp(direntry->d_name,tzdirsub,strlen(direntry->d_name)) == 0)
++ continue;
++
+ snprintf(tzdir + tzdir_orig_len, MAXPGPATH - tzdir_orig_len,
+ "/%s", direntry->d_name);
+
+@@ -1615,6 +1621,13 @@
+ if (direntry->d_name[0] == '.')
+ continue;
+
++ /* copy current working directory so that there is no risk of modification by basename(),
++ * and compare to current direntry name; skip if they are the same as this is a recursive fs loop
++ */
++ snprintf(fullname, MAXPGPATH, "%s", dir->dirname[dir->depth]);
++ if (strncmp(direntry->d_name,basename(fullname),strlen(direntry->d_name)) == 0)
++ continue;
++
+ snprintf(fullname, MAXPGPATH, "%s/%s",
+ dir->dirname[dir->depth], direntry->d_name);
+ if (stat(fullname, &statbuf) != 0)
diff --git a/dev-db/postgresql/files/postgresql-9.2-9.4-tz-dir-overflow.patch b/dev-db/postgresql/files/postgresql-9.2-9.4-tz-dir-overflow.patch
new file mode 100644
index 000000000000..59e43c5384e7
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.2-9.4-tz-dir-overflow.patch
@@ -0,0 +1,16 @@
+--- a/src/timezone/pgtz.c 2015-02-02 15:45:23.000000000 -0500
++++ b/src/timezone/pgtz.c 2015-04-07 14:21:22.341832190 -0400
+@@ -1615,6 +1615,13 @@
+ if (direntry->d_name[0] == '.')
+ continue;
+
++ /* copy current working directory so that there is no risk of modification by basename(),
++ * and compare to current direntry name; skip if they are the same as this is a recursive fs loop
++ */
++ snprintf(fullname, MAXPGPATH, "%s", dir->dirname[dir->depth]);
++ if (strncmp(direntry->d_name,basename(fullname),strlen(direntry->d_name)) == 0)
++ continue;
++
+ snprintf(fullname, MAXPGPATH, "%s/%s",
+ dir->dirname[dir->depth], direntry->d_name);
+ if (stat(fullname, &statbuf) != 0)
diff --git a/dev-db/postgresql/files/postgresql-9.2-no-server.patch b/dev-db/postgresql/files/postgresql-9.2-no-server.patch
new file mode 100644
index 000000000000..a0c33efc63ae
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.2-no-server.patch
@@ -0,0 +1,143 @@
+diff -Naur a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2012-05-10 18:35:09.000000000 -0400
++++ b/contrib/Makefile 2012-05-20 09:33:47.892622992 -0400
+@@ -5,58 +5,10 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- dummy_seclabel \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_archivecleanup \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_standby \
+- pg_stat_statements \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_trgm \
+- pg_upgrade \
+- pg_upgrade_support \
+ pgbench \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_parser \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+
+ ifeq ($(with_ossp_uuid),yes)
+ SUBDIRS += uuid-ossp
+diff -Naur a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2012-05-10 18:35:09.000000000 -0400
++++ b/src/backend/Makefile 2012-05-20 09:36:24.446654842 -0400
+@@ -45,7 +45,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -114,7 +114,7 @@
+ endif # aix
+
+ # Update the commonly used headers before building the subdirectories
+-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
+
+ # run this unconditionally to avoid needing to know its dependencies here:
+ submake-schemapg:
+@@ -207,23 +207,7 @@
+
+ ##########################################################################
+
+-install: all installdirs install-bin
+-ifeq ($(PORTNAME), cygwin)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+-ifeq ($(PORTNAME), win32)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+- $(MAKE) -C catalog install-data
+- $(MAKE) -C tsearch install-data
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
++install:
+
+ install-bin: postgres $(POSTGRES_IMP) installdirs
+ $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
+diff -Naur a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2012-05-10 18:35:09.000000000 -0400
++++ b/src/bin/Makefile 2012-05-20 09:41:18.489958216 -0400
+@@ -13,8 +13,7 @@
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+
+-SUBDIRS = initdb pg_ctl pg_dump \
+- psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup
++SUBDIRS = pg_dump psql scripts pg_config
+
+ ifeq ($(PORTNAME), win32)
+ SUBDIRS += pgevent
+diff -Naur a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2012-05-10 18:35:09.000000000 -0400
++++ b/src/Makefile 2012-05-20 09:40:13.532774840 -0400
+@@ -14,17 +14,11 @@
+
+ SUBDIRS = \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ bin \
+- pl \
+- makefiles \
+- test/regress
++ makefiles
+
+ # There are too many interdependencies between the subdirectories, so
+ # don't attempt parallel make here.
diff --git a/dev-db/postgresql/files/postgresql-9.3-no-server.patch b/dev-db/postgresql/files/postgresql-9.3-no-server.patch
new file mode 100644
index 000000000000..3ce90d60ae70
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.3-no-server.patch
@@ -0,0 +1,148 @@
+diff -Naur a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/contrib/Makefile 2013-06-09 01:48:22.351874929 +0000
+@@ -5,61 +5,10 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- dummy_seclabel \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_archivecleanup \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_standby \
+- pg_stat_statements \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_trgm \
+- pg_upgrade \
+- pg_upgrade_support \
+ pgbench \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- pg_xlogdump \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_parser \
+- tsearch2 \
+- unaccent \
+- vacuumlo \
+- worker_spi
++ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+
+ ifeq ($(with_ossp_uuid),yes)
+ SUBDIRS += uuid-ossp
+diff -Naur a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/backend/Makefile 2013-06-09 01:50:19.655864258 +0000
+@@ -47,7 +47,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -116,7 +116,7 @@
+ endif # aix
+
+ # Update the commonly used headers before building the subdirectories
+-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
+
+ # run this unconditionally to avoid needing to know its dependencies here:
+ submake-schemapg:
+@@ -209,23 +209,8 @@
+
+ ##########################################################################
+
+-install: all installdirs install-bin
+-ifeq ($(PORTNAME), cygwin)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+-ifeq ($(PORTNAME), win32)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+- $(MAKE) -C catalog install-data
+- $(MAKE) -C tsearch install-data
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
++install:
++
+
+ install-bin: postgres $(POSTGRES_IMP) installdirs
+ $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
+diff -Naur a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/bin/Makefile 2013-06-09 01:51:56.143824442 +0000
+@@ -13,8 +13,7 @@
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+
+-SUBDIRS = initdb pg_ctl pg_dump \
+- psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup
++SUBDIRS = pg_dump psql scripts pg_config
+
+ ifeq ($(PORTNAME), win32)
+ SUBDIRS += pgevent
+diff -Naur a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/Makefile 2013-06-09 01:54:30.479704228 +0000
+@@ -15,17 +15,11 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ bin \
+- pl \
+- makefiles \
+- test/regress
++ makefiles
+
+ # There are too many interdependencies between the subdirectories, so
+ # don't attempt parallel make here.
diff --git a/dev-db/postgresql/files/postgresql-9.4-no-server.patch b/dev-db/postgresql/files/postgresql-9.4-no-server.patch
new file mode 100644
index 000000000000..c46146e5ec9e
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.4-no-server.patch
@@ -0,0 +1,151 @@
+diff -Naur a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/contrib/Makefile 2013-06-09 01:48:22.351874929 +0000
+@@ -5,64 +5,10 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- dummy_seclabel \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_archivecleanup \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_trgm \
+- pg_upgrade \
+- pg_upgrade_support \
+ pgbench \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- pg_xlogdump \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- test_parser \
+- test_shm_mq \
+- tsearch2 \
+- unaccent \
+- vacuumlo \
+- worker_spi
++ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+
+ ifeq ($(with_ossp_uuid),yes)
+ SUBDIRS += uuid-ossp
+diff -Naur a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/backend/Makefile 2013-06-09 01:50:19.655864258 +0000
+@@ -47,7 +47,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -116,7 +116,7 @@
+ endif # aix
+
+ # Update the commonly used headers before building the subdirectories
+-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
+
+ # run this unconditionally to avoid needing to know its dependencies here:
+ submake-schemapg:
+@@ -209,23 +209,8 @@
+
+ ##########################################################################
+
+-install: all installdirs install-bin
+-ifeq ($(PORTNAME), cygwin)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+-ifeq ($(PORTNAME), win32)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+- $(MAKE) -C catalog install-data
+- $(MAKE) -C tsearch install-data
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
++install:
++
+
+ install-bin: postgres $(POSTGRES_IMP) installdirs
+ $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
+diff -Naur a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/bin/Makefile 2013-06-09 01:51:56.143824442 +0000
+@@ -13,8 +13,7 @@
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+
+-SUBDIRS = initdb pg_ctl pg_dump \
+- psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup
++SUBDIRS = pg_dump psql scripts pg_config
+
+ ifeq ($(PORTNAME), win32)
+ SUBDIRS += pgevent
+diff -Naur a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/Makefile 2013-06-09 01:54:30.479704228 +0000
+@@ -15,17 +15,11 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ bin \
+- pl \
+- makefiles \
+- test/regress
++ makefiles
+
+ # There are too many interdependencies between the subdirectories, so
+ # don't attempt parallel make here.
diff --git a/dev-db/postgresql/files/postgresql-9.5-no-server.patch b/dev-db/postgresql/files/postgresql-9.5-no-server.patch
new file mode 100644
index 000000000000..1a12d5b820b2
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.5-no-server.patch
@@ -0,0 +1,152 @@
+diff --git a/contrib/Makefile b/contrib/Makefile
+index b37d0dd..b56fbf6 100644
+--- a/contrib/Makefile
++++ b/contrib/Makefile
+@@ -5,64 +5,9 @@ top_builddir = ..
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- dummy_seclabel \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_archivecleanup \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_trgm \
+- pg_upgrade \
+- pg_upgrade_support \
+ pgbench \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- pg_xlogdump \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- test_parser \
+- test_shm_mq \
+- tsearch2 \
+- unaccent \
+- vacuumlo \
+- worker_spi
+-
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
++ vacuumlo
+
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+diff -Naur a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/backend/Makefile 2013-06-09 01:50:19.655864258 +0000
+@@ -47,7 +47,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -116,7 +116,7 @@
+ endif # aix
+
+ # Update the commonly used headers before building the subdirectories
+-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
+
+ # run this unconditionally to avoid needing to know its dependencies here:
+ submake-schemapg:
+@@ -209,23 +209,8 @@
+
+ ##########################################################################
+
+-install: all installdirs install-bin
+-ifeq ($(PORTNAME), cygwin)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+-ifeq ($(PORTNAME), win32)
+-ifeq ($(MAKE_DLL), true)
+- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+-endif
+-endif
+- $(MAKE) -C catalog install-data
+- $(MAKE) -C tsearch install-data
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
+- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
++install:
++
+
+ install-bin: postgres $(POSTGRES_IMP) installdirs
+ $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
+diff -Naur a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/bin/Makefile 2013-06-09 01:51:56.143824442 +0000
+@@ -13,8 +13,7 @@
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+
+-SUBDIRS = initdb pg_ctl pg_dump \
+- psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup
++SUBDIRS = pg_dump psql scripts pg_config
+
+ ifeq ($(PORTNAME), win32)
+ SUBDIRS += pgevent
+diff -Naur a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2013-05-06 20:57:06.000000000 +0000
++++ b/src/Makefile 2013-06-09 01:54:30.479704228 +0000
+@@ -15,17 +15,11 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ bin \
+- pl \
+- makefiles \
+- test/regress
++ makefiles
+
+ # There are too many interdependencies between the subdirectories, so
+ # don't attempt parallel make here.
diff --git a/dev-db/postgresql/files/postgresql-check-db-dir b/dev-db/postgresql/files/postgresql-check-db-dir
new file mode 100644
index 000000000000..861b398e5032
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-check-db-dir
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+eerror() {
+ echo "$@" >&2
+}
+
+# Check that DATA_DIR has been set
+if [ -z ${DATA_DIR} ] ; then
+ eerror "DATA_DIR not set"
+ exit 1
+fi
+
+# Check that DATA_DIR exists
+if [ ! -d ${DATA_DIR} ] ; then
+ eerror "Directory not found: ${DATA_DIR}"
+ eerror "HINT: Ensure that DATA_DIR points to the right path."
+ eerror "HINT: Or perhaps you need to create the database cluster:"
+ eerror " emerge --config dev-db/postgresql:@SLOT@"
+ exit 1
+fi
+
+# Check for the existence of PostgreSQL's config files, and set the
+# proper mode and ownership.
+# Only three files should be checked as potentially other files
+# may be in PGDATA that should not be touched.
+for file in postgresql pg_hba pg_ident ; do
+ file="${PGDATA%/}/${file}.conf"
+ if [ ! -f ${file} ] ; then
+ eerror "${file} not found"
+ eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
+ exit 1
+ fi
+done
diff --git a/dev-db/postgresql/files/postgresql.confd b/dev-db/postgresql/files/postgresql.confd
new file mode 100644
index 000000000000..07b465d9b61a
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.confd
@@ -0,0 +1,58 @@
+# Which port and socket to bind PostgreSQL
+PGPORT="5432"
+
+# How long to wait for server to start in seconds
+START_TIMEOUT=10
+
+# NICE_QUIT ignores new connections and wait for clients to disconnect from
+# server before shutting down. NICE_TIMEOUT in seconds determines how long to
+# wait for this to succeed.
+NICE_TIMEOUT=60
+
+# Forecfully disconnect clients from server and shut down. This is performed
+# after NICE_QUIT. Terminated client connections have their open transactions
+# rolled back.
+# Set RUDE_QUIT to "NO" to disable. RUDE_TIMEOUT in seconds.
+RUDE_QUIT="YES"
+RUDE_TIMEOUT=30
+
+# If the server still fails to shutdown, you can force it to quit by setting
+# this to YES and a recover-run will execute on the next startup.
+# Set FORCE_QUIT to "YES" to enable. FORCE_TIMEOUT in seconds.
+FORCE_QUIT="NO"
+FORCE_TIMEOUT=2
+
+# Extra options to run postmaster with, e.g.:
+# -N is the maximal number of client connections
+# -B is the number of shared buffers and has to be at least 2x the value for -N
+# Please read the man-page to postmaster for more options. Many of these
+# options can be set directly in the configuration file.
+#PGOPTS="-N 512 -B 1024"
+
+# Pass extra environment variables. If you have to export environment variables
+# for the database process, this can be done here.
+# Don't forget to escape quotes.
+#PG_EXTRA_ENV="PGPASSFILE=\"/path/to/.pgpass\""
+
+##############################################################################
+#
+# The following values should not be arbitrarily changed.
+#
+# `emerge --config dev-db/postgresql:@SLOT@' uses these values to
+# determine where to create the data directory, where to place the
+# configuration files, and any additional options to pass to initdb.
+#
+# The initscript also uses these variables to inform PostgreSQL where to find
+# its data directory and configuration files.
+#
+##############################################################################
+
+# Location of configuration files
+PGDATA="/etc/postgresql-@SLOT@/"
+
+# Where the data directory is located/to be created
+DATA_DIR="/var/lib/postgresql/@SLOT@/data"
+
+# Additional options to pass to initdb.
+# See `man initdb' for available options.
+PG_INITDB_OPTS="--encoding=UTF8"
diff --git a/dev-db/postgresql/files/postgresql.init b/dev-db/postgresql/files/postgresql.init
new file mode 100644
index 000000000000..5f07c4d545fc
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init
@@ -0,0 +1,138 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+extra_started_commands="reload"
+
+get_config() {
+ [ -f ${PGDATA%/}/postgresql.conf ] || return 1
+
+ eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \
+ | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
+}
+
+depend() {
+ use net
+ provide postgresql
+
+ if [ "$(get_config log_destination)" = "syslog" ]; then
+ use logger
+ fi
+}
+
+configured_port=$(get_config port)
+: ${configured_port:=${PGPORT}}
+socket_path=$(get_config unix_socket_directory)
+: ${socket_path:=/run/postgresql}
+
+checkconfig() {
+ # Check that DATA_DIR has been set
+ if [ -z ${DATA_DIR} ] ; then
+ eerror "DATA_DIR not set"
+ eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@"
+ return 1
+ fi
+
+ # Check that DATA_DIR exists
+ if [ ! -d ${DATA_DIR} ] ; then
+ eerror "Directory not found: ${DATA_DIR}"
+ eerror "HINT: Ensure that DATA_DIR points to the right path."
+ eerror "HINT: Or perhaps you need to create the database cluster:"
+ eerror " emerge --config dev-db/postgresql:@SLOT@"
+ return 1
+ fi
+
+ # Check for the existence of PostgreSQL's config files, and set the
+ # proper mode and ownership.
+ # Only three files should be checked as potentially other files
+ # may be in PGDATA that should not be touched.
+ local file
+ for file in postgresql pg_hba pg_ident ; do
+ file="${PGDATA%/}/${file}.conf"
+ if [ -f ${file} ] ; then
+ checkpath -f -m 0600 -o postgres:postgres ${file}
+ else
+ eerror "${file} not found"
+ eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
+ return 1
+ fi
+ done
+
+ # Set the proper permission for the socket path and create it if
+ # it doesn't exist.
+ checkpath -d -m 1775 -o postgres:postgres ${socket_path}
+ if [ -e ${socket_path%/}/.s.PGSQL.${configured_port} ] ; then
+ eerror "Socket conflict."
+ eerror "A server is already listening on:"
+ eerror " ${socket_path%/}/.s.PGSQL.${configured_port}"
+ eerror "HINT: Change PGPORT to listen on a different socket."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting PostgreSQL"
+
+ rm -f ${DATA_DIR%/}/postmaster.pid
+
+ local extraenv
+ local x
+ for x in ${PG_EXTRA_ENV} ; do
+ extraenv="${extraenv} --env ${x}"
+ done
+
+ start-stop-daemon --start \
+ --user postgres \
+ --env "PGPORT=${configured_port}" \
+ ${extraenv} \
+ --pidfile ${DATA_DIR%/}/postmaster.pid \
+ --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl \
+ -- start -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \
+ -D ${PGDATA} -o "--data-directory=${DATA_DIR} ${PGOPTS}"
+ local retval=$?
+
+ if [ $retval -ne 0 ] ; then
+ eerror "Check the log for a possible explanation of the above error. The log may be"
+ eerror " ${DATA_DIR%/}/postmaster.log"
+ eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent."
+ eend $retval
+ return $retval
+ fi
+
+ eend $retval
+}
+
+stop() {
+ local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
+ ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)"
+
+ local retval
+ local retries=SIGTERM/${NICE_TIMEOUT}
+
+ if [ "${RUDE_QUIT}" != "NO" ] ; then
+ einfo "RUDE_QUIT enabled."
+ retries="${retries}/SIGINT/${RUDE_TIMEOUT}"
+ fi
+ if [ "${FORCE_QUIT}" = "YES" ] ; then
+ einfo "FORCE_QUIT enabled."
+ ewarn "A recover-run might be executed on next startup."
+ retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}"
+ fi
+
+ # Loops through nice, rude, and force quit in one go.
+ start-stop-daemon --stop \
+ --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \
+ --retry ${retries} \
+ --pidfile ${DATA_DIR%/}/postmaster.pid
+
+ eend
+}
+
+reload() {
+ ebegin "Reloading PostgreSQL configuration"
+ kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid)
+ eend $?
+}
diff --git a/dev-db/postgresql/files/postgresql.init-9.3 b/dev-db/postgresql/files/postgresql.init-9.3
new file mode 100644
index 000000000000..1c797c19d683
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init-9.3
@@ -0,0 +1,143 @@
+#!/sbin/runscript
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+extra_started_commands="reload"
+
+get_config() {
+ [ -f ${PGDATA%/}/postgresql.conf ] || return 1
+
+ eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \
+ | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
+}
+
+depend() {
+ use net
+ provide postgresql
+
+ if [ "$(get_config log_destination)" = "syslog" ]; then
+ use logger
+ fi
+}
+
+configured_port=$(get_config port)
+: ${configured_port:=${PGPORT}}
+socket_paths=$(get_config unix_socket_directories)
+: ${socket_paths:=/run/postgresql}
+
+checkconfig() {
+ # Check that DATA_DIR has been set
+ if [ -z ${DATA_DIR} ] ; then
+ eerror "DATA_DIR not set"
+ eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@"
+ return 1
+ fi
+
+ # Check that DATA_DIR exists
+ if [ ! -d ${DATA_DIR} ] ; then
+ eerror "Directory not found: ${DATA_DIR}"
+ eerror "HINT: Ensure that DATA_DIR points to the right path."
+ eerror "HINT: Or perhaps you need to create the database cluster:"
+ eerror " emerge --config dev-db/postgresql:@SLOT@"
+ return 1
+ fi
+
+ # Check for the existence of PostgreSQL's config files, and set the
+ # proper mode and ownership.
+ # Only three files should be checked as potentially other files
+ # may be in PGDATA that should not be touched.
+ local file
+ for file in postgresql pg_hba pg_ident ; do
+ file="${PGDATA%/}/${file}.conf"
+ if [ -f ${file} ] ; then
+ checkpath -f -m 0600 -o postgres:postgres ${file}
+ else
+ eerror "${file} not found"
+ eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
+ return 1
+ fi
+ done
+
+ # Set the proper permission for the socket paths and create it if
+ # it doesn't exist.
+ set -f; IFS=','
+ local s
+ for s in ${socket_paths}; do
+ checkpath -d -m 1775 -o postgres:postgres ${s}
+ if [ -e ${s%/}/.s.PGSQL.${configured_port} ] ; then
+ eerror "Socket conflict."
+ eerror "A server is already listening on:"
+ eerror " ${s%/}/.s.PGSQL.${configured_port}"
+ eerror "HINT: Change PGPORT to listen on a different socket."
+ return 1
+ fi
+ done
+ set +f; unset IFS
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting PostgreSQL"
+
+ rm -f ${DATA_DIR%/}/postmaster.pid
+
+ local extraenv
+ local x
+ for x in ${PG_EXTRA_ENV} ; do
+ extraenv="${extraenv} --env ${x}"
+ done
+
+ start-stop-daemon --start \
+ --user postgres \
+ --env "PGPORT=${configured_port}" \
+ ${extraenv} \
+ --pidfile ${DATA_DIR%/}/postmaster.pid \
+ --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl \
+ -- start -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \
+ -D ${PGDATA} -o "--data-directory=${DATA_DIR} ${PGOPTS}"
+ local retval=$?
+
+ if [ $retval -ne 0 ] ; then
+ eerror "Check the log for a possible explanation of the above error. The log may be"
+ eerror " ${DATA_DIR%/}/postmaster.log"
+ eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent."
+ eend $retval
+ return $retval
+ fi
+
+ eend $retval
+}
+
+stop() {
+ local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
+ ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)"
+
+ local retval
+ local retries=SIGTERM/${NICE_TIMEOUT}
+
+ if [ "${RUDE_QUIT}" != "NO" ] ; then
+ einfo "RUDE_QUIT enabled."
+ retries="${retries}/SIGINT/${RUDE_TIMEOUT}"
+ fi
+ if [ "${FORCE_QUIT}" = "YES" ] ; then
+ einfo "FORCE_QUIT enabled."
+ ewarn "A recover-run might be executed on next startup."
+ retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}"
+ fi
+
+ # Loops through nice, rude, and force quit in one go.
+ start-stop-daemon --stop \
+ --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \
+ --retry ${retries} \
+ --pidfile ${DATA_DIR%/}/postmaster.pid
+
+ eend
+}
+
+reload() {
+ ebegin "Reloading PostgreSQL configuration"
+ kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid)
+ eend $?
+}
diff --git a/dev-db/postgresql/files/postgresql.init-pre_9.2 b/dev-db/postgresql/files/postgresql.init-pre_9.2
new file mode 100644
index 000000000000..c85c7075c74d
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init-pre_9.2
@@ -0,0 +1,140 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+extra_started_commands="reload"
+
+get_config() {
+ [ -f ${PGDATA%/}/postgresql.conf ] || return 1
+
+ eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \
+ | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
+}
+
+depend() {
+ use net
+ provide postgresql
+
+ if [ "$(get_config log_destination)" = "syslog" ]; then
+ use logger
+ fi
+}
+
+configured_port=$(get_config port)
+: ${configured_port:=${PGPORT}}
+socket_path=$(get_config unix_socket_directory)
+: ${socket_path:=/run/postgresql}
+
+checkconfig() {
+ # Check that DATA_DIR has been set
+ if [ -z ${DATA_DIR} ] ; then
+ eerror "DATA_DIR not set"
+ eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@"
+ return 1
+ fi
+
+ # Check that DATA_DIR exists
+ if [ ! -d ${DATA_DIR} ] ; then
+ eerror "Directory not found: ${DATA_DIR}"
+ eerror "HINT: Ensure that DATA_DIR points to the right path."
+ eerror "HINT: Or perhaps you need to create the database cluster:"
+ eerror " emerge --config dev-db/postgresql:@SLOT@"
+ return 1
+ fi
+
+ # Check for the existence of PostgreSQL's config files, and set the
+ # proper mode and ownership.
+ # Only three files should be checked as potentially other files
+ # may be in PGDATA that should not be touched.
+ local file
+ for file in postgresql pg_hba pg_ident ; do
+ file="${PGDATA%/}/${file}.conf"
+ if [ -f ${file} ] ; then
+ checkpath -f -m 0600 -o postgres:postgres ${file}
+ else
+ eerror "${file} not found"
+ eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
+ return 1
+ fi
+ done
+
+ # Set the proper permission for the socket path and create it if
+ # it doesn't exist.
+ checkpath -d -m 1775 -o postgres:postgres ${socket_path}
+ if [ -e ${socket_path%/}/.s.PGSQL.${configured_port} ] ; then
+ eerror "Socket conflict."
+ eerror "A server is already listening on:"
+ eerror " ${socket_path%/}/.s.PGSQL.${configured_port}"
+ eerror "HINT: Change PGPORT to listen on a different socket."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting PostgreSQL"
+
+ rm -f ${DATA_DIR%/}/postmaster.pid
+
+ local extraenv
+ local x
+ for x in ${PG_EXTRA_ENV} ; do
+ extraenv="${extraenv} --env ${x}"
+ done
+
+ start-stop-daemon --start \
+ --user postgres \
+ --env "PGPORT=${configured_port}" \
+ ${extraenv} \
+ --pidfile ${DATA_DIR%/}/postmaster.pid \
+ --wait $((${START_TIMEOUT}*1000)) \
+ --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \
+ -- -D ${PGDATA} --data-directory=${DATA_DIR} --silent-mode=true \
+ ${PGOPTS}
+
+ local retval=$?
+
+ if [ $retval -ne 0 ] ; then
+ eerror "Check the log for a possible explanation of the above error. The log may be"
+ eerror " ${DATA_DIR%/}/postmaster.log"
+ eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent."
+ eend $retval
+ return $retval
+ fi
+
+ eend $retval
+}
+
+stop() {
+ local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
+ ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)"
+
+ local retval
+ local retries=SIGTERM/${NICE_TIMEOUT}
+
+ if [ "${RUDE_QUIT}" != "NO" ] ; then
+ einfo "RUDE_QUIT enabled."
+ retries="${retries}/SIGINT/${RUDE_TIMEOUT}"
+ fi
+ if [ "${FORCE_QUIT}" = "YES" ] ; then
+ einfo "FORCE_QUIT enabled."
+ ewarn "A recover-run might be executed on next startup."
+ retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}"
+ fi
+
+ # Loops through nice, rude, and force quit in one go.
+ start-stop-daemon --stop \
+ --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \
+ --retry ${retries} \
+ --pidfile ${DATA_DIR%/}/postmaster.pid
+
+ eend
+}
+
+reload() {
+ ebegin "Reloading PostgreSQL configuration"
+ kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid)
+ eend $?
+}
diff --git a/dev-db/postgresql/files/postgresql.service b/dev-db/postgresql/files/postgresql.service
new file mode 100644
index 000000000000..20ed27a10f29
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.service
@@ -0,0 +1,51 @@
+# It's not recommended to modify this file in-place, because it will be
+# overwritten during package upgrades. If you want to customize, the
+# best way is to create file
+# "/etc/systemd/system/postgresql-@SLOT@.service.d/*.conf"
+# containing your changes
+
+# For example, if you want to change the server's port number to 5433,
+# create a file named
+# "/etc/systemd/system/postgresql-@SLOT@.service.d/port.conf"
+# containing:
+# [Service]
+# Environment=PGPORT=5433
+# This will override the setting appearing below.
+
+[Unit]
+Description=PostgreSQL database server
+After=network.target
+
+[Service]
+Type=forking
+
+User=postgres
+Group=postgres
+
+# Port number for server to listen on
+Environment=PGPORT=5432
+
+# Location of configuration files
+Environment=PGDATA=/etc/postgresql-@SLOT@
+
+# Where the data directory is located
+Environment=DATA_DIR=/var/lib/postgresql/@SLOT@/data
+
+# Where to send early-startup messages from the server (before the logging
+# options of postgresql.conf take effect)
+# This is normally controlled by the global default set by systemd
+# StandardOutput=syslog
+
+ExecStartPre=/usr/bin/postgresql-@SLOT@-check-db-dir
+ExecStart=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl start -D ${DATA_DIR} -s -l ${DATA_DIR}/postmaster.log -o "-p ${PGPORT} -D ${PGDATA} --data-directory=${DATA_DIR}" -w -t 300
+ExecStop=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl stop -D ${DATA_DIR} -s -m fast
+ExecReload=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl reload -D ${DATA_DIR} -s
+
+# Give a reasonable amount of time for the server to start up/shut down
+TimeoutSec=300
+
+# Disable OOM kill on the postmaster
+OOMScoreAdjust=-1000
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dev-db/postgresql/files/postgresql.tmpfilesd b/dev-db/postgresql/files/postgresql.tmpfilesd
new file mode 100644
index 000000000000..26f44efa3288
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.tmpfilesd
@@ -0,0 +1 @@
+d /run/postgresql 1775 postgres postgres -