summaryrefslogtreecommitdiff
path: root/dev-db/postgresql/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /dev-db/postgresql/files
reinit the tree, so we can have metadata
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-10beta2-no-server.patch146
-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.10-no-server.patch151
-rw-r--r--dev-db/postgresql/files/postgresql-9.5-no-server.patch152
-rw-r--r--dev-db/postgresql/files/postgresql-9.5.5-no-server.patch151
-rw-r--r--dev-db/postgresql/files/postgresql-9.6-no-server.patch110
-rw-r--r--dev-db/postgresql/files/postgresql-9.6.1-no-server.patch130
-rw-r--r--dev-db/postgresql/files/postgresql-9.6.3-no-server.patch145
-rw-r--r--dev-db/postgresql/files/postgresql-check-db-dir35
-rw-r--r--dev-db/postgresql/files/postgresql.confd58
-rw-r--r--dev-db/postgresql/files/postgresql.confd-9.265
-rw-r--r--dev-db/postgresql/files/postgresql.confd-9.365
-rw-r--r--dev-db/postgresql/files/postgresql.init137
-rwxr-xr-xdev-db/postgresql/files/postgresql.init-9.2152
-rw-r--r--dev-db/postgresql/files/postgresql.init-9.3142
-rwxr-xr-xdev-db/postgresql/files/postgresql.init-9.3-r1157
-rw-r--r--dev-db/postgresql/files/postgresql.service55
-rw-r--r--dev-db/postgresql/files/postgresql.service-9.251
-rw-r--r--dev-db/postgresql/files/postgresql.service-9.656
-rw-r--r--dev-db/postgresql/files/postgresql.service-9.6-r152
-rw-r--r--dev-db/postgresql/files/postgresql.tmpfiles1
26 files changed, 2500 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-10beta2-no-server.patch b/dev-db/postgresql/files/postgresql-10beta2-no-server.patch
new file mode 100644
index 000000000000..8c88465e7bd8
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-10beta2-no-server.patch
@@ -0,0 +1,146 @@
+diff -Naruw a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2017-07-10 16:26:20.000000000 -0400
++++ b/contrib/Makefile 2017-07-12 09:35:05.025053646 -0400
+@@ -5,57 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- amcheck \
+- auth_delay \
+- auto_explain \
+- bloom \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_trgm \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- pg_visibility \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- tsm_system_rows \
+- tsm_system_time \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+diff -Naruw a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2017-07-10 16:26:20.000000000 -0400
++++ b/src/backend/Makefile 2017-07-12 10:02:15.890642203 -0400
+@@ -51,7 +51,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: generated-headers
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -226,23 +226,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 -Naruw a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2017-07-10 16:26:20.000000000 -0400
++++ b/src/bin/Makefile 2017-07-12 10:06:45.609174107 -0400
+@@ -14,19 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- initdb \
+- pg_archivecleanup \
+- pg_basebackup \
+ pg_config \
+- pg_controldata \
+- pg_ctl \
+ pg_dump \
+- pg_resetwal \
+- pg_rewind \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_upgrade \
+- pg_waldump \
+ pgbench \
+ psql \
+ scripts
+diff -Naruw a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2017-07-10 16:26:20.000000000 -0400
++++ b/src/Makefile 2017-07-12 10:10:04.128087426 -0400
+@@ -15,20 +15,12 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+- backend/replication/pgoutput \
+ fe_utils \
+ bin \
+- pl \
+- makefiles \
+- test/regress \
+- test/perl
++ 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-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.10-no-server.patch b/dev-db/postgresql/files/postgresql-9.4.10-no-server.patch
new file mode 100644
index 000000000000..81fc3837bede
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.4.10-no-server.patch
@@ -0,0 +1,151 @@
+diff -Naruw a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2016-10-24 16:12:53.000000000 -0400
++++ b/contrib/Makefile 2016-10-27 13:38:23.361545396 -0400
+@@ -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
+
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+diff -Naruw a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2016-10-24 16:12:53.000000000 -0400
++++ b/src/backend/Makefile 2016-10-27 14:04:47.617000374 -0400
+@@ -47,7 +47,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -106,7 +106,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:
+@@ -199,23 +199,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 -Naruw a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2016-10-24 16:12:53.000000000 -0400
++++ b/src/bin/Makefile 2016-10-27 13:41:34.443930143 -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 -Naruw a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2016-10-24 16:12:53.000000000 -0400
++++ b/src/Makefile 2016-10-27 13:43:09.296792018 -0400
+@@ -15,18 +15,11 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ bin \
+- pl \
+- makefiles \
+- test/regress \
+- test/perl
++ 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..c5e2c7ddd3b8
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.5-no-server.patch
@@ -0,0 +1,152 @@
+diff -ru a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2015-06-29 15:42:18.000000000 -0400
++++ b/contrib/Makefile 2015-09-06 07:50:51.258463861 -0400
+@@ -5,56 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_trgm \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- tsm_system_rows \
+- tsm_system_time \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+-
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+ else
+diff -ru a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2015-06-29 15:42:18.000000000 -0400
++++ b/src/backend/Makefile 2015-09-06 08:01:36.775374842 -0400
+@@ -47,7 +47,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -106,7 +106,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:
+@@ -199,23 +199,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 -ru a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2015-06-29 15:42:18.000000000 -0400
++++ b/src/bin/Makefile 2015-09-06 08:03:27.014847309 -0400
+@@ -14,20 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- initdb \
+- pg_archivecleanup \
+- pg_basebackup \
+ pg_config \
+- pg_controldata \
+- pg_ctl \
+ pg_dump \
+- pg_resetxlog \
+- pg_rewind \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_upgrade \
+- pg_xlogdump \
+- pgbench \
+ psql \
+ scripts
+
+diff -ru a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2015-06-29 15:42:18.000000000 -0400
++++ b/src/Makefile 2015-09-06 08:04:25.274568519 -0400
+@@ -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.5-no-server.patch b/dev-db/postgresql/files/postgresql-9.5.5-no-server.patch
new file mode 100644
index 000000000000..285667801a63
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.5.5-no-server.patch
@@ -0,0 +1,151 @@
+diff -Naruw postgresql-9.5.5.orig/contrib/Makefile postgresql-9.5.5/contrib/Makefile
+--- postgresql-9.5.5.orig/contrib/Makefile 2016-10-24 16:10:50.000000000 -0400
++++ postgresql-9.5.5/contrib/Makefile 2016-10-27 13:49:19.418285694 -0400
+@@ -5,55 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_trgm \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- tsm_system_rows \
+- tsm_system_time \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+diff -Naruw postgresql-9.5.5.orig/src/backend/Makefile postgresql-9.5.5/src/backend/Makefile
+--- postgresql-9.5.5.orig/src/backend/Makefile 2016-10-24 16:10:50.000000000 -0400
++++ postgresql-9.5.5/src/backend/Makefile 2016-10-27 13:51:16.027706097 -0400
+@@ -47,7 +47,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -106,7 +106,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:
+@@ -199,23 +199,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 -Naruw postgresql-9.5.5.orig/src/bin/Makefile postgresql-9.5.5/src/bin/Makefile
+--- postgresql-9.5.5.orig/src/bin/Makefile 2016-10-24 16:10:50.000000000 -0400
++++ postgresql-9.5.5/src/bin/Makefile 2016-10-27 14:26:26.397161219 -0400
+@@ -14,19 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- initdb \
+- pg_archivecleanup \
+- pg_basebackup \
+ pg_config \
+- pg_controldata \
+- pg_ctl \
+ pg_dump \
+- pg_resetxlog \
+- pg_rewind \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_upgrade \
+- pg_xlogdump \
+ pgbench \
+ psql \
+ scripts
+diff -Naruw postgresql-9.5.5.orig/src/Makefile postgresql-9.5.5/src/Makefile
+--- postgresql-9.5.5.orig/src/Makefile 2016-10-24 16:10:50.000000000 -0400
++++ postgresql-9.5.5/src/Makefile 2016-10-27 14:03:49.513956432 -0400
+@@ -15,18 +15,11 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ bin \
+- pl \
+- makefiles \
+- test/regress \
+- test/perl
++ 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.6-no-server.patch b/dev-db/postgresql/files/postgresql-9.6-no-server.patch
new file mode 100644
index 000000000000..637e65ecc472
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.6-no-server.patch
@@ -0,0 +1,110 @@
+vdiff -ru a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2015-06-29 15:42:18.000000000 -0400
++++ b/contrib/Makefile 2015-09-06 07:50:51.258463861 -0400
+@@ -5,58 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- bloom \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_trgm \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- pg_visibility \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- tsm_system_rows \
+- tsm_system_time \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+-
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+ else
+diff -ru a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2015-06-29 15:42:18.000000000 -0400
++++ b/src/bin/Makefile 2015-09-06 08:03:27.014847309 -0400
+@@ -14,20 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- initdb \
+- pg_archivecleanup \
+- pg_basebackup \
+ pg_config \
+- pg_controldata \
+- pg_ctl \
+ pg_dump \
+- pg_resetxlog \
+- pg_rewind \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_upgrade \
+- pg_xlogdump \
+- pgbench \
+ psql \
+ scripts
+
+diff -ru a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2015-06-29 15:42:18.000000000 -0400
++++ b/src/Makefile 2015-09-06 08:04:25.274568519 -0400
+@@ -15,19 +15,11 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+- fe_utils \
+ bin \
+- pl \
+- makefiles \
+- test/regress \
+- test/perl
++ 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.6.1-no-server.patch b/dev-db/postgresql/files/postgresql-9.6.1-no-server.patch
new file mode 100644
index 000000000000..868567cadb2c
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.6.1-no-server.patch
@@ -0,0 +1,130 @@
+diff -Naruw a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2016-10-24 16:08:51.000000000 -0400
++++ b/contrib/Makefile 2016-10-28 11:41:00.450589656 -0400
+@@ -5,58 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- bloom \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_trgm \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- pg_visibility \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- tsm_system_rows \
+- tsm_system_time \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+-
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+ else
+diff -Naruw a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2016-10-24 16:08:51.000000000 -0400
++++ b/src/backend/Makefile 2016-10-28 11:48:58.571353118 -0400
+@@ -51,7 +51,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: someheaders
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -110,7 +110,7 @@
+ endif # aix
+
+ # Update the commonly used headers before building the subdirectories
+-$(SUBDIRS:%=%-recursive): | generated-headers
++someheaders $(SUBDIRS:%=%-recursive): | generated-headers
+
+ # src/port needs a convenient way to force just errcodes.h to get built
+ submake-errcodes: $(top_builddir)/src/include/utils/errcodes.h
+diff -Naruw a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2016-10-24 16:08:51.000000000 -0400
++++ b/src/bin/Makefile 2016-10-28 11:42:26.000129832 -0400
+@@ -14,19 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- initdb \
+- pg_archivecleanup \
+- pg_basebackup \
+ pg_config \
+- pg_controldata \
+- pg_ctl \
+ pg_dump \
+- pg_resetxlog \
+- pg_rewind \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_upgrade \
+- pg_xlogdump \
+ pgbench \
+ psql \
+ scripts
+diff -Naruw a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2016-10-24 16:08:51.000000000 -0400
++++ b/src/Makefile 2016-10-28 11:41:00.453922971 -0400
+@@ -15,19 +15,11 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+- fe_utils \
+ bin \
+- pl \
+- makefiles \
+- test/regress \
+- test/perl
++ 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.6.3-no-server.patch b/dev-db/postgresql/files/postgresql-9.6.3-no-server.patch
new file mode 100644
index 000000000000..db662d4630e3
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-9.6.3-no-server.patch
@@ -0,0 +1,145 @@
+diff -Naruw a/contrib/Makefile b/contrib/Makefile
+--- a/contrib/Makefile 2017-05-08 17:15:12.000000000 -0400
++++ b/contrib/Makefile 2017-07-13 20:20:26.926646151 -0400
+@@ -5,57 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- adminpack \
+- auth_delay \
+- auto_explain \
+- bloom \
+- btree_gin \
+- btree_gist \
+- chkpass \
+- citext \
+- cube \
+- dblink \
+- dict_int \
+- dict_xsyn \
+- earthdistance \
+- file_fdw \
+- fuzzystrmatch \
+- hstore \
+- intagg \
+- intarray \
+- isn \
+- lo \
+- ltree \
+ oid2name \
+- pageinspect \
+- passwordcheck \
+- pg_buffercache \
+- pg_freespacemap \
+- pg_prewarm \
+- pg_standby \
+- pg_stat_statements \
+- pg_trgm \
+- pgcrypto \
+- pgrowlocks \
+- pgstattuple \
+- pg_visibility \
+- postgres_fdw \
+- seg \
+- spi \
+- tablefunc \
+- tcn \
+- test_decoding \
+- tsm_system_rows \
+- tsm_system_time \
+- tsearch2 \
+- unaccent \
+ vacuumlo
+
+-ifeq ($(with_openssl),yes)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+diff -Naruw a/src/backend/Makefile b/src/backend/Makefile
+--- a/src/backend/Makefile 2017-05-08 17:15:12.000000000 -0400
++++ b/src/backend/Makefile 2017-07-13 20:18:08.590323095 -0400
+@@ -51,7 +51,7 @@
+
+ ##########################################################################
+
+-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
++all: generated-headers
+
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -218,23 +218,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 -Naruw a/src/bin/Makefile b/src/bin/Makefile
+--- a/src/bin/Makefile 2017-05-08 17:15:12.000000000 -0400
++++ b/src/bin/Makefile 2017-07-13 20:23:51.419471550 -0400
+@@ -14,19 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+
+ SUBDIRS = \
+- initdb \
+- pg_archivecleanup \
+- pg_basebackup \
+ pg_config \
+- pg_controldata \
+- pg_ctl \
+ pg_dump \
+- pg_resetxlog \
+- pg_rewind \
+- pg_test_fsync \
+- pg_test_timing \
+- pg_upgrade \
+- pg_xlogdump \
+ pgbench \
+ psql \
+ scripts
+diff -Naruw a/src/Makefile b/src/Makefile
+--- a/src/Makefile 2017-05-08 17:15:12.000000000 -0400
++++ b/src/Makefile 2017-07-13 20:25:57.539158282 -0400
+@@ -15,19 +15,12 @@
+ SUBDIRS = \
+ common \
+ port \
+- timezone \
+ backend \
+- backend/utils/mb/conversion_procs \
+- backend/snowball \
+ include \
+ interfaces \
+- backend/replication/libpqwalreceiver \
+ fe_utils \
+ bin \
+- pl \
+- makefiles \
+- test/regress \
+- test/perl
++ 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..7f89919a1f68
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-check-db-dir
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+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.confd-9.2 b/dev-db/postgresql/files/postgresql.confd-9.2
new file mode 100644
index 000000000000..7753eeae3a89
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.confd-9.2
@@ -0,0 +1,65 @@
+# Directory that contains the unix socket. Created and controlled by
+# the related initscript. The directory created will be owned
+# root:postgres with mode 1775.
+#
+# /run/postgresql is the default directory.
+PG_SOCKET_DIRECTORY="/run/postgresql"
+
+# 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.confd-9.3 b/dev-db/postgresql/files/postgresql.confd-9.3
new file mode 100644
index 000000000000..8b6d2a097285
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.confd-9.3
@@ -0,0 +1,65 @@
+# Comma-separated list of directories that contain a unix
+# socket. Created and controlled by the related initscript. The
+# directories created will be owned root:postgres with mode 1775.
+#
+# /run/postgresql is the default directory.
+PG_SOCKET_DIRECTORIES="/run/postgresql"
+
+# 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..35dd316e9604
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init
@@ -0,0 +1,137 @@
+#!/sbin/openrc-run
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+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.2 b/dev-db/postgresql/files/postgresql.init-9.2
new file mode 100755
index 000000000000..b191ca29e97c
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init-9.2
@@ -0,0 +1,152 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+extra_started_commands="reload promote"
+
+PG_CTL="/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl"
+
+description="PostgreSQL @SLOT@ -- the world's most advanced open source database --
+${RC_SERVICE} is a wrapper around pg_ctl with additional administrative checks
+and convenience"
+
+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}}
+
+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 root:postgres "${PG_SOCKET_DIRECTORY}"
+ if [ -e "${PG_SOCKET_DIRECTORY%/}/.s.PGSQL.${configured_port}" ] ; then
+ eerror "Socket conflict."
+ eerror "A server is already listening on:"
+ eerror " ${PG_SOCKET_DIRECTORY%/}/.s.PGSQL.${configured_port}"
+ eerror "HINT: Change PGPORT to listen on a different socket."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting PostgreSQL @SLOT@"
+
+ rm -f "${DATA_DIR%/}/postmaster.pid"
+
+ su - postgres -c \
+ "PGPORT=${configured_port} ${PG_EXTRA_ENV} ${PG_CTL} start \
+ -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \
+ -D ${PGDATA} \
+ -o '--data-directory=${DATA_DIR} \
+ --unix-socket-directory=${PG_SOCKET_DIRECTORY} \
+ ${PGOPTS}'"
+
+ local retval=$?
+
+ if [ $retval -ne 0 ] ; then
+ eerror "Check the log for a possible explanation of the above error."
+ eerror "The log may be located at:"
+ eerror " ${DATA_DIR%/}/postmaster.log"
+ eerror "Or wherever you configured PostgreSQL @SLOT@ to log."
+ fi
+
+ eend $retval
+}
+
+stop() {
+ local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
+ ebegin "Stopping PostgreSQL @SLOT@ (this can take up to ${seconds} seconds)"
+
+ su - postgres -c \
+ "${PG_CTL} stop -t ${NICE_TIMEOUT} -s -D ${DATA_DIR} -m smart"
+ local retval=$?
+
+ if [ "${RUDE_QUIT}" != "NO" -a ${retval} -ne 0 ] ; then
+ einfo "Previous attempt failed. Trying RUDE_QUIT."
+ su - postgres -c \
+ "${PG_CTL} stop -t ${RUDE_TIMEOUT} -s -D ${DATA_DIR} -m fast"
+ retval=$?
+ fi
+
+ if [ "${FORCE_QUIT}" = "YES" -a ${retval} -ne 0 ] ; then
+ einfo "Previous step failed. Trying FORCE_QUIT."
+ ewarn "A recover-run might be executed on next startup."
+ su - postgres -c \
+ "${PG_CTL} stop -t ${FORCE_TIMEOUT} -s -D ${DATA_DIR} -m immediate"
+ retval=$?
+ fi
+
+ eend ${retval}
+}
+
+status() {
+ ebegin "Checking PostgreSQL @SLOT@ status"
+ su - postgres -c "${PG_CTL} status -D ${DATA_DIR}"
+ eend $?
+}
+
+description_reload="Simply sends the postgres process a SIGHUP signal, causing
+ it to reread its configuration files (postgresql.conf, pg_hba.conf,
+ etc.). This allows changing of configuration-file options that do not
+ require a complete restart to take effect."
+reload() {
+ ebegin "Reloading PostgreSQL @SLOT@ configuration"
+ su - postgres -c "${PG_CTL} reload -s -D ${DATA_DIR}"
+ eend $?
+}
+
+description_promote="If the server is in standby, it is commanded to exit
+ recovery and begin read-write operations."
+promote() {
+ ebegin "Promoting PostgreSQL @SLOT@"
+ su - postgres -c "${PG_CTL} promote -s -D ${DATA_DIR}"
+ 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..ffecea7a757c
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init-9.3
@@ -0,0 +1,142 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+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-9.3-r1 b/dev-db/postgresql/files/postgresql.init-9.3-r1
new file mode 100755
index 000000000000..256ee7e6fd35
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init-9.3-r1
@@ -0,0 +1,157 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+extra_started_commands="reload promote"
+
+PG_CTL="/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl"
+
+description="PostgreSQL @SLOT@ -- the world's most advanced open source database --
+${RC_SERVICE} is a wrapper around pg_ctl with additional administrative checks
+and convenience"
+
+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}}
+
+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 ${PG_SOCKET_DIRECTORIES}; do
+ checkpath -d -m 1775 -o root: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 @SLOT@"
+
+ rm -f "${DATA_DIR%/}/postmaster.pid"
+
+ su - postgres -c \
+ "PGPORT=${configured_port} ${PG_EXTRA_ENV} ${PG_CTL} start \
+ -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \
+ -D ${PGDATA} \
+ -o '--data-directory=${DATA_DIR} \
+ --unix-socket-directories=${PG_SOCKET_DIRECTORIES} \
+ ${PGOPTS}'"
+
+ local retval=$?
+
+ if [ $retval -ne 0 ] ; then
+ eerror "Check the log for a possible explanation of the above error."
+ eerror "The log may be located at:"
+ eerror " ${DATA_DIR%/}/postmaster.log"
+ eerror "Or wherever you configured PostgreSQL @SLOT@ to log."
+ fi
+
+ eend $retval
+}
+
+stop() {
+ local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
+ ebegin "Stopping PostgreSQL @SLOT@ (this can take up to ${seconds} seconds)"
+
+ su - postgres -c \
+ "${PG_CTL} stop -t ${NICE_TIMEOUT} -s -D ${DATA_DIR} -m smart"
+ local retval=$?
+
+ if [ "${RUDE_QUIT}" != "NO" -a ${retval} -ne 0 ] ; then
+ einfo "Previous attempt failed. Trying RUDE_QUIT."
+ su - postgres -c \
+ "${PG_CTL} stop -t ${RUDE_TIMEOUT} -s -D ${DATA_DIR} -m fast"
+ retval=$?
+ fi
+
+ if [ "${FORCE_QUIT}" = "YES" -a ${retval} -ne 0 ] ; then
+ einfo "Previous step failed. Trying FORCE_QUIT."
+ ewarn "A recover-run might be executed on next startup."
+ su - postgres -c \
+ "${PG_CTL} stop -t ${FORCE_TIMEOUT} -s -D ${DATA_DIR} -m immediate"
+ retval=$?
+ fi
+
+ eend ${retval}
+}
+
+status() {
+ ebegin "Checking PostgreSQL @SLOT@ status"
+ su - postgres -c "${PG_CTL} status -D ${DATA_DIR}"
+ eend $?
+}
+
+description_reload="Simply sends the postgres process a SIGHUP signal, causing
+ it to reread its configuration files (postgresql.conf, pg_hba.conf,
+ etc.). This allows changing of configuration-file options that do not
+ require a complete restart to take effect."
+reload() {
+ ebegin "Reloading PostgreSQL @SLOT@ configuration"
+ su - postgres -c "${PG_CTL} reload -s -D ${DATA_DIR}"
+ eend $?
+}
+
+description_promote="If the server is in standby, it is commanded to exit
+ recovery and begin read-write operations."
+promote() {
+ ebegin "Promoting PostgreSQL @SLOT@"
+ su - postgres -c "${PG_CTL} promote -s -D ${DATA_DIR}"
+ eend $?
+}
diff --git a/dev-db/postgresql/files/postgresql.service b/dev-db/postgresql/files/postgresql.service
new file mode 100644
index 000000000000..a607169d22f4
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.service
@@ -0,0 +1,55 @@
+# 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
+
+# Make sure the required runtimedir is present
+RuntimeDirectory=postgresql
+RuntimeDirectoryMode=1775
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dev-db/postgresql/files/postgresql.service-9.2 b/dev-db/postgresql/files/postgresql.service-9.2
new file mode 100644
index 000000000000..20ed27a10f29
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.service-9.2
@@ -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.service-9.6 b/dev-db/postgresql/files/postgresql.service-9.6
new file mode 100644
index 000000000000..89ec2d5cf7c0
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.service-9.6
@@ -0,0 +1,56 @@
+# 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=notify
+
+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/postgres -p ${PGPORT} -D ${DATA_DIR}
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=mixed
+KillSignal=SIGINT
+
+# Give a reasonable amount of time for the server to start up/shut down
+TimeoutSec=300
+
+# Disable OOM kill on the postmaster
+OOMScoreAdjust=-1000
+
+# Make sure the required runtimedir is present
+RuntimeDirectory=postgresql
+RuntimeDirectoryMode=1775
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dev-db/postgresql/files/postgresql.service-9.6-r1 b/dev-db/postgresql/files/postgresql.service-9.6-r1
new file mode 100644
index 000000000000..3b92e851f299
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.service-9.6-r1
@@ -0,0 +1,52 @@
+# 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=notify
+
+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/postgres -p ${PGPORT} -D ${DATA_DIR}
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=mixed
+KillSignal=SIGINT
+
+# 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.tmpfiles b/dev-db/postgresql/files/postgresql.tmpfiles
new file mode 100644
index 000000000000..650ae22b7c1b
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.tmpfiles
@@ -0,0 +1 @@
+d /run/postgresql 1775 root postgres -