public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2015-10-25 21:10 Michał Górny
  0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2015-10-25 21:10 UTC (permalink / raw
  To: gentoo-commits

commit:     4d732339911b0ea2aa9b994efe17a92d42281504
Author:     Elias Probst <mail <AT> eliasprobst <DOT> eu>
AuthorDate: Fri Oct 23 21:25:09 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Oct 25 19:45:00 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4d732339

dev-db/postgresql: Handle RuntimeDirectory in systemd unit

Instead of using a separate `tmpfiles.d` definition to create
`/run/postgresql`, let the service unit take care of it on its
own. This prevents situations where the postgresql service can't
start because `systemd-tmpfiles` wasn't run yet.

Bug: https://bugs.gentoo.org/show_bug.cgi?id=563122

Package-Manager: portage-2.2.23

 dev-db/postgresql/files/postgresql.service                            | 4 ++++
 dev-db/postgresql/files/postgresql.tmpfilesd                          | 1 -
 .../{postgresql-9.0.23.ebuild => postgresql-9.0.23-r1.ebuild}         | 2 --
 .../{postgresql-9.1.19.ebuild => postgresql-9.1.19-r1.ebuild}         | 2 --
 .../{postgresql-9.2.14.ebuild => postgresql-9.2.14-r1.ebuild}         | 2 --
 .../{postgresql-9.3.10.ebuild => postgresql-9.3.10-r1.ebuild}         | 2 --
 .../{postgresql-9.4.5.ebuild => postgresql-9.4.5-r1.ebuild}           | 2 --
 .../{postgresql-9.5_beta1.ebuild => postgresql-9.5_beta1-r1.ebuild}   | 2 --
 dev-db/postgresql/postgresql-9999.ebuild                              | 2 --
 9 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/dev-db/postgresql/files/postgresql.service b/dev-db/postgresql/files/postgresql.service
index 20ed27a..a607169 100644
--- a/dev-db/postgresql/files/postgresql.service
+++ b/dev-db/postgresql/files/postgresql.service
@@ -47,5 +47,9 @@ 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.tmpfilesd b/dev-db/postgresql/files/postgresql.tmpfilesd
deleted file mode 100644
index 26f44ef..0000000
--- a/dev-db/postgresql/files/postgresql.tmpfilesd
+++ /dev/null
@@ -1 +0,0 @@
-d /run/postgresql 1775 postgres postgres -

diff --git a/dev-db/postgresql/postgresql-9.0.23.ebuild b/dev-db/postgresql/postgresql-9.0.23-r1.ebuild
similarity index 99%
rename from dev-db/postgresql/postgresql-9.0.23.ebuild
rename to dev-db/postgresql/postgresql-9.0.23-r1.ebuild
index 174a686..ac1b4fe 100644
--- a/dev-db/postgresql/postgresql-9.0.23.ebuild
+++ b/dev-db/postgresql/postgresql-9.0.23-r1.ebuild
@@ -198,8 +198,6 @@ src_install() {
 			"${FILESDIR}/${PN}.service" | \
 			systemd_newunit - ${PN}-${SLOT}.service
 
-		systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
-
 		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
 		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session

diff --git a/dev-db/postgresql/postgresql-9.1.19.ebuild b/dev-db/postgresql/postgresql-9.1.19-r1.ebuild
similarity index 99%
rename from dev-db/postgresql/postgresql-9.1.19.ebuild
rename to dev-db/postgresql/postgresql-9.1.19-r1.ebuild
index e2ab37e..817622c 100644
--- a/dev-db/postgresql/postgresql-9.1.19.ebuild
+++ b/dev-db/postgresql/postgresql-9.1.19-r1.ebuild
@@ -202,8 +202,6 @@ src_install() {
 			"${FILESDIR}/${PN}.service" | \
 			systemd_newunit - ${PN}-${SLOT}.service
 
-		systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
-
 		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
 		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session

diff --git a/dev-db/postgresql/postgresql-9.2.14.ebuild b/dev-db/postgresql/postgresql-9.2.14-r1.ebuild
similarity index 99%
rename from dev-db/postgresql/postgresql-9.2.14.ebuild
rename to dev-db/postgresql/postgresql-9.2.14-r1.ebuild
index 6ec39d3..83a2fa7 100644
--- a/dev-db/postgresql/postgresql-9.2.14.ebuild
+++ b/dev-db/postgresql/postgresql-9.2.14-r1.ebuild
@@ -196,8 +196,6 @@ src_install() {
 			"${FILESDIR}/${PN}.service" | \
 			systemd_newunit - ${PN}-${SLOT}.service
 
-		systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
-
 		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
 		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session

diff --git a/dev-db/postgresql/postgresql-9.3.10.ebuild b/dev-db/postgresql/postgresql-9.3.10-r1.ebuild
similarity index 99%
rename from dev-db/postgresql/postgresql-9.3.10.ebuild
rename to dev-db/postgresql/postgresql-9.3.10-r1.ebuild
index dc084ca..2367c97 100644
--- a/dev-db/postgresql/postgresql-9.3.10.ebuild
+++ b/dev-db/postgresql/postgresql-9.3.10-r1.ebuild
@@ -196,8 +196,6 @@ src_install() {
 			"${FILESDIR}/${PN}.service" | \
 			systemd_newunit - ${PN}-${SLOT}.service
 
-		systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
-
 		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
 		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session

diff --git a/dev-db/postgresql/postgresql-9.4.5.ebuild b/dev-db/postgresql/postgresql-9.4.5-r1.ebuild
similarity index 99%
rename from dev-db/postgresql/postgresql-9.4.5.ebuild
rename to dev-db/postgresql/postgresql-9.4.5-r1.ebuild
index a411b38..d705b10 100644
--- a/dev-db/postgresql/postgresql-9.4.5.ebuild
+++ b/dev-db/postgresql/postgresql-9.4.5-r1.ebuild
@@ -228,8 +228,6 @@ src_install() {
 			"${FILESDIR}/${PN}.service" | \
 			systemd_newunit - ${PN}-${SLOT}.service
 
-		systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
-
 		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
 		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session

diff --git a/dev-db/postgresql/postgresql-9.5_beta1.ebuild b/dev-db/postgresql/postgresql-9.5_beta1-r1.ebuild
similarity index 99%
rename from dev-db/postgresql/postgresql-9.5_beta1.ebuild
rename to dev-db/postgresql/postgresql-9.5_beta1-r1.ebuild
index 50d2cec..cc14882 100644
--- a/dev-db/postgresql/postgresql-9.5_beta1.ebuild
+++ b/dev-db/postgresql/postgresql-9.5_beta1-r1.ebuild
@@ -234,8 +234,6 @@ src_install() {
 			"${FILESDIR}/${PN}.service" | \
 			systemd_newunit - ${PN}-${SLOT}.service
 
-		systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
-
 		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
 		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild
index 36e35fd..c2fe866 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -186,8 +186,6 @@ src_install() {
 		"${FILESDIR}/${PN}.service" | \
 		systemd_newunit - ${PN}-${SLOT}.service
 
-	systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
-
 	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
 	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2017-04-17 15:48 Aaron Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron Swenson @ 2017-04-17 15:48 UTC (permalink / raw
  To: gentoo-commits

commit:     f1b07f8816c2f0346d07468bdb4c5b9ce4ffada7
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 17 13:09:56 2017 +0000
Commit:     Aaron Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Mon Apr 17 15:40:58 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f1b07f88

dev-db/postgresql: Eselect and security related fixes

Dependency bumped on app-eselect/eselect-postgresql to 2.0. Some of
its work has been shifted into the ebuild as the files/links don’t
change until this package is reemerge, unmerged, or updated.

Security issues addressed in the initscripts per bugs 603716 and 603720.

Bugs: 603716, 603720

Package-Manager: portage-2.3.0

 dev-db/postgresql/files/postgresql.confd-9.2       |  65 +++++
 dev-db/postgresql/files/postgresql.confd-9.3       |  65 +++++
 dev-db/postgresql/files/postgresql.init-9.2        | 153 ++++++++++++
 dev-db/postgresql/files/postgresql.init-9.3-r1     | 158 ++++++++++++
 ...sql-9999.ebuild => postgresql-9.2.20-r1.ebuild} | 239 +++++++++++-------
 ...sql-9999.ebuild => postgresql-9.3.16-r1.ebuild} | 236 +++++++++++-------
 ...sql-9999.ebuild => postgresql-9.4.11-r1.ebuild} | 272 +++++++++++++-------
 ...esql-9999.ebuild => postgresql-9.5.6-r1.ebuild} | 276 ++++++++++++++-------
 ...esql-9999.ebuild => postgresql-9.6.2-r1.ebuild} | 273 +++++++++++++-------
 dev-db/postgresql/postgresql-9999.ebuild           | 101 +++++---
 10 files changed, 1338 insertions(+), 500 deletions(-)

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 00000000000..7753eeae3a8
--- /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 00000000000..8b6d2a09728
--- /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-9.2 b/dev-db/postgresql/files/postgresql.init-9.2
new file mode 100755
index 00000000000..0b257049008
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init-9.2
@@ -0,0 +1,153 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+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-r1 b/dev-db/postgresql/files/postgresql.init-9.3-r1
new file mode 100755
index 00000000000..b7a08990bf6
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql.init-9.3-r1
@@ -0,0 +1,158 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+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/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9.2.20-r1.ebuild
similarity index 58%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.2.20-r1.ebuild
index 6a995c154ba..09d00f4a78a 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.2.20-r1.ebuild
@@ -3,17 +3,16 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
-		python-single-r1 systemd user versionator
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+		systemd user versionator
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-# Fix if needed
-SLOT="9.7"
+SLOT="$(get_version_component_range 1-2)"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
@@ -21,7 +20,7 @@ HOMEPAGE="http://www.postgresql.org/"
 
 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
 		 zh_CN zh_TW"
-IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
+IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
 	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
 
 for lingua in ${LINGUAS}; do
@@ -39,7 +38,7 @@ wanted_languages() {
 }
 
 CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
+>=app-eselect/eselect-postgresql-2.0
 sys-apps/less
 virtual/libintl
 kerberos? ( virtual/krb5 )
@@ -60,23 +59,11 @@ zlib? ( sys-libs/zlib )
 
 DEPEND="${CDEPEND}
 !!<sys-apps/sandbox-2.0
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.2
-app-text/docbook-xml-dtd:4.2
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
-src_unpack() {
-	base_src_unpack
-	git-2_src_unpack
-}
 
 RDEPEND="${CDEPEND}
 !dev-db/postgresql-docs:${SLOT}
@@ -85,17 +72,8 @@ RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	ewarn "You are using a live ebuild that uses the current source code as it is"
-	ewarn "available from PostgreSQL's Git repository at emerge time. Given such,"
-	ewarn "the GNU Makefiles may be altered by upstream without notice and the"
-	ewarn "documentation for this live version is not readily available"
-	ewarn "online. Ergo, the ebuild maintainers will not support building a"
-	ewarn "client-only and/or document-free version."
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	enewgroup postgres 70
 	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
@@ -111,10 +89,11 @@ src_prepare() {
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
 
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
+	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
+
+	# Fix bug 486556 where the server would crash at start up because of
+	# an infinite loop caused by a self-referencing symlink.
+	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
 
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
@@ -148,6 +127,7 @@ src_configure() {
 		$(use_enable !pg_legacytimestamp integer-datetimes) \
 		$(use_enable threads thread-safety) \
 		$(use_with kerberos gssapi) \
+		$(use_with kerberos krb5) \
 		$(use_with ldap) \
 		$(use_with pam) \
 		$(use_with perl) \
@@ -163,78 +143,150 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
 	dodoc README HISTORY doc/{TODO,bug.template}
 
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
 	insinto /etc/postgresql-${SLOT}
 	newins src/bin/psql/psqlrc.sample psqlrc
 
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
 	use static-libs || find "${ED}" -name '*.a' -delete
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
+	local linkname mansec
+	for mansec in {1,3,7} ; do
+		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
+			bn=$(basename "${f}")
+			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
+			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
+				  /usr/share/man/man${mansec}/${linkname}
+		done
+	done
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.service" | \
-		systemd_newunit - ${PN}-${SLOT}.service
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
 
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
 
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.2" | newconfd - ${PN}-${SLOT}
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 0775 /run/postgresql
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.2" | newinitd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.service" | \
+			systemd_newunit - ${PN}-${SLOT}.service
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 0775 /run/postgresql
+		fi
 	fi
 }
 
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql96). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
+	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
+}
+
 pkg_postinst() {
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT%/}/run/postgresql/"
 		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
 		elog "environment:"
-		elog "    source /etc/profile"
+		elog "    emerge --config =${CATEGORY}/${PF}"
 	fi
-
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT%/}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT%/}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -249,6 +301,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
@@ -297,21 +351,10 @@ pkg_config() {
 	einfo "The database cluster will be created in:"
 	einfo "    ${DATA_DIR}"
 	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
 
 	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
 		eerror "The given directory, '${DATA_DIR}', is not empty."
@@ -339,6 +382,10 @@ pkg_config() {
 		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
 	fi
 
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf
+
 	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
 		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
 		# On the off-chance that you might need to work with UTF-8 encoded
@@ -371,17 +418,17 @@ pkg_config() {
 }
 
 src_test() {
-	einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
 		[[ ${UID} -eq 0 ]] || \
-			ewarn "Tests cannot be run as root. Enable 'userpriv' in FEATURES."
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
 
-		ewarn "Skipping."
+		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9.3.16-r1.ebuild
similarity index 59%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.3.16-r1.ebuild
index 6a995c154ba..0055c0e30d9 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.3.16-r1.ebuild
@@ -3,17 +3,16 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
-		python-single-r1 systemd user versionator
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+		systemd user versionator
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-# Fix if needed
-SLOT="9.7"
+SLOT="$(get_version_component_range 1-2)"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
@@ -21,7 +20,7 @@ HOMEPAGE="http://www.postgresql.org/"
 
 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
 		 zh_CN zh_TW"
-IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
+IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
 	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
 
 for lingua in ${LINGUAS}; do
@@ -39,7 +38,7 @@ wanted_languages() {
 }
 
 CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
+>=app-eselect/eselect-postgresql-2.0
 sys-apps/less
 virtual/libintl
 kerberos? ( virtual/krb5 )
@@ -60,23 +59,11 @@ zlib? ( sys-libs/zlib )
 
 DEPEND="${CDEPEND}
 !!<sys-apps/sandbox-2.0
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.2
-app-text/docbook-xml-dtd:4.2
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
-src_unpack() {
-	base_src_unpack
-	git-2_src_unpack
-}
 
 RDEPEND="${CDEPEND}
 !dev-db/postgresql-docs:${SLOT}
@@ -85,17 +72,8 @@ RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	ewarn "You are using a live ebuild that uses the current source code as it is"
-	ewarn "available from PostgreSQL's Git repository at emerge time. Given such,"
-	ewarn "the GNU Makefiles may be altered by upstream without notice and the"
-	ewarn "documentation for this live version is not readily available"
-	ewarn "online. Ergo, the ebuild maintainers will not support building a"
-	ewarn "client-only and/or document-free version."
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	enewgroup postgres 70
 	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
@@ -116,6 +94,12 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
+
+	# Fix bug 486556 where the server would crash at start up because of
+	# an infinite loop caused by a self-referencing symlink.
+	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
+
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
@@ -148,6 +132,7 @@ src_configure() {
 		$(use_enable !pg_legacytimestamp integer-datetimes) \
 		$(use_enable threads thread-safety) \
 		$(use_with kerberos gssapi) \
+		$(use_with kerberos krb5) \
 		$(use_with ldap) \
 		$(use_with pam) \
 		$(use_with perl) \
@@ -163,41 +148,119 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
 	dodoc README HISTORY doc/{TODO,bug.template}
 
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
 	insinto /etc/postgresql-${SLOT}
 	newins src/bin/psql/psqlrc.sample psqlrc
 
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
 	use static-libs || find "${ED}" -name '*.a' -delete
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
+	local linkname mansec
+	for mansec in {1,3,7} ; do
+		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
+			bn=$(basename "${f}")
+			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
+			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
+				  /usr/share/man/man${mansec}/${linkname}
+		done
+	done
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.service" | \
-		systemd_newunit - ${PN}-${SLOT}.service
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
 
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
 
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 0775 /run/postgresql
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.service" | \
+			systemd_newunit - ${PN}-${SLOT}.service
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 0775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql96). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
 	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
 }
 
 pkg_postinst() {
@@ -206,35 +269,29 @@ pkg_postinst() {
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT%/}/run/postgresql/"
 		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
 		elog "environment:"
-		elog "    source /etc/profile"
+		elog "    emerge --config =${CATEGORY}/${PF}"
 	fi
-
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT%/}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT%/}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -249,6 +306,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
@@ -297,21 +356,10 @@ pkg_config() {
 	einfo "The database cluster will be created in:"
 	einfo "    ${DATA_DIR}"
 	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
 
 	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
 		eerror "The given directory, '${DATA_DIR}', is not empty."
@@ -339,6 +387,10 @@ pkg_config() {
 		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
 	fi
 
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
 	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
 		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
 		# On the off-chance that you might need to work with UTF-8 encoded
@@ -371,17 +423,17 @@ pkg_config() {
 }
 
 src_test() {
-	einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
 		[[ ${UID} -eq 0 ]] || \
-			ewarn "Tests cannot be run as root. Enable 'userpriv' in FEATURES."
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
 
-		ewarn "Skipping."
+		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9.4.11-r1.ebuild
similarity index 55%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.4.11-r1.ebuild
index 6a995c154ba..538724b3677 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.4.11-r1.ebuild
@@ -3,17 +3,16 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
-		python-single-r1 systemd user versionator
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+		systemd user versionator
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-# Fix if needed
-SLOT="9.7"
+SLOT="$(get_version_component_range 1-2)"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
@@ -21,7 +20,7 @@ HOMEPAGE="http://www.postgresql.org/"
 
 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
 		 zh_CN zh_TW"
-IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
+IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
 	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
 
 for lingua in ${LINGUAS}; do
@@ -39,7 +38,7 @@ wanted_languages() {
 }
 
 CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
+>=app-eselect/eselect-postgresql-2.0
 sys-apps/less
 virtual/libintl
 kerberos? ( virtual/krb5 )
@@ -53,30 +52,40 @@ ssl? (
 	libressl? ( dev-libs/libressl:= )
 )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
 "
 
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
 DEPEND="${CDEPEND}
 !!<sys-apps/sandbox-2.0
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.2
-app-text/docbook-xml-dtd:4.2
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
-src_unpack() {
-	base_src_unpack
-	git-2_src_unpack
-}
 
 RDEPEND="${CDEPEND}
 !dev-db/postgresql-docs:${SLOT}
@@ -85,17 +94,8 @@ RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	ewarn "You are using a live ebuild that uses the current source code as it is"
-	ewarn "available from PostgreSQL's Git repository at emerge time. Given such,"
-	ewarn "the GNU Makefiles may be altered by upstream without notice and the"
-	ewarn "documentation for this live version is not readily available"
-	ewarn "online. Ergo, the ebuild maintainers will not support building a"
-	ewarn "client-only and/or document-free version."
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	enewgroup postgres 70
 	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
@@ -116,6 +116,12 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || epatch "${FILESDIR}/${PN}-9.4.10-no-server.patch"
+
+	# Fix bug 486556 where the server would crash at start up because of
+	# an infinite loop caused by a self-referencing symlink.
+	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
+
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
@@ -137,6 +143,17 @@ src_configure() {
 
 	local PO="${EPREFIX%/}"
 
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
 	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
@@ -155,7 +172,7 @@ src_configure() {
 		$(use_with readline) \
 		$(use_with ssl openssl) \
 		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
@@ -163,41 +180,119 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
 	dodoc README HISTORY doc/{TODO,bug.template}
 
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
 	insinto /etc/postgresql-${SLOT}
 	newins src/bin/psql/psqlrc.sample psqlrc
 
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
 	use static-libs || find "${ED}" -name '*.a' -delete
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
+	local linkname mansec
+	for mansec in {1,3,7} ; do
+		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
+			bn=$(basename "${f}")
+			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
+			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
+				  /usr/share/man/man${mansec}/${linkname}
+		done
+	done
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.service" | \
-		systemd_newunit - ${PN}-${SLOT}.service
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
 
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
 
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 0775 /run/postgresql
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.service" | \
+			systemd_newunit - ${PN}-${SLOT}.service
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 0775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql96). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
 	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
 }
 
 pkg_postinst() {
@@ -206,35 +301,29 @@ pkg_postinst() {
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
 		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
+		elog "Official documentation:"
+		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT%/}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
 		elog "environment:"
-		elog "    source /etc/profile"
+		elog "    emerge --config =${CATEGORY}/${PF}"
 	fi
-
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT%/}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT%/}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -249,6 +338,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
@@ -297,21 +388,10 @@ pkg_config() {
 	einfo "The database cluster will be created in:"
 	einfo "    ${DATA_DIR}"
 	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
 
 	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
 		eerror "The given directory, '${DATA_DIR}', is not empty."
@@ -339,6 +419,10 @@ pkg_config() {
 		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
 	fi
 
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
 	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
 		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
 		# On the off-chance that you might need to work with UTF-8 encoded
@@ -371,17 +455,17 @@ pkg_config() {
 }
 
 src_test() {
-	einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
 		[[ ${UID} -eq 0 ]] || \
-			ewarn "Tests cannot be run as root. Enable 'userpriv' in FEATURES."
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
 
-		ewarn "Skipping."
+		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9.5.6-r1.ebuild
similarity index 55%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.5.6-r1.ebuild
index 6a995c154ba..fdfc66fd9bd 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.5.6-r1.ebuild
@@ -5,15 +5,14 @@ EAPI="5"
 
 PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
 
-inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
-		python-single-r1 systemd user versionator
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+		systemd user versionator
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-# Fix if needed
-SLOT="9.7"
+SLOT="$(get_version_component_range 1-2)"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
@@ -21,7 +20,7 @@ HOMEPAGE="http://www.postgresql.org/"
 
 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
 		 zh_CN zh_TW"
-IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
+IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
 	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
 
 for lingua in ${LINGUAS}; do
@@ -39,7 +38,7 @@ wanted_languages() {
 }
 
 CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
+>=app-eselect/eselect-postgresql-2.0
 sys-apps/less
 virtual/libintl
 kerberos? ( virtual/krb5 )
@@ -53,30 +52,40 @@ ssl? (
 	libressl? ( dev-libs/libressl:= )
 )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
 "
 
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
 DEPEND="${CDEPEND}
 !!<sys-apps/sandbox-2.0
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.2
-app-text/docbook-xml-dtd:4.2
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
-src_unpack() {
-	base_src_unpack
-	git-2_src_unpack
-}
 
 RDEPEND="${CDEPEND}
 !dev-db/postgresql-docs:${SLOT}
@@ -85,17 +94,8 @@ RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	ewarn "You are using a live ebuild that uses the current source code as it is"
-	ewarn "available from PostgreSQL's Git repository at emerge time. Given such,"
-	ewarn "the GNU Makefiles may be altered by upstream without notice and the"
-	ewarn "documentation for this live version is not readily available"
-	ewarn "online. Ergo, the ebuild maintainers will not support building a"
-	ewarn "client-only and/or document-free version."
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	enewgroup postgres 70
 	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
@@ -116,6 +116,12 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || epatch "${FILESDIR}/${PN}-9.5.5-no-server.patch"
+
+	# Fix bug 486556 where the server would crash at start up because of
+	# an infinite loop caused by a self-referencing symlink.
+	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
+
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
@@ -137,6 +143,17 @@ src_configure() {
 
 	local PO="${EPREFIX%/}"
 
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
 	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
@@ -145,6 +162,7 @@ src_configure() {
 		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
 		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
 		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
 		$(use_enable !pg_legacytimestamp integer-datetimes) \
 		$(use_enable threads thread-safety) \
 		$(use_with kerberos gssapi) \
@@ -155,7 +173,7 @@ src_configure() {
 		$(use_with readline) \
 		$(use_with ssl openssl) \
 		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
@@ -163,78 +181,155 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
 	dodoc README HISTORY doc/{TODO,bug.template}
 
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
 	insinto /etc/postgresql-${SLOT}
 	newins src/bin/psql/psqlrc.sample psqlrc
 
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
 	use static-libs || find "${ED}" -name '*.a' -delete
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
+
+	local linkname mansec
+	for mansec in {1,3,7} ; do
+		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
+			bn=$(basename "${f}")
+			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
+			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
+				  /usr/share/man/man${mansec}/${linkname}
+		done
+	done
+
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.service" | \
-		systemd_newunit - ${PN}-${SLOT}.service
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
 
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
 
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.service" | \
+			systemd_newunit - ${PN}-${SLOT}.service
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 0775 /run/postgresql
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 0775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql96). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
 	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
 }
 
 pkg_postinst() {
 	postgresql-config update
 
+	if use alpha && use server ; then
+		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
+		ewarn "As a result, performance will be extremely degraded."
+	fi
+
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
+	if use server ; then
 		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT%/}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
 		elog "environment:"
-		elog "    source /etc/profile"
+		elog "    emerge --config =${CATEGORY}/${PF}"
 	fi
-
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT%/}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT%/}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -249,6 +344,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
@@ -297,21 +394,10 @@ pkg_config() {
 	einfo "The database cluster will be created in:"
 	einfo "    ${DATA_DIR}"
 	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
 
 	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
 		eerror "The given directory, '${DATA_DIR}', is not empty."
@@ -339,6 +425,10 @@ pkg_config() {
 		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
 	fi
 
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
 	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
 		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
 		# On the off-chance that you might need to work with UTF-8 encoded
@@ -371,17 +461,17 @@ pkg_config() {
 }
 
 src_test() {
-	einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
 		[[ ${UID} -eq 0 ]] || \
-			ewarn "Tests cannot be run as root. Enable 'userpriv' in FEATURES."
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
 
-		ewarn "Skipping."
+		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9.6.2-r1.ebuild
similarity index 55%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.6.2-r1.ebuild
index 6a995c154ba..07527caf315 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.6.2-r1.ebuild
@@ -5,15 +5,17 @@ EAPI="5"
 
 PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
 
-inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
-		python-single-r1 systemd user versionator
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+		systemd user versionator
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-# Fix if needed
-SLOT="9.7"
+SLOT="$(get_version_component_range 1-2)"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
@@ -21,7 +23,7 @@ HOMEPAGE="http://www.postgresql.org/"
 
 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
 		 zh_CN zh_TW"
-IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
+IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
 	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
 
 for lingua in ${LINGUAS}; do
@@ -39,7 +41,7 @@ wanted_languages() {
 }
 
 CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
+>=app-eselect/eselect-postgresql-2.0
 sys-apps/less
 virtual/libintl
 kerberos? ( virtual/krb5 )
@@ -53,30 +55,40 @@ ssl? (
 	libressl? ( dev-libs/libressl:= )
 )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
 "
 
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
 DEPEND="${CDEPEND}
 !!<sys-apps/sandbox-2.0
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.2
-app-text/docbook-xml-dtd:4.2
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
-src_unpack() {
-	base_src_unpack
-	git-2_src_unpack
-}
 
 RDEPEND="${CDEPEND}
 !dev-db/postgresql-docs:${SLOT}
@@ -85,17 +97,8 @@ RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	ewarn "You are using a live ebuild that uses the current source code as it is"
-	ewarn "available from PostgreSQL's Git repository at emerge time. Given such,"
-	ewarn "the GNU Makefiles may be altered by upstream without notice and the"
-	ewarn "documentation for this live version is not readily available"
-	ewarn "online. Ergo, the ebuild maintainers will not support building a"
-	ewarn "client-only and/or document-free version."
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	enewgroup postgres 70
 	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
@@ -116,6 +119,12 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || epatch "${FILESDIR}/${PN}-${SLOT}.1-no-server.patch"
+
+	# Fix bug 486556 where the server would crash at start up because of
+	# an infinite loop caused by a self-referencing symlink.
+	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
+
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
@@ -137,6 +146,17 @@ src_configure() {
 
 	local PO="${EPREFIX%/}"
 
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
 	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
@@ -155,7 +175,7 @@ src_configure() {
 		$(use_with readline) \
 		$(use_with ssl openssl) \
 		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
@@ -163,41 +183,119 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
 	dodoc README HISTORY doc/{TODO,bug.template}
 
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
 	insinto /etc/postgresql-${SLOT}
 	newins src/bin/psql/psqlrc.sample psqlrc
 
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
 	use static-libs || find "${ED}" -name '*.a' -delete
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
+
+	local linkname mansec
+	for mansec in {1,3,7} ; do
+		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
+			bn=$(basename "${f}")
+			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
+			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
+				  /usr/share/man/man${mansec}/${linkname}
+		done
+	done
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.service" | \
-		systemd_newunit - ${PN}-${SLOT}.service
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
 
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
 
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 0775 /run/postgresql
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.service" | \
+			systemd_newunit - ${PN}-${SLOT}.service
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 0775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql96). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
 	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
 }
 
 pkg_postinst() {
@@ -206,35 +304,29 @@ pkg_postinst() {
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
 		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
+		elog "Official documentation:"
+		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT%/}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
 		elog "environment:"
-		elog "    source /etc/profile"
+		elog "    emerge --config =${CATEGORY}/${PF}"
 	fi
-
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT%/}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT%/}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -249,6 +341,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
@@ -297,21 +391,10 @@ pkg_config() {
 	einfo "The database cluster will be created in:"
 	einfo "    ${DATA_DIR}"
 	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
 
 	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
 		eerror "The given directory, '${DATA_DIR}', is not empty."
@@ -339,6 +422,10 @@ pkg_config() {
 		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
 	fi
 
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
 	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
 		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
 		# On the off-chance that you might need to work with UTF-8 encoded
@@ -371,17 +458,17 @@ pkg_config() {
 }
 
 src_test() {
-	einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
 		[[ ${UID} -eq 0 ]] || \
-			ewarn "Tests cannot be run as root. Enable 'userpriv' in FEATURES."
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
 
-		ewarn "Skipping."
+		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild
index 6a995c154ba..4ef8157f431 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -10,8 +10,8 @@ inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
 
 KEYWORDS=""
 
-# Fix if needed
-SLOT="9.7"
+# Bump when rc released.
+SLOT="10"
 
 EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
 
@@ -39,7 +39,7 @@ wanted_languages() {
 }
 
 CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
+>=app-eselect/eselect-postgresql-2.0
 sys-apps/less
 virtual/libintl
 kerberos? ( virtual/krb5 )
@@ -174,17 +174,13 @@ src_install() {
 	insinto /etc/postgresql-${SLOT}
 	newins src/bin/psql/psqlrc.sample psqlrc
 
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
 	use static-libs || find "${ED}" -name '*.a' -delete
 
 	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
+		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
 
 	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
+		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
 
 	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
 		"${FILESDIR}/${PN}.service" | \
@@ -194,26 +190,74 @@ src_install() {
 
 	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
 
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
+
+	local linkname mansec
+	for mansec in {1,3,7} ; do
+		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
+			bn=$(basename "${f}")
+			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
+			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
+				  /usr/share/man/man${mansec}/${linkname}
+		done
+	done
+
 	if use prefix ; then
 		keepdir /run/postgresql
 		fperms 0775 /run/postgresql
 	fi
 }
 
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql97). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst().  We
+	# only worry about the 9.7 slot as that's the last slot that had its
+	# slot-specific links generated by eselect.
+	#
+	# This can be removed when 10 is the lowest slot in the tree.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
+	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
+}
+
 pkg_postinst() {
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
 	elog
 	elog "Gentoo specific documentation:"
 	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
@@ -297,21 +341,10 @@ pkg_config() {
 	einfo "The database cluster will be created in:"
 	einfo "    ${DATA_DIR}"
 	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
 
 	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
 		eerror "The given directory, '${DATA_DIR}', is not empty."
@@ -339,6 +372,10 @@ pkg_config() {
 		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
 	fi
 
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
 	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
 		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
 		# On the off-chance that you might need to work with UTF-8 encoded


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2017-05-31 16:48 Patrice Clement
  0 siblings, 0 replies; 14+ messages in thread
From: Patrice Clement @ 2017-05-31 16:48 UTC (permalink / raw
  To: gentoo-commits

commit:     c5244125f049f0de1b4055169ea2c37958c612a4
Author:     Chris Mayo <aklhfex <AT> gmail <DOT> com>
AuthorDate: Mon May 15 18:51:11 2017 +0000
Commit:     Patrice Clement <monsieurp <AT> gentoo <DOT> org>
CommitDate: Wed May 31 16:47:32 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c5244125

dev-db/postgresql: change systemd unit type to notify.

Add systemd USE flag to control required configure option and dependency.

Default events that used to be written to postmaster.log will now be written to
the location specified by DefaultStandardOutput and DefaultStandardError in
system.conf.

Package-Manager: Portage-2.3.5, Repoman-2.3.2
Closes: https://github.com/gentoo/gentoo/pull/4557

 dev-db/postgresql/files/postgresql.service-9.6     |  56 +++++
 ...esql-9999.ebuild => postgresql-9.6.3-r1.ebuild} | 227 +++++++++++++--------
 dev-db/postgresql/postgresql-9999.ebuild           |  23 ++-
 3 files changed, 215 insertions(+), 91 deletions(-)

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 00000000000..89ec2d5cf7c
--- /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/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9.6.3-r1.ebuild
similarity index 65%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.6.3-r1.ebuild
index 4c37f742af7..2a849b459b1 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.6.3-r1.ebuild
@@ -5,15 +5,17 @@ EAPI="5"
 
 PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
 
-inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
-		python-single-r1 systemd user versionator
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+		systemd user versionator
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-# Bump when rc released.
-SLOT="10"
+SLOT="$(get_version_component_range 1-2)"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
@@ -21,8 +23,8 @@ HOMEPAGE="http://www.postgresql.org/"
 
 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
 		 zh_CN zh_TW"
-IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
+IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
+	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
 
 for lingua in ${LINGUAS}; do
 	IUSE+=" linguas_${lingua}"
@@ -53,31 +55,42 @@ ssl? (
 	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
 	libressl? ( dev-libs/libressl:= )
 )
+server? ( systemd? ( sys-apps/systemd ) )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
 "
 
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
 DEPEND="${CDEPEND}
 !!<sys-apps/sandbox-2.0
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.2
-app-text/docbook-xml-dtd:4.2
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
-src_unpack() {
-	base_src_unpack
-	git-2_src_unpack
-}
 
 RDEPEND="${CDEPEND}
 !dev-db/postgresql-docs:${SLOT}
@@ -86,17 +99,8 @@ RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	ewarn "You are using a live ebuild that uses the current source code as it is"
-	ewarn "available from PostgreSQL's Git repository at emerge time. Given such,"
-	ewarn "the GNU Makefiles may be altered by upstream without notice and the"
-	ewarn "documentation for this live version is not readily available"
-	ewarn "online. Ergo, the ebuild maintainers will not support building a"
-	ewarn "client-only and/or document-free version."
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	enewgroup postgres 70
 	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
@@ -117,6 +121,12 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || epatch "${FILESDIR}/${PN}-${SLOT}.1-no-server.patch"
+
+	# Fix bug 486556 where the server would crash at start up because of
+	# an infinite loop caused by a self-referencing symlink.
+	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
+
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
@@ -138,6 +148,17 @@ src_configure() {
 
 	local PO="${EPREFIX%/}"
 
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
 	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
@@ -155,8 +176,9 @@ src_configure() {
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
@@ -164,33 +186,35 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
 	dodoc README HISTORY doc/{TODO,bug.template}
 
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
 	insinto /etc/postgresql-${SLOT}
 	newins src/bin/psql/psqlrc.sample psqlrc
 
 	use static-libs || find "${ED}" -name '*.a' -delete
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.service" | \
-		systemd_newunit - ${PN}-${SLOT}.service
-
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
 	local f bn
 	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
 					-mindepth 1 -maxdepth 1)
@@ -213,22 +237,46 @@ src_install() {
 		done
 	done
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 0775 /run/postgresql
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+		fi
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 0775 /run/postgresql
+		fi
 	fi
 }
 
 pkg_preinst() {
 	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
+	# /usr/bin/psql96). They may have been created by the
 	# postgresql.eselect module, but they're handled within this ebuild
 	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
 	local canonicalise
 	if type -p realpath > /dev/null; then
 		canonicalise=realpath
@@ -243,7 +291,9 @@ pkg_preinst() {
 	# First remove any symlinks in /usr/bin that may have been created
 	# by the old eselect
 	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
 	done
 
 	# Then move the symlinks created by the ebuild to their proper place.
@@ -259,27 +309,29 @@ pkg_postinst() {
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT%/}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT%/}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT%/}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -294,6 +346,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
@@ -389,9 +443,11 @@ pkg_config() {
 	einfo "by default. You can disable it in the cluster's:"
 	einfo "    ${PGDATA%/}/postgresql.conf"
 	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
+	if ! use systemd; then
+		einfo "The PostgreSQL server, by default, will log events to:"
+		einfo "    ${DATA_DIR%/}/postmaster.log"
+		einfo
+	fi
 	if use prefix ; then
 		einfo "The location of the configuration files have moved to:"
 		einfo "    ${PGDATA}"
@@ -402,6 +458,9 @@ pkg_config() {
 		einfo
 		einfo "Or move the configuration files back:"
 		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	elif use systemd; then
+		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
 	else
 		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
 		einfo "instead of 'pg_ctl'."
@@ -409,17 +468,17 @@ pkg_config() {
 }
 
 src_test() {
-	einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
 		[[ ${UID} -eq 0 ]] || \
-			ewarn "Tests cannot be run as root. Enable 'userpriv' in FEATURES."
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
 
-		ewarn "Skipping."
+		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild
index 4c37f742af7..cbc1266c206 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -22,7 +22,7 @@ HOMEPAGE="http://www.postgresql.org/"
 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
 		 zh_CN zh_TW"
 IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
+	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
 
 for lingua in ${LINGUAS}; do
 	IUSE+=" linguas_${lingua}"
@@ -53,6 +53,7 @@ ssl? (
 	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
 	libressl? ( dev-libs/libressl:= )
 )
+server? ( systemd? ( sys-apps/systemd ) )
 tcl? ( >=dev-lang/tcl-8:0= )
 uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
@@ -155,6 +156,7 @@ src_configure() {
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
 		$(use_with uuid ossp-uuid) \
 		$(use_with xml libxml) \
@@ -183,9 +185,11 @@ src_install() {
 	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
 		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.service" | \
-		systemd_newunit - ${PN}-${SLOT}.service
+	if use systemd; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.service-9.6" | \
+			systemd_newunit - ${PN}-${SLOT}.service
+	fi
 
 	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
 
@@ -389,9 +393,11 @@ pkg_config() {
 	einfo "by default. You can disable it in the cluster's:"
 	einfo "    ${PGDATA%/}/postgresql.conf"
 	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
+	if ! use systemd; then
+		einfo "The PostgreSQL server, by default, will log events to:"
+		einfo "    ${DATA_DIR%/}/postmaster.log"
+		einfo
+	fi
 	if use prefix ; then
 		einfo "The location of the configuration files have moved to:"
 		einfo "    ${PGDATA}"
@@ -402,6 +408,9 @@ pkg_config() {
 		einfo
 		einfo "Or move the configuration files back:"
 		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	elif use systemd; then
+		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
 	else
 		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
 		einfo "instead of 'pg_ctl'."


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2017-07-13 15:34 Aaron Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron Swenson @ 2017-07-13 15:34 UTC (permalink / raw
  To: gentoo-commits

commit:     fcfc94349d709fff8645a467873bf19d7bdfe566
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 13 15:33:54 2017 +0000
Commit:     Aaron Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Thu Jul 13 15:33:54 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fcfc9434

dev-db/postgresql: 10_beta2 Version Bump

Added 10_beta2, and bumped the slot on the live ebuild.

Package-Manager: Portage-2.3.6, Repoman-2.3.1

 dev-db/postgresql/Manifest                         |   1 +
 .../files/postgresql-10beta2-no-server.patch       | 146 +++++++++++
 ...esql-9999.ebuild => postgresql-10_beta2.ebuild} | 277 ++++++++++++---------
 dev-db/postgresql/postgresql-9999.ebuild           |  28 ++-
 4 files changed, 325 insertions(+), 127 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 2058e113e42..e6c7f829533 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,3 +1,4 @@
+DIST postgresql-10beta2.tar.bz2 19790809 SHA256 0d6b50236039fc92e8784bd908b452c38ef63c0f9029f34e7115fbc30e17b195 SHA512 58abb8e38252ddf50d975588c9d43bf28d1169b499d068ace9324c6380ac1916975ca9a9a708dffb499e333e8b85c381efe8821166e2071236d6c8c4498f97a0 WHIRLPOOL 920fbc7459f0f9a9a3b72200ab2a4042672f351dc5b63dc7b63e2fafe0a74838fff1da0d814c37d81d28dc07e85bd4f14330ac367df2fb61f1ed0f56927e2131
 DIST postgresql-9.1.24.tar.bz2 15863767 SHA256 de0d84e9f32af145fcd66d8d324f6ef1a0b17944ea344b7bbe9d99fff68ae5d3 SHA512 a9ad0d62846598afee317eeda83406b5f85a658bfe7eb78aff6c59c904223dd165adbd5870598b74aa0e012878489f0c285e6ac7b07ebddf3cf8d81ba70bea7e WHIRLPOOL f58d79df5562c3fc22dae96ba064e19a4c83f42358911575f854cb2e062457f9331547cb19f9970003a2e15b7e8c609b9aab2a1e17099a446c89786581ccb13b
 DIST postgresql-9.2.19.tar.bz2 16466698 SHA256 1d29d73a4f590fcc348280f13ac2ff6a0f72c94908c54e3c20b7ab1560e8dbad SHA512 d3b4c5578bf6d6580028e775bff81a921258cb53b6b06567d96a352d14f3b63063adb480b2f5e2029baf8a034e14b5cd75eebc04f1ed7b16c849e1a5ec1f4867 WHIRLPOOL c13b45fd7aee08ea472557c9f40d79c45abd572fefcc215002b562b8046b1937bf522f6f7f6e280ff1e434c9698734cda9f1c3dacd3c8fee5f33dad0da21f75f
 DIST postgresql-9.2.20.tar.bz2 16480653 SHA256 0b8abdae8400cabea5587a726003c9dd71c73c049bdae523abc35f9312dd8f26 SHA512 16f7861e0372481dbc5c69ac977bab46f592045f32951a245f3677121261640fcc169a75e730d592e36c15c9a120e7d06755550bdabf121ad89d76a17535d0f9 WHIRLPOOL af5005564056185fa240fd97bec862738f9951bb57082485beba3eacf5d8bf709c58d01f8bde656a391eee173d592d9cf792be87de04a09869aa3d82c8719320

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 00000000000..8c88465e7bd
--- /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/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-10_beta2.ebuild
similarity index 63%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-10_beta2.ebuild
index cbc1266c206..6ccc0c76d15 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-10_beta2.ebuild
@@ -1,28 +1,31 @@
 # Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI="5"
+EAPI="6"
 
 PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
 
-inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
-		python-single-r1 systemd user versionator
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+		systemd user versionator
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-# Bump when rc released.
-SLOT="10"
+SLOT=$(get_major_version)
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
 HOMEPAGE="http://www.postgresql.org/"
 
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
+LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
+		 zh_TW"
+IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
+	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
+	  xml zlib"
 
 for lingua in ${LINGUAS}; do
 	IUSE+=" linguas_${lingua}"
@@ -49,36 +52,46 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8:= )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
 ssl? (
 	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
 	libressl? ( dev-libs/libressl:= )
 )
-server? ( systemd? ( sys-apps/systemd ) )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
 "
 
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
 DEPEND="${CDEPEND}
 !!<sys-apps/sandbox-2.0
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.2
-app-text/docbook-xml-dtd:4.2
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
-src_unpack() {
-	base_src_unpack
-	git-2_src_unpack
-}
 
 RDEPEND="${CDEPEND}
 !dev-db/postgresql-docs:${SLOT}
@@ -87,17 +100,8 @@ RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	ewarn "You are using a live ebuild that uses the current source code as it is"
-	ewarn "available from PostgreSQL's Git repository at emerge time. Given such,"
-	ewarn "the GNU Makefiles may be altered by upstream without notice and the"
-	ewarn "documentation for this live version is not readily available"
-	ewarn "online. Ergo, the ebuild maintainers will not support building a"
-	ewarn "client-only and/or document-free version."
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	enewgroup postgres 70
 	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
@@ -118,13 +122,19 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || eapply "${FILESDIR}/${PN}-${SLOT}beta2-no-server.patch"
+
+	# Fix bug 486556 where the server would crash at start up because of
+	# an infinite loop caused by a self-referencing symlink.
+	#eapply "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
+
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
 			die 'PGSQL_PAM_SERVICE rename failed.'
 	fi
 
-	epatch_user
+	eapply_user
 }
 
 src_configure() {
@@ -139,6 +149,17 @@ src_configure() {
 
 	local PO="${EPREFIX%/}"
 
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
 	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
@@ -158,7 +179,7 @@ src_configure() {
 		$(use_with ssl openssl) \
 		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
@@ -166,34 +187,64 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
 	dodoc README HISTORY doc/{TODO,bug.template}
 
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
 
-	use static-libs || find "${ED}" -name '*.a' -delete
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
+			bn=$(basename "${f}")
+			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
+		done
 
-	if use systemd; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service-9.6" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-	fi
+		popd > /dev/null
+	done
 
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
 
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+	use static-libs || find "${ED}" -name '*.a' -delete
 
 	local f bn
 	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
@@ -204,57 +255,39 @@ src_install() {
 		# issue. This is only necessary for 9.7 and earlier. 10 never
 		# had this issue.
 		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
+			  "/usr/bin/${bn}${SLOT/.}"
 	done
 
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 0775 /run/postgresql
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
 	fi
-}
 
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
 
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
-	done
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
 
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+		fi
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 0775 /run/postgresql
+		fi
+	fi
 }
 
 pkg_postinst() {
@@ -263,27 +296,29 @@ pkg_postinst() {
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT%/}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT%/}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT%/}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -298,6 +333,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
@@ -418,17 +455,17 @@ pkg_config() {
 }
 
 src_test() {
-	einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
 		[[ ${UID} -eq 0 ]] || \
-			ewarn "Tests cannot be run as root. Enable 'userpriv' in FEATURES."
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
 
-		ewarn "Skipping."
+		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild
index cbc1266c206..0245d247103 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -11,7 +11,7 @@ inherit eutils flag-o-matic git-2 linux-info multilib pam prefix \
 KEYWORDS=""
 
 # Bump when rc released.
-SLOT="10"
+SLOT="11"
 
 EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
 
@@ -207,14 +207,28 @@ src_install() {
 			  "/usr/bin/${bn}${SLOT/.}tmp"
 	done
 
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
+
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null
+
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
 			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
+			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
 		done
+
+		popd > /dev/null
 	done
 
 	if use prefix ; then


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2017-08-10 15:16 Aaron Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron Swenson @ 2017-08-10 15:16 UTC (permalink / raw
  To: gentoo-commits

commit:     24455ca948572a132da179a8ee8f18402467aadb
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 10 15:16:20 2017 +0000
Commit:     Aaron Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Thu Aug 10 15:16:20 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=24455ca9

dev-db/postgresql: Clean out old and unused

Package-Manager: Portage-2.3.6, Repoman-2.3.1

 dev-db/postgresql/Manifest                         |   8 -
 .../files/postgresql-9.0-no-server.patch           | 135 ------
 .../files/postgresql-9.4-no-server.patch           | 151 -------
 dev-db/postgresql/files/postgresql.init-pre_9.2    | 139 ------
 dev-db/postgresql/postgresql-10_beta2.ebuild       | 469 --------------------
 dev-db/postgresql/postgresql-9.1.24.ebuild         | 384 -----------------
 dev-db/postgresql/postgresql-9.2.20-r1.ebuild      | 435 -------------------
 dev-db/postgresql/postgresql-9.2.20.ebuild         | 394 -----------------
 dev-db/postgresql/postgresql-9.2.21-r1.ebuild      | 435 -------------------
 dev-db/postgresql/postgresql-9.3.16-r1.ebuild      | 440 -------------------
 dev-db/postgresql/postgresql-9.3.16.ebuild         | 399 -----------------
 dev-db/postgresql/postgresql-9.3.17-r1.ebuild      | 440 -------------------
 dev-db/postgresql/postgresql-9.4.11-r1.ebuild      | 472 --------------------
 dev-db/postgresql/postgresql-9.4.11.ebuild         | 431 -------------------
 dev-db/postgresql/postgresql-9.4.12-r1.ebuild      | 472 --------------------
 dev-db/postgresql/postgresql-9.5.6-r1.ebuild       | 478 ---------------------
 dev-db/postgresql/postgresql-9.5.6.ebuild          | 441 -------------------
 dev-db/postgresql/postgresql-9.6.1-r1.ebuild       | 438 -------------------
 dev-db/postgresql/postgresql-9.6.2-r1.ebuild       | 475 --------------------
 dev-db/postgresql/postgresql-9.6.2.ebuild          | 438 -------------------
 dev-db/postgresql/postgresql-9.6.3.ebuild          | 475 --------------------
 21 files changed, 7949 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 8fe58158126..1f6e3ba7512 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,23 +1,15 @@
-DIST postgresql-10beta2.tar.bz2 19790809 SHA256 0d6b50236039fc92e8784bd908b452c38ef63c0f9029f34e7115fbc30e17b195 SHA512 58abb8e38252ddf50d975588c9d43bf28d1169b499d068ace9324c6380ac1916975ca9a9a708dffb499e333e8b85c381efe8821166e2071236d6c8c4498f97a0 WHIRLPOOL 920fbc7459f0f9a9a3b72200ab2a4042672f351dc5b63dc7b63e2fafe0a74838fff1da0d814c37d81d28dc07e85bd4f14330ac367df2fb61f1ed0f56927e2131
 DIST postgresql-10beta3.tar.bz2 19914123 SHA256 6722546739f8e2dd379e8031784e86c5c588638df6c477046ebdd479586bcb3e SHA512 cdbda1c17d58f2999ad71a208d6aa3b18b82bfc8f185eb4ce36496b27ae23bca03f76925e4b242a4c3c2eec96ca0b135e696f55b59282b208ecfe7f8b642f24f WHIRLPOOL 5db99df6c8d0b455a3e6c8d4a734be52bb5dc6b3225cb0f3d547ea22e87e4eae45709667bad71bc1fe8e7f024345c1b9e186b07faf9c23a9db046c9bfc01e8af
-DIST postgresql-9.1.24.tar.bz2 15863767 SHA256 de0d84e9f32af145fcd66d8d324f6ef1a0b17944ea344b7bbe9d99fff68ae5d3 SHA512 a9ad0d62846598afee317eeda83406b5f85a658bfe7eb78aff6c59c904223dd165adbd5870598b74aa0e012878489f0c285e6ac7b07ebddf3cf8d81ba70bea7e WHIRLPOOL f58d79df5562c3fc22dae96ba064e19a4c83f42358911575f854cb2e062457f9331547cb19f9970003a2e15b7e8c609b9aab2a1e17099a446c89786581ccb13b
 DIST postgresql-9.2.19.tar.bz2 16466698 SHA256 1d29d73a4f590fcc348280f13ac2ff6a0f72c94908c54e3c20b7ab1560e8dbad SHA512 d3b4c5578bf6d6580028e775bff81a921258cb53b6b06567d96a352d14f3b63063adb480b2f5e2029baf8a034e14b5cd75eebc04f1ed7b16c849e1a5ec1f4867 WHIRLPOOL c13b45fd7aee08ea472557c9f40d79c45abd572fefcc215002b562b8046b1937bf522f6f7f6e280ff1e434c9698734cda9f1c3dacd3c8fee5f33dad0da21f75f
-DIST postgresql-9.2.20.tar.bz2 16480653 SHA256 0b8abdae8400cabea5587a726003c9dd71c73c049bdae523abc35f9312dd8f26 SHA512 16f7861e0372481dbc5c69ac977bab46f592045f32951a245f3677121261640fcc169a75e730d592e36c15c9a120e7d06755550bdabf121ad89d76a17535d0f9 WHIRLPOOL af5005564056185fa240fd97bec862738f9951bb57082485beba3eacf5d8bf709c58d01f8bde656a391eee173d592d9cf792be87de04a09869aa3d82c8719320
 DIST postgresql-9.2.21.tar.bz2 16508040 SHA256 0697e843523ee60c563f987f9c65bc4201294b18525d6e5e4b2c50c6d4058ef9 SHA512 c548cd1ba34ad71dd3f1acde5775ba2e71121f004324fac44dbe123a91d599ced0f1b8be675ed07b77712e8c23f376ff6221349385c19a88c4edbbb186f17861 WHIRLPOOL c46fd4909e2d534b98c8a97f0f5410ab40285c118517a36ee73d0e1234483144d1f58785a59df53fdbfab7c2876a60d000bf574dff0be3030f8c909509b1bfe6
 DIST postgresql-9.2.22.tar.bz2 16531224 SHA256 a70e94fa58776b559a8f7b5301371ac4922c9e3ed313ccbef20862514de7c192 SHA512 3e5ab04c2be2719579b2ebbf64b220522acfd9ea74029dd2ed699f60230da224bdc99de4ee5529b513e5586de0377764c4e54deb3dd93d5c53c4d666dce2b6b7 WHIRLPOOL ff1817463b488f4793cd0851df846b961d5510b7c1cf4a560717755ca47c363eb782bc1f2cd7a5d8cbc49727dea64394c6b30038105fc584749157157948964d
 DIST postgresql-9.3.15.tar.bz2 17059932 SHA256 a9fcba1446a93aa95e3e1b6535756f0472d10b0f267a0845f8b2b29f89de5c4f SHA512 35c30cdb5599f99c94ab921f9f5e7671a8c0b7bca8fe3b616630ae13d6eda8d329e77e7e802da6a83cb09c3c9ca10fa8ce0de8a184e6fff471130e1cd68ce762 WHIRLPOOL 7a627b2da1dc3671df7edfe58420f81ce24202c1251225054674d79e431bc36e1a70c84aaacb76c59e9eefb26429cbbb9ea80c45a989e3564b69e334d3dd4d84
-DIST postgresql-9.3.16.tar.bz2 17108969 SHA256 845f5e4ac8cf026b6a77c5a180a2fe869f51e9d06acf8d0365b05505a2c66873 SHA512 2e379aca5db79ab5795e6f1e4ff8b21b1aa284cfb0d34655430d8b959cebac7982ee6eda66833a1fb208a36a51251c946565982cd5dff619ab334603ded530e7 WHIRLPOOL fea45fb6563fc4c56a1853baf83bbdd59991871176aa00a4fcdda5e95a9277d187ddd2fc5d0c3c76f090e7a359d2d5af140e8af3f6a964897beb41ef8435483e
 DIST postgresql-9.3.17.tar.bz2 17158802 SHA256 9c03e5f280cfe9bd202fa01af773eb146abd8ab3065f7279d574c568f6948dbe SHA512 4b6fc079c2bb728b13b72eb2f7d92183ffb1a9b32110d99dfce674032ac499963b75a021265ba08dc95c34ae35a7edac65ef1e658e66ee2da41c1ce646a702dc WHIRLPOOL f573aaa6acf6d542ed647f392bdb42cd60f650e66174c603f0344d64e2962f2fbb46f0233226188ee9a3a75b2de6532738aac28876bd097556eb4f6c0de21667
 DIST postgresql-9.3.18.tar.bz2 17194269 SHA256 ad60d12a5a3dd0f6f5904c41b87e43eff49d3f74e45129fe52c5744366ff2fe0 SHA512 df3f2e0bb396cac74021fcc1a989d04515c12e73846b7392ae859c32668d73ae0027607426072672b6228d7533cc512f72b5729bf5c8f7b0e8d0270727784455 WHIRLPOOL c5b3db88e01c507556b354acb1ecf2bbf43246d023c5d9e1d8479ce4aa9944beca518abbd3e810830af1d75356272b4df3eb58358edfdd265cdc395f62ac8c33
 DIST postgresql-9.4.10.tar.bz2 17802812 SHA256 7061678bed1981c681ce54c76b98b6ec17743f090a9775104a45e7e1a8826ecf SHA512 2fcf47769b22c69bc82c9d6edc317e18dfcb4a96534e012bae4355e5088afa83da98b21e08a07766794f0a166888acbd16705a806464ea11711ed97c3b4012fb WHIRLPOOL e6ed3c209043cbbacb0698e1be367f20028d649d4cff62b5d6edd162c6ad629a3ec5f55854bd12334a3d3165462fecb34188bd62cd398cfc242a3579810b5b85
-DIST postgresql-9.4.11.tar.bz2 17832915 SHA256 e3eb51d045c180b03d2de1f0c3af9356e10be49448e966ca01dfc2c6d1cc9d23 SHA512 a3ed866d82ab4b90c2a7ec2abec0308015845947f42b76e420cce8f268e1c374806a9fab00ba0563d742a53014a30fa0eaa90804a09fd162b76fcbfbeff6b70f WHIRLPOOL cb53a9e1ee518b43c8be135e3b09005314c8dd108eacd37e6a5be45b2391b31a4acf8427c7aac86524f0ef0e264b46329c97aa5b01e6c4d0b63cd6f7e081697c
 DIST postgresql-9.4.12.tar.bz2 17833119 SHA256 fca055481875d1c49e31c28443f56472a1474b3fbe25b7ae64440c6118f82e64 SHA512 69951f9e66069aad1049a0ea9fdcd7bf2f84b42e7c6e0f761d78ab22131a39cf56448ef0ddc28170b66970bf53edf2d2355530fcfc0a2dca92b66d69686b7ecb WHIRLPOOL ca023aab29d7993e236c52df58d6fae6f9bd1649cf20f1e1b118ff232dc41674001d3dc9bc945e3f9dd61779dde27cb93265b89d3615e47f49ea46751d8e97c3
 DIST postgresql-9.4.13.tar.bz2 17867502 SHA256 0080f55d65194de8b96a2dab153443f8248ff2b2b10e6ab4cda2dcadcac7f2ab SHA512 98e5721ab1ebc88070a5c2c9ef10e4fc21825de495db71f011577aa15fdd31c2dc0429d48e1624f7161c9d31dd75de4d8cf4ed2e34006ed6d1852f04a948e932 WHIRLPOOL 4f963b81dca21a2f3f5e047b5cfd1796d103c0648c4af0250ffe2274ed71011634dfc1e8387fe6dfa6589585a8fcb5accc9878c461978b9abd483b85f6ea3e68
 DIST postgresql-9.5.5.tar.bz2 18525082 SHA256 02c65290be74de6604c3fed87c9fd3e6b32e949f0ab8105a75bd7ed5aa71f394 SHA512 727ab57796cd393ec3755e9aabf515ebbdc3152b4062c20e64511e866a7e7038ba5c5e2843f13f3a79e2263296451f0e93108346b6f638611fba2449394e338e WHIRLPOOL ec5262fd8cecea20fd12bcec8e6e015817ae8181d9e9ff6d8aca6ed43cadedac1bd5006c3d04262b99b9a79aa02c409920ab3392136f3ff3dc480fe1155cade8
-DIST postgresql-9.5.6.tar.bz2 18598551 SHA256 bb9e5f6d34e20783e96e10c1d6c0c09c31749e802aaa46b793ce2522725ae12f SHA512 fabaeb2d4841ca2f2fd7b0f9c90368debc91f569ade5ad4dc9250c27d790a97ed58a670319f0fe59404fce7e986e8dafb1408edbe6fc149531bdb230b1b913fe WHIRLPOOL 257aa2d2a71b12b13da958563197b9bd0acc6c4a0d3b96787ad2d202414d074629f4b39c8291cae4770b2d867a4b331214f404eaef84a37278d3aa90147d14de
 DIST postgresql-9.5.7.tar.bz2 18639775 SHA256 8b1e936f82109325decc0f5575e846b93fb4fd384e8c4bde83ff5e7f87fc6cad SHA512 0f879a8d7587739aa9a696d60f909f819d567c67dff7c730d5e856639ed78ebc35beeb3cdaf782573d7e62c7056560a934f64cf11ccac6e309f58bb82d1ca78f WHIRLPOOL d58fb5bc378a58efaf2be8d689bd6d511170c3de18e5300ed46be51e272654d52807fd9a783b6a3ec30a022a44577edb19d6627e5153b5e14259de5571ba15bb
 DIST postgresql-9.5.8.tar.bz2 18670910 SHA256 ade57068f134f36710fa953e1ef79185abd96572f8098741413132f79ed37202 SHA512 4a11f0a16df460391c8250122ca8bf1ab76e49672a8c003ed09718bb4ce2aa57757e7aaec6e41b53d0d1ada293172b974761606647fcc8b4fce8807490b6ef10 WHIRLPOOL 7688ddeea69449d2e2a518017d306f6c17a08becb258297cbf4bde9f3734c5ba2129a9660b448df458963a7cdc796bbb72f2798c20abd3d50d1be8d4f3f94ec1
-DIST postgresql-9.6.1.tar.bz2 19260568 SHA256 e5101e0a49141fc12a7018c6dad594694d3a3325f5ab71e93e0e51bd94e51fcd SHA512 f27af67f9a96f6327150330bf091a803e10eabbac4e488cf5e4d72907e2eb1dbde7282fe0b89fd75711fd8bdcdb3688b5a9eac1e4d6871f4e8681c9c8b0e7c45 WHIRLPOOL 1ea7933817895ec4ddd531b60eead2c0c3324b90fe48224bd49748d11e76313bb7699670edaf5c8f41b8424026bed59d29aab69208c5ced5161196a4827c78f8
-DIST postgresql-9.6.2.tar.bz2 19478040 SHA256 0187b5184be1c09034e74e44761505e52357248451b0c854dddec6c231fe50c9 SHA512 7c9d61a591408e29d7dc70d6b28ecdf06edf7f8fbf4e014e60a1e4f841fd5734c74a820094f6153e10ef633d48ea73f2a85194f6d2cd519a8f7087a261e9e02b WHIRLPOOL 0d3981d2990186967ad61c84a02cadf680015e4dc41ff6bb9bb0ed0936979abe6561f2a730ef000173ee8635a6859361b6ce174afbda837defb50300e1cfc909
 DIST postgresql-9.6.3.tar.bz2 19534323 SHA256 1645b3736901f6d854e695a937389e68ff2066ce0cde9d73919d6ab7c995b9c6 SHA512 97141972e154e6b0e756ee6a4e20f26e82022a9fd4c56305314a3a5567a79ece638e4ac3d513b46138737ae6bd27a098f30013a94767db151181aac9c01290a1 WHIRLPOOL 774146faf5795796812e541d3c7a2ad9ce8125afdc64c0bfa599a733904f4efd3c73dfb907dbb66b6482b2d6efdbd9f2c0dcedffcc4e23bd6030e968a51db658
 DIST postgresql-9.6.4.tar.bz2 19566875 SHA256 2b3ab16d82e21cead54c08b95ce3ac480696944a68603b6c11b3205b7376ce13 SHA512 b0527efacce6efc09340b68c8c56483cd884676e01cb6bfb4f9ce63226a394bdb0bcf3d832f84e4dff5ceecf09ef4cf93e9fbd0ac453ec85efb11ac50a7dff39 WHIRLPOOL 6296114c2a6f690428754278d11fb93f2142c28bc36e0a17b4b075b60ee90bf708d73d68ff6e8118253ef22e54cd5e325094e3675eccb7f060e32af2572a65b0

diff --git a/dev-db/postgresql/files/postgresql-9.0-no-server.patch b/dev-db/postgresql/files/postgresql-9.0-no-server.patch
deleted file mode 100644
index 1b45cd954c5..00000000000
--- a/dev-db/postgresql/files/postgresql-9.0-no-server.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-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.4-no-server.patch b/dev-db/postgresql/files/postgresql-9.4-no-server.patch
deleted file mode 100644
index c46146e5ec9..00000000000
--- a/dev-db/postgresql/files/postgresql-9.4-no-server.patch
+++ /dev/null
@@ -1,151 +0,0 @@
-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.init-pre_9.2 b/dev-db/postgresql/files/postgresql.init-pre_9.2
deleted file mode 100644
index 0973087b315..00000000000
--- a/dev-db/postgresql/files/postgresql.init-pre_9.2
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/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 \
-        --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/postgresql-10_beta2.ebuild b/dev-db/postgresql/postgresql-10_beta2.ebuild
deleted file mode 100644
index 6560be4d50a..00000000000
--- a/dev-db/postgresql/postgresql-10_beta2.ebuild
+++ /dev/null
@@ -1,469 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT=$(get_major_version)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		 zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}beta2-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	#eapply "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.1.24.ebuild b/dev-db/postgresql/postgresql-9.1.24.ebuild
deleted file mode 100644
index d75c9142d26..00000000000
--- a/dev-db/postgresql/postgresql-9.1.24.ebuild
+++ /dev/null
@@ -1,384 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-# Testing within Portage's environment is broken, and the patch no
-# longer applies cleanly.
-RESTRICT="test"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	epatch "${FILESDIR}/pg_ctl-exit-status.patch"
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.1-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-pre_9.2" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	while [ "$correct" != "true" ] ; do
-		einfo "Are you ready to continue? (y/n)"
-		read answer
-		if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-			correct="true"
-		elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-			die "Aborting initialization."
-		else
-			echo "Answer not recognized"
-		fi
-	done
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.2.20-r1.ebuild b/dev-db/postgresql/postgresql-9.2.20-r1.ebuild
deleted file mode 100644
index 63786e00878..00000000000
--- a/dev-db/postgresql/postgresql-9.2.20-r1.ebuild
+++ /dev/null
@@ -1,435 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.2" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.2" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.2.20.ebuild b/dev-db/postgresql/postgresql-9.2.20.ebuild
deleted file mode 100644
index ea2a0341512..00000000000
--- a/dev-db/postgresql/postgresql-9.2.20.ebuild
+++ /dev/null
@@ -1,394 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	while [ "$correct" != "true" ] ; do
-		einfo "Are you ready to continue? (y/n)"
-		read answer
-		if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-			correct="true"
-		elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-			die "Aborting initialization."
-		else
-			echo "Answer not recognized"
-		fi
-	done
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.2.21-r1.ebuild b/dev-db/postgresql/postgresql-9.2.21-r1.ebuild
deleted file mode 100644
index 004acf03857..00000000000
--- a/dev-db/postgresql/postgresql-9.2.21-r1.ebuild
+++ /dev/null
@@ -1,435 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.2" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.2" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.3.16-r1.ebuild b/dev-db/postgresql/postgresql-9.3.16-r1.ebuild
deleted file mode 100644
index bf27a126ce0..00000000000
--- a/dev-db/postgresql/postgresql-9.3.16-r1.ebuild
+++ /dev/null
@@ -1,440 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.3.16.ebuild b/dev-db/postgresql/postgresql-9.3.16.ebuild
deleted file mode 100644
index 8d5aa3f04da..00000000000
--- a/dev-db/postgresql/postgresql-9.3.16.ebuild
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	while [ "$correct" != "true" ] ; do
-		einfo "Are you ready to continue? (y/n)"
-		read answer
-		if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-			correct="true"
-		elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-			die "Aborting initialization."
-		else
-			echo "Answer not recognized"
-		fi
-	done
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.3.17-r1.ebuild b/dev-db/postgresql/postgresql-9.3.17-r1.ebuild
deleted file mode 100644
index 32606fb69ed..00000000000
--- a/dev-db/postgresql/postgresql-9.3.17-r1.ebuild
+++ /dev/null
@@ -1,440 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.4.11-r1.ebuild b/dev-db/postgresql/postgresql-9.4.11-r1.ebuild
deleted file mode 100644
index c59e32ab3ae..00000000000
--- a/dev-db/postgresql/postgresql-9.4.11-r1.ebuild
+++ /dev/null
@@ -1,472 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.4.11.ebuild b/dev-db/postgresql/postgresql-9.4.11.ebuild
deleted file mode 100644
index 771987a18c9..00000000000
--- a/dev-db/postgresql/postgresql-9.4.11.ebuild
+++ /dev/null
@@ -1,431 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	while [ "$correct" != "true" ] ; do
-		einfo "Are you ready to continue? (y/n)"
-		read answer
-		if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-			correct="true"
-		elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-			die "Aborting initialization."
-		else
-			echo "Answer not recognized"
-		fi
-	done
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.4.12-r1.ebuild b/dev-db/postgresql/postgresql-9.4.12-r1.ebuild
deleted file mode 100644
index e46feae1864..00000000000
--- a/dev-db/postgresql/postgresql-9.4.12-r1.ebuild
+++ /dev/null
@@ -1,472 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.5.6-r1.ebuild b/dev-db/postgresql/postgresql-9.5.6-r1.ebuild
deleted file mode 100644
index 71af0ab2c5a..00000000000
--- a/dev-db/postgresql/postgresql-9.5.6-r1.ebuild
+++ /dev/null
@@ -1,478 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-9.5.5-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	if use alpha && use server ; then
-		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
-		ewarn "As a result, performance will be extremely degraded."
-	fi
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.5.6.ebuild b/dev-db/postgresql/postgresql-9.5.6.ebuild
deleted file mode 100644
index 43e8649b9c3..00000000000
--- a/dev-db/postgresql/postgresql-9.5.6.ebuild
+++ /dev/null
@@ -1,441 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-9.5.5-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	if use alpha && use server ; then
-		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
-		ewarn "As a result, performance will be extremely degraded."
-	fi
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.1-r1.ebuild b/dev-db/postgresql/postgresql-9.6.1-r1.ebuild
deleted file mode 100644
index e453d379b99..00000000000
--- a/dev-db/postgresql/postgresql-9.6.1-r1.ebuild
+++ /dev/null
@@ -1,438 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}.1-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.2-r1.ebuild b/dev-db/postgresql/postgresql-9.6.2-r1.ebuild
deleted file mode 100644
index 80cb4316fd9..00000000000
--- a/dev-db/postgresql/postgresql-9.6.2-r1.ebuild
+++ /dev/null
@@ -1,475 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}.1-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.2.ebuild b/dev-db/postgresql/postgresql-9.6.2.ebuild
deleted file mode 100644
index e453d379b99..00000000000
--- a/dev-db/postgresql/postgresql-9.6.2.ebuild
+++ /dev/null
@@ -1,438 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}.1-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.3.ebuild b/dev-db/postgresql/postgresql-9.6.3.ebuild
deleted file mode 100644
index 80cb4316fd9..00000000000
--- a/dev-db/postgresql/postgresql-9.6.3.ebuild
+++ /dev/null
@@ -1,475 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
-		 zh_CN zh_TW"
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-
-for lingua in ${LINGUAS}; do
-	IUSE+=" linguas_${lingua}"
-done
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local enable_langs
-
-	for lingua in ${LINGUAS} ; do
-		use linguas_${lingua} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}.1-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	local linkname mansec
-	for mansec in {1,3,7} ; do
-		for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
-			bn=$(basename "${f}")
-			linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
-			dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
-				  /usr/share/man/man${mansec}/${linkname}
-		done
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2018-02-11 15:55 Aaron Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron Swenson @ 2018-02-11 15:55 UTC (permalink / raw
  To: gentoo-commits

commit:     850efe2a5700c2ba30f9e9860dd83143cf15da34
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 11 15:54:10 2018 +0000
Commit:     Aaron Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Sun Feb 11 15:54:38 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=850efe2a

dev-db/postgresql: Cleanup Old and Insecure Files

Bug: https://bugs.gentoo.org/627462
Bug: https://bugs.gentoo.org/636978
Bug: https://bugs.gentoo.org/630824
Bug: https://bugs.gentoo.org/603720
Bug: https://bugs.gentoo.org/603716
Package-Manager: Portage-2.3.19, Repoman-2.3.6

 dev-db/postgresql/Manifest                         |   6 -
 .../files/postgresql-9.2-9.4-tz-dir-overflow.patch |  16 -
 dev-db/postgresql/files/postgresql.confd           |  58 ---
 dev-db/postgresql/files/postgresql.init            | 137 -------
 dev-db/postgresql/files/postgresql.init-9.3        | 142 -------
 dev-db/postgresql/files/postgresql.service         |  55 ---
 dev-db/postgresql/files/postgresql.service-9.6     |  56 ---
 dev-db/postgresql/postgresql-9.2.19.ebuild         | 390 ------------------
 dev-db/postgresql/postgresql-9.2.22.ebuild         | 441 --------------------
 dev-db/postgresql/postgresql-9.2.23-r1.ebuild      | 445 ---------------------
 dev-db/postgresql/postgresql-9.2.23.ebuild         | 441 --------------------
 dev-db/postgresql/postgresql-9.3.15.ebuild         | 395 ------------------
 dev-db/postgresql/postgresql-9.4.10.ebuild         | 427 --------------------
 dev-db/postgresql/postgresql-9.5.5.ebuild          | 438 --------------------
 14 files changed, 3447 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index c95ed08cc42..1d45e013a07 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,17 +1,11 @@
 DIST postgresql-10.1.tar.bz2 19669989 BLAKE2B 2fbe782023b6d55c6fadaba38e517c60038b3b7b0a14fa8793043f7b9c4719a692440f286bb1f898045b5f56ef1c064f97f36e821990755077dc8d9bb0dbd639 SHA512 06050d353aa43f32e0de0199d833d8a4652aff893b718b1c40ed31837838f73fe4d977ac0f2164ab97b3eeff4aae3409f440601740898a893877d96bc0ed1882
 DIST postgresql-10.2.tar.bz2 19901836 BLAKE2B ea626774dc11463418b3d0126d04bd2d8eb7e8bb299551bff0c30c7f999f37a1f48e6bbfcde1ee15c0e0519e222bfe14f14d985503fe517a06f127009148ae98 SHA512 bac61644c12c31e2dce97ec0134902a2a7141e922619015425961b963961b21210ca840f59ba585d3d75c7e34cb640f2ebeaa2b25c4a866db68f5e73a8f8a448
-DIST postgresql-9.2.19.tar.bz2 16466698 BLAKE2B ca5e84ac33923b36639bee403935c14c87bf37cd8061eb1d82bc1816449910ebe1373f74c2467850650fb7c3cadfe049a168ddc4a7e64ce54515731df552992a SHA512 d3b4c5578bf6d6580028e775bff81a921258cb53b6b06567d96a352d14f3b63063adb480b2f5e2029baf8a034e14b5cd75eebc04f1ed7b16c849e1a5ec1f4867
-DIST postgresql-9.2.22.tar.bz2 16531224 BLAKE2B 2d3b73db5c3082872df824b8e14e65c6cf4f7389f88b7ed577ddf59570294e74a6392a27f78e77c5da2c974566b38deaa979511649a6e95f5323d3961c587f78 SHA512 3e5ab04c2be2719579b2ebbf64b220522acfd9ea74029dd2ed699f60230da224bdc99de4ee5529b513e5586de0377764c4e54deb3dd93d5c53c4d666dce2b6b7
-DIST postgresql-9.2.23.tar.bz2 16531436 BLAKE2B df12276856e17693f0f1b2623a96ca15cfea95dc6e67e349391a60ba49d9a252ee94448bc07cbc0290f29546ba8b87fa24f62ca8f27cde41d4400c3aa275d778 SHA512 9715cb9aa34921f7d246837c6c516d588f88fda543ad635520e9575a5ea448ad39062f2c89c086c7f129cc5f61f4dca33e4f5fd94e1df39da428507c56a81ba3
 DIST postgresql-9.2.24.tar.bz2 16552576 BLAKE2B 15e1fcc72830630c6c919113ed53c30c08f97c2543e678cac914b86456434d036f2efc262810e8f7ca0be714a8f690592a271ea5f6fb39777e73e94a9555e0ee SHA512 a6f043e5ef5e12e23c1c43b26a5ecafce62f3a86f38b5b85e7cb0cb7aa376d40e460a526baf67ae40de40525e4744fb5e48650ee5e007db4ce9742fcf548bd56
-DIST postgresql-9.3.15.tar.bz2 17059932 BLAKE2B c5afbdf3b1ffe457e137495001eb2f570adcf7844b909b62f3d077336d50b75d9fac456430c99df6449f1ea016252e9a99d96922fc3b5f21796c1361803312d6 SHA512 35c30cdb5599f99c94ab921f9f5e7671a8c0b7bca8fe3b616630ae13d6eda8d329e77e7e802da6a83cb09c3c9ca10fa8ce0de8a184e6fff471130e1cd68ce762
 DIST postgresql-9.3.20.tar.bz2 17197360 BLAKE2B 2b07f6ee78294a490a8902d0129ac6b5e729e2d9a30631becc193cb7561294354a779ffc62bd61e807b1f540f01ce095e8ae4ad77adf2ea135389143809c9d48 SHA512 40098661bf00b64ad2d773b242613c44fe269b5ae984ad8990f85ce705b27138b127493c507103052fb6705d52f2e63a1df6692c7024d43c3c6b18154f2ef407
 DIST postgresql-9.3.21.tar.bz2 17014472 BLAKE2B 7735e7150c0418f979110cef083235959d22f4b63756cf76b9715862cc409b89f51b3e49bad9a33771b4df3ed39c515cf356c2ed69b77a3c7cb8d3448c83a024 SHA512 4c34ddf140a28b7095f8853f85c85cdc4ac44e4e5062ef66542c3082ada8509a201e0037e75d880e7909e1b41d0e3577713ad981cea8e693fb87644a0dce9929
-DIST postgresql-9.4.10.tar.bz2 17802812 BLAKE2B 6f93a348ef51979b02c096d2c8fe980ce00e9fd1f9cf0766f3b06fa1ba9f52a146cffc205e7708c7bd16e0686486b21118734f4a1cd9823837abeee2e6fc9175 SHA512 2fcf47769b22c69bc82c9d6edc317e18dfcb4a96534e012bae4355e5088afa83da98b21e08a07766794f0a166888acbd16705a806464ea11711ed97c3b4012fb
 DIST postgresql-9.4.15.tar.bz2 17921677 BLAKE2B a41c81c7acc92265a6558c26370ff2afd258922a7158bbf40f8b1d6c7a3dbfb548502f42d646c96982dd5a87e5991f9d03046ae91e216704b97691666966d795 SHA512 be69f184cf18fb4c611d31a128f3593dc537551606f1db84a3ce9899b72f546876f05b29792435c3780c6c2b571759f4db2c172d62b2c012bd58574df80b4eb1
 DIST postgresql-9.4.16.tar.bz2 17778763 BLAKE2B 6051bbf042df6f7523ad5f27443c5c4fa8d3405813d40b281883df30f1f6a1709696cb1c0ff981bbe961eb6ba1ff1c49953736b730030111d106c700641954a5 SHA512 2e2bf14e2e63dec7254813e3c3a902a39cbd0aae89d8b3da5f75c6dead5d413a4f260fda6e87c9f84e4378df350c6531e67d972201f731a848b60bacef5b2bc8
 DIST postgresql-9.5.10.tar.bz2 18701419 BLAKE2B bdd9a191f4de2ba1cb501476a5eabb377b60899b524f50e5baa1f47b95ce491634b7e69a9c37017614f48789d2b97fdff98e0b12ea06611d1ca76988a8db62c8 SHA512 24e31adabb0b88be882ab0440c560f0e4d5d69203be0581ca0ce22316555d92219ea0a2fd5254f12b2508bd3e58bbe0f1a7c8837228c96d9d5f00caac45af95a
 DIST postgresql-9.5.11.tar.bz2 18572811 BLAKE2B 7b825d472e3bd6711eb3b4d5b1b5a03098d8d7ec7d0fc35cf7a5a12830bed9ca69922b75ab039fb6f0fcf1865a9fc37d3505d9eb129d03910ae1fa5e74f0a5db SHA512 c196709ddb953fe7ebdcee6e1d4624fc8136b83c5f0f6f010c29036a32f29f73763bdf64613dd57919d4be128e95a7f179c1c69a82f5951593c2fa0c2315fe83
-DIST postgresql-9.5.5.tar.bz2 18525082 BLAKE2B 1a8e81b1f5b530c670863cfb08e47541c372e62f7ec6083da80b895cf015a80fc8bd3ffc9c7968e288303c71083ceda8ca54bcd3e2cb66c4f20b13396dc16fac SHA512 727ab57796cd393ec3755e9aabf515ebbdc3152b4062c20e64511e866a7e7038ba5c5e2843f13f3a79e2263296451f0e93108346b6f638611fba2449394e338e
 DIST postgresql-9.6.6.tar.bz2 19605724 BLAKE2B efdb13a4e32133b31a0ee368aed9bf76f0511596a2d77ade60129c2c76b0ba2c7dafad532cf09ae007d7110175a153968cfa151cf8aa7008b59d36ed00ed18ed SHA512 ac2f0fe6ef7c4e14f85cd7592d1306d9657b7f35efa6f43a089d7785ab970b8c25aa1e66d83df056c23513d6dbac0a9f54717b3d85758560d02e7f8141914ebc
 DIST postgresql-9.6.7.tar.bz2 19504886 BLAKE2B 04ed26987f3a38826b7e04bf364d8f59fc93aa700fdf74b4fc6afdb2fcf12697945c8354e49507af9c4d48fcc05173182cb164778c97845bf84250fd9e5ad882 SHA512 6a66cdd5b74ea6dc95628b89bb7663555370be56b3e938f635950628ad5d77443ac8f40c747be1fc1cfc19ca8b0a27f41e52fe4db83a43c7a7bab9bb076c7844

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
deleted file mode 100644
index 59e43c5384e..00000000000
--- a/dev-db/postgresql/files/postgresql-9.2-9.4-tz-dir-overflow.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- 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.confd b/dev-db/postgresql/files/postgresql.confd
deleted file mode 100644
index 07b465d9b61..00000000000
--- a/dev-db/postgresql/files/postgresql.confd
+++ /dev/null
@@ -1,58 +0,0 @@
-# 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
deleted file mode 100644
index 35dd316e960..00000000000
--- a/dev-db/postgresql/files/postgresql.init
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/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.3 b/dev-db/postgresql/files/postgresql.init-9.3
deleted file mode 100644
index ffecea7a757..00000000000
--- a/dev-db/postgresql/files/postgresql.init-9.3
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/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.service b/dev-db/postgresql/files/postgresql.service
deleted file mode 100644
index a607169d22f..00000000000
--- a/dev-db/postgresql/files/postgresql.service
+++ /dev/null
@@ -1,55 +0,0 @@
-# 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.6 b/dev-db/postgresql/files/postgresql.service-9.6
deleted file mode 100644
index 89ec2d5cf7c..00000000000
--- a/dev-db/postgresql/files/postgresql.service-9.6
+++ /dev/null
@@ -1,56 +0,0 @@
-# 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/postgresql-9.2.19.ebuild b/dev-db/postgresql/postgresql-9.2.19.ebuild
deleted file mode 100644
index 54d1c48fa58..00000000000
--- a/dev-db/postgresql/postgresql-9.2.19.ebuild
+++ /dev/null
@@ -1,390 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	while [ "$correct" != "true" ] ; do
-		einfo "Are you ready to continue? (y/n)"
-		read answer
-		if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-			correct="true"
-		elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-			die "Aborting initialization."
-		else
-			echo "Answer not recognized"
-		fi
-	done
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.2.22.ebuild b/dev-db/postgresql/postgresql-9.2.22.ebuild
deleted file mode 100644
index f68ece459c1..00000000000
--- a/dev-db/postgresql/postgresql-9.2.22.ebuild
+++ /dev/null
@@ -1,441 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.2" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.2" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.2.23-r1.ebuild b/dev-db/postgresql/postgresql-9.2.23-r1.ebuild
deleted file mode 100644
index 9eae7d8feef..00000000000
--- a/dev-db/postgresql/postgresql-9.2.23-r1.ebuild
+++ /dev/null
@@ -1,445 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.2" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.2" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.2.23.ebuild b/dev-db/postgresql/postgresql-9.2.23.ebuild
deleted file mode 100644
index bc6bfbfbf3d..00000000000
--- a/dev-db/postgresql/postgresql-9.2.23.ebuild
+++ /dev/null
@@ -1,441 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.2" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.2" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.3.15.ebuild b/dev-db/postgresql/postgresql-9.3.15.ebuild
deleted file mode 100644
index 2a15daf099f..00000000000
--- a/dev-db/postgresql/postgresql-9.3.15.ebuild
+++ /dev/null
@@ -1,395 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	while [ "$correct" != "true" ] ; do
-		einfo "Are you ready to continue? (y/n)"
-		read answer
-		if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-			correct="true"
-		elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-			die "Aborting initialization."
-		else
-			echo "Answer not recognized"
-		fi
-	done
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.4.10.ebuild b/dev-db/postgresql/postgresql-9.4.10.ebuild
deleted file mode 100644
index 0c0626e267c..00000000000
--- a/dev-db/postgresql/postgresql-9.4.10.ebuild
+++ /dev/null
@@ -1,427 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python{2_7,3_4} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-	while [ "$correct" != "true" ] ; do
-		einfo "Are you ready to continue? (y/n)"
-		read answer
-		if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-			correct="true"
-		elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-			die "Aborting initialization."
-		else
-			echo "Answer not recognized"
-		fi
-	done
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.5.5.ebuild b/dev-db/postgresql/postgresql-9.5.5.ebuild
deleted file mode 100644
index 18ae5023750..00000000000
--- a/dev-db/postgresql/postgresql-9.5.5.ebuild
+++ /dev/null
@@ -1,438 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="5"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-1.2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || epatch "${FILESDIR}/${PN}-9.5.5-no-server.patch"
-
-	# Fix bug 486556 where the server would crash at start up because of
-	# an infinite loop caused by a self-referencing symlink.
-	epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	epatch_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	dodir /etc/eselect/postgresql/slots/${SLOT}
-	echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
-		"${ED}/etc/eselect/postgresql/slots/${SLOT}/base"
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 0775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	postgresql-config update
-
-	if use alpha && use server ; then
-		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
-		ewarn "As a result, performance will be extremely degraded."
-	fi
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if [[ -z ${REPLACING_VERSIONS} ]] ; then
-		elog
-		elog "It looks like this is your first time installing PostgreSQL. Run the"
-		elog "following command in all active shells to pick up changes to the default"
-		elog "environment:"
-		elog "    source /etc/profile"
-	fi
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	if [ -z "$PG_AUTOCONFIG" ] ; then
-		while [ "$correct" != "true" ] ; do
-			einfo "Are you ready to continue? (y/n)"
-			read answer
-			if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-				correct="true"
-			elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-				die "Aborting initialization."
-			else
-				echo "Answer not recognized"
-			fi
-		done
-	else
-		einfo "PG_AUTOCONFIG set, not prompting"
-	fi
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2018-05-20  9:42 Aaron Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron Swenson @ 2018-05-20  9:42 UTC (permalink / raw
  To: gentoo-commits

commit:     389ff0cbbc0887419892791e1e136466b0fde120
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Sun May 20 09:41:47 2018 +0000
Commit:     Aaron Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Sun May 20 09:41:47 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=389ff0cb

dev-db/postgresql: Cleanup insecure

Bug: https://bugs.gentoo.org/649288
Package-Manager: Portage-2.3.24, Repoman-2.3.6

 dev-db/postgresql/Manifest                         |   6 -
 .../files/postgresql-10beta2-no-server.patch       | 146 ------
 dev-db/postgresql/postgresql-10.1.ebuild           | 460 -------------------
 dev-db/postgresql/postgresql-9.3.20.ebuild         | 450 -------------------
 dev-db/postgresql/postgresql-9.4.15.ebuild         | 482 --------------------
 dev-db/postgresql/postgresql-9.5.10.ebuild         | 488 --------------------
 dev-db/postgresql/postgresql-9.6.6.ebuild          | 493 ---------------------
 dev-db/postgresql/postgresql-9.6.7.ebuild          | 493 ---------------------
 8 files changed, 3018 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 4d80c787678..734bfe706ad 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,16 +1,10 @@
-DIST postgresql-10.1.tar.bz2 19669989 BLAKE2B 2fbe782023b6d55c6fadaba38e517c60038b3b7b0a14fa8793043f7b9c4719a692440f286bb1f898045b5f56ef1c064f97f36e821990755077dc8d9bb0dbd639 SHA512 06050d353aa43f32e0de0199d833d8a4652aff893b718b1c40ed31837838f73fe4d977ac0f2164ab97b3eeff4aae3409f440601740898a893877d96bc0ed1882
 DIST postgresql-10.3.tar.bz2 19959653 BLAKE2B ba3b05f53b0f879b18d6d0649bf819697c77a066b49d941a96d13a4741854b01aeb0c8b868d6550a08ad52572c9463c968660aa83c16cbaa5b4bf7a89387a524 SHA512 05cf82d3483bdf38734e6ff0fef6b80e7f8fd3cb5ea6792ffe222a599d97d1a29638970bf28ebf5bd1f877e8dcd9986d88f5c5e5379e74fe79ce83e20d2babba
 DIST postgresql-10.4.tar.bz2 20201838 BLAKE2B 6d1cdc44547740c8f9fbc2e989364640409c6d2a365568b75731277dd0fba473ce07e2ee27e8ebfad507a6ce0ab3d3a44156c0e3a069d96d320771d8a97ba82f SHA512 b7c0d2fdc724e2eb1cda9fc1eb01b47352bbe6ba6357b3e898b7f5990fd78499c8c68dcb3aa9bde7821d71b5882d8856131384e899f8055d89d51cdfdbc9e663
-DIST postgresql-9.3.20.tar.bz2 17197360 BLAKE2B 2b07f6ee78294a490a8902d0129ac6b5e729e2d9a30631becc193cb7561294354a779ffc62bd61e807b1f540f01ce095e8ae4ad77adf2ea135389143809c9d48 SHA512 40098661bf00b64ad2d773b242613c44fe269b5ae984ad8990f85ce705b27138b127493c507103052fb6705d52f2e63a1df6692c7024d43c3c6b18154f2ef407
 DIST postgresql-9.3.22.tar.bz2 17022938 BLAKE2B 198705e438717d0d9e12c73e0c0e3eff0ba89ea50a1b183de70f065e13c153c164890fe56bc6ec13b0cb9617df4f66894c122eeddaf9303b9a02b8e08b19b085 SHA512 667ff496172626d2fe35c6795935fb07f4f7967a3b0631dd3b96278f8dc00b3d08794f091a5ab060a45d6f2a861e0f10f0e9660f9e343ab34eeabd693104c47f
 DIST postgresql-9.3.23.tar.bz2 17033683 BLAKE2B f02ad25f6b8755a9a57c3a6dcb63b78672e29473b061ad1616be2fb97fbfd83fe0dc9fc9fda66ac0231fb30fb13f9ef8975ba5a9701d83f33495bcf2c2651b4a SHA512 bb2d54312de728aa0379ea5bc6385036bbe69d3b7f85bbd78c210840eed19ace29840849caf38d0689e21130a0c94818a362b3927805d8eded53b68e240a52b0
-DIST postgresql-9.4.15.tar.bz2 17921677 BLAKE2B a41c81c7acc92265a6558c26370ff2afd258922a7158bbf40f8b1d6c7a3dbfb548502f42d646c96982dd5a87e5991f9d03046ae91e216704b97691666966d795 SHA512 be69f184cf18fb4c611d31a128f3593dc537551606f1db84a3ce9899b72f546876f05b29792435c3780c6c2b571759f4db2c172d62b2c012bd58574df80b4eb1
 DIST postgresql-9.4.17.tar.bz2 17807762 BLAKE2B 7640c29a71c6aeff47d9b43dd1e4f52edac4295b646b34da3a0ed9c26a8a826061bfd892e9907b62f31b7f01ee3aaf437c88d79b84d1d786d608dcd088309ecf SHA512 9ac03d460e521dcd142ac463dd5bb0f3e3f47333367bf8d61499ec7e8d0129d338c6f111667d0006df0c8ced9ae8a337d4c1b40eb5f55e6bc8dd5a24dfd376f0
 DIST postgresql-9.4.18.tar.bz2 17828085 BLAKE2B 346584e7d74264a7d58b3793cfd6247ae3cad3bb946bedec8df8d97278ffe6f8e881d31ad50e9f5d622aa4ae9b9711b36258bb60d520bb9a1d458af63c343e9e SHA512 2e64c3130c3dfc5183a77d72f61714bea34bfe549f55720eee25046e00b913a7effec3d7e43a021766ac957c1fa3c8c5e6c26ccbd8be1b434ae618e1fe9daab6
-DIST postgresql-9.5.10.tar.bz2 18701419 BLAKE2B bdd9a191f4de2ba1cb501476a5eabb377b60899b524f50e5baa1f47b95ce491634b7e69a9c37017614f48789d2b97fdff98e0b12ea06611d1ca76988a8db62c8 SHA512 24e31adabb0b88be882ab0440c560f0e4d5d69203be0581ca0ce22316555d92219ea0a2fd5254f12b2508bd3e58bbe0f1a7c8837228c96d9d5f00caac45af95a
 DIST postgresql-9.5.12.tar.bz2 18589538 BLAKE2B 4246eb2bf5fe2e3bb48bdc411ebd3c87015570f0be4d8b1ed2a0f2ed20a8374e3244fa0aa17f9145f4f951c88f5b0717a4dd2186bf1621ce3334789f5f8dd50f SHA512 ab81bc95fd587f76a1986db5616b63d861b84da0eb9e54478f5298248a81d7a608d1bb1a9e30662c8190d05630106ddb3bb6413c34b003de948417214d342654
 DIST postgresql-9.5.13.tar.bz2 18600185 BLAKE2B 7560f08648ec1417d304aa8c53c3220d7a4b2fdaf2cb4920a0196273466d1dbab4c12dbceb3dc9a136458c0089dd5f5dc595c95353584d49da0d2ab6e7903bba SHA512 807b22aabee38326934213de04b782a6b22cd8fe5c5bfd8b6cfa44281924527a715dcd78adbee276746446a7b05036b4714b00a16c650027543dcbafe1888082
-DIST postgresql-9.6.6.tar.bz2 19605724 BLAKE2B efdb13a4e32133b31a0ee368aed9bf76f0511596a2d77ade60129c2c76b0ba2c7dafad532cf09ae007d7110175a153968cfa151cf8aa7008b59d36ed00ed18ed SHA512 ac2f0fe6ef7c4e14f85cd7592d1306d9657b7f35efa6f43a089d7785ab970b8c25aa1e66d83df056c23513d6dbac0a9f54717b3d85758560d02e7f8141914ebc
-DIST postgresql-9.6.7.tar.bz2 19504886 BLAKE2B 04ed26987f3a38826b7e04bf364d8f59fc93aa700fdf74b4fc6afdb2fcf12697945c8354e49507af9c4d48fcc05173182cb164778c97845bf84250fd9e5ad882 SHA512 6a66cdd5b74ea6dc95628b89bb7663555370be56b3e938f635950628ad5d77443ac8f40c747be1fc1cfc19ca8b0a27f41e52fe4db83a43c7a7bab9bb076c7844
 DIST postgresql-9.6.8.tar.bz2 19528927 BLAKE2B 6aab5dbe4b13e1624befc33c2fa5241804dff71879e2d60c166db19c2fe015cd19cfc35054e6aede82bfe6b83a7146b6d2eedaabb94111c163da732526ff1723 SHA512 6b7595c0046308c725d77360b156e979d6bc469b78ac6500f631112f19b2607ca2d816781f8c5fd3bd835c48e079e79ada7af687fbd306a8fec5e160f20dd211
 DIST postgresql-9.6.9.tar.bz2 19566222 BLAKE2B e92a5ffaa8f4400364a174fc21ab11bb18c96dce9be721e6073ff7ad21b828859c2ac5fe8da81cad6a3d2a63a62d8fcb067d4bb02a9d23903525ad1f78955470 SHA512 3ce2a8f3a017d9c0bd0f1b475a9ee02bcb6a4119b0d436757911f444f49f5024bb1a1be07ce16a79e71af77799de1bf952b32279b4566bae075f23a50b8545c6

diff --git a/dev-db/postgresql/files/postgresql-10beta2-no-server.patch b/dev-db/postgresql/files/postgresql-10beta2-no-server.patch
deleted file mode 100644
index 8c88465e7bd..00000000000
--- a/dev-db/postgresql/files/postgresql-10beta2-no-server.patch
+++ /dev/null
@@ -1,146 +0,0 @@
-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/postgresql-10.1.ebuild b/dev-db/postgresql/postgresql-10.1.ebuild
deleted file mode 100644
index ade9ff4d6fd..00000000000
--- a/dev-db/postgresql/postgresql-10.1.ebuild
+++ /dev/null
@@ -1,460 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT=$(get_major_version)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl python +readline
-	  selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}beta2-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.3.20.ebuild b/dev-db/postgresql/postgresql-9.3.20.ebuild
deleted file mode 100644
index a725ec9680c..00000000000
--- a/dev-db/postgresql/postgresql-9.3.20.ebuild
+++ /dev/null
@@ -1,450 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.4.15.ebuild b/dev-db/postgresql/postgresql-9.4.15.ebuild
deleted file mode 100644
index 6ec49cac42e..00000000000
--- a/dev-db/postgresql/postgresql-9.4.15.ebuild
+++ /dev/null
@@ -1,482 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.5.10.ebuild b/dev-db/postgresql/postgresql-9.5.10.ebuild
deleted file mode 100644
index afa02d895a8..00000000000
--- a/dev-db/postgresql/postgresql-9.5.10.ebuild
+++ /dev/null
@@ -1,488 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-9.5.5-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	if use alpha && use server ; then
-		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
-		ewarn "As a result, performance will be extremely degraded."
-	fi
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.6.ebuild b/dev-db/postgresql/postgresql-9.6.6.ebuild
deleted file mode 100644
index 720b5ecf4dd..00000000000
--- a/dev-db/postgresql/postgresql-9.6.6.ebuild
+++ /dev/null
@@ -1,493 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-server? ( systemd? ( sys-apps/systemd ) )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.7.ebuild b/dev-db/postgresql/postgresql-9.6.7.ebuild
deleted file mode 100644
index 3e34fcbed56..00000000000
--- a/dev-db/postgresql/postgresql-9.6.7.ebuild
+++ /dev/null
@@ -1,493 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 ~arm ~arm64 ~hppa ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
-	  +readline selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-wanted_languages() {
-	local linguas="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru
-		sk sl sv tr zh_CN zh_TW"
-	local enable_langs lingua
-
-	for lingua in ${linguas} ; do
-		has ${lingua} ${LINGUAS-${lingua}} && enable_langs+="${lingua} "
-	done
-
-	echo -n ${enable_langs}
-}
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-server? ( systemd? ( sys-apps/systemd ) )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		"$(use_enable nls nls "$(wanted_languages)")"
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2019-06-15 10:58 Aaron W. Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron W. Swenson @ 2019-06-15 10:58 UTC (permalink / raw
  To: gentoo-commits

commit:     87cf3bd99d04619a664a6ef898edecba1125126a
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 15 10:56:02 2019 +0000
Commit:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Sat Jun 15 10:56:09 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=87cf3bd9

dev-db/postgresql: Cleanup old/insecure

Bug: https://bugs.gentoo.org/685846
Package-Manager: Portage-2.3.62, Repoman-2.3.11
Signed-off-by: Aaron W. Swenson <titanofold <AT> gentoo.org>

 dev-db/postgresql/Manifest                         |  11 -
 .../files/postgresql-9.3-no-server.patch           | 144 ------
 dev-db/postgresql/postgresql-10.6.ebuild           | 460 -------------------
 dev-db/postgresql/postgresql-10.7.ebuild           | 460 -------------------
 dev-db/postgresql/postgresql-11.1.ebuild           | 460 -------------------
 dev-db/postgresql/postgresql-11.2.ebuild           | 460 -------------------
 dev-db/postgresql/postgresql-12_beta1.ebuild       | 460 -------------------
 dev-db/postgresql/postgresql-9.3.25.ebuild         | 443 -------------------
 dev-db/postgresql/postgresql-9.4.20.ebuild         | 475 --------------------
 dev-db/postgresql/postgresql-9.4.21.ebuild         | 475 --------------------
 dev-db/postgresql/postgresql-9.5.15.ebuild         | 481 --------------------
 dev-db/postgresql/postgresql-9.5.16.ebuild         | 481 --------------------
 dev-db/postgresql/postgresql-9.6.11.ebuild         | 486 ---------------------
 dev-db/postgresql/postgresql-9.6.12.ebuild         | 486 ---------------------
 14 files changed, 5782 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 95279f068e8..ea182832865 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,17 +1,6 @@
-DIST postgresql-10.6.tar.bz2 20350612 BLAKE2B b751085b8fce73efb2531378a553c8c956f5e05a0002de8fdc58c0f2a6cf2b9dfaff6bd621047a094a51e459bc8fc5b1658d6a754a396fa3b7aedc1024ea3b4c SHA512 5d4d5cee2a19ad1820c3411bc4851904e3059cdcacc837350694d54d7d59260b66c565c72cc14a3a10541a8fc49c5185f08f57b7a8c7e4c64ed2614da6e1201f
-DIST postgresql-10.7.tar.bz2 18940030 BLAKE2B ce02d2c4ba97c1845b3708941bb7a9f6ee025fc4a881e35790279aadf5e35464d6716cfdeb4ad145ce4549e639ad01d333cff858f956607c0cd583af65f1cd3e SHA512 2fa8194e9ef540930eecc2a43907a77f7f185590046350d48fd625bdb1ab459095c4e2e0d2faac846935d7231ac672ace760633deeee365572768da619458ba9
 DIST postgresql-10.8.tar.bz2 18958913 BLAKE2B d2e1664a53c5b2f24b412f497769ffd33e2f48977fa0f4503cb588497b61955a97497c87950ae60d498d75c7385fc63dd832b518174614f695d8882628a4ebb8 SHA512 c9cd0298f553e13e32d4315e17e9e61c1fd011391c5203282d9040f26fd08c85f749e6f2cea3bcc42d1ca153a1272bcd773196ef3bf2bdfb74cd12c5f523b7ca
-DIST postgresql-11.1.tar.bz2 21263173 BLAKE2B d762b6e8b0e7b08b16ed252687118a0a4516172e38e8940879fd050f72d19ff045af949e72977a62c2ce0a788af7d42c9bde7748347566bec3694e337bba6f73 SHA512 35d00984e9f5f063a5b96e97aa1b40381ab76d07b2336bda5981fd80bef1324f56eefca5069ae78770ecd6ece5df85264e599fdb3478ecb71d4fdd0d7b6becca
-DIST postgresql-11.2.tar.bz2 19714229 BLAKE2B 459674c08a0435363da29428bef7ec49a012b534b390ce6addafac000ce58ad0ad7ba4e1522f5279da29535399836971c61536827d481af766322935d7c6d01b SHA512 dae00a543fdeed36bc338abd4ccfd9fe9a8b6b2b7eaa00b1078e4f27802de75a461c27da2800bc9dd64e658681e5787bd03764bde79940656cae1e8c8716f011
 DIST postgresql-11.3.tar.bz2 19718775 BLAKE2B f56686bff4e70c2b6333554a620a5c2d5c226654a1d61de43b4493c44a14e2bcd9c102dba420994878d328af52d933885e4948cd002f14b693aef1416697a0ea SHA512 03269bb88f44f3a81d5e3a8ca2fe59f63f784436840f08870b2e539755629cbde8ac288e0bb4472ee93294a88b37b814ddff48444254c1a3f7a10b4bb64f7133
 DIST postgresql-12beta1.tar.bz2 20589423 BLAKE2B 622f936524bca74c20e27967b4cfcec31ba4ffc3132af516fc6dbb89843d688df41b72b7febe7060d2eb6716d64228124b4bc9831e9b11601be0fd95b7727710 SHA512 f46017659aa88141b056fc1852280c92ffbc3ba52d1cda2e3e302d3ec6ba478cc2a8ab04c87f10774b0401e8284fc46bb387a3e0e594a26a30ef7a4cf79b1de3
-DIST postgresql-9.3.25.tar.bz2 17067593 BLAKE2B fd9ca5685e5511dcaa72da882b674846dcd5a16227e5b33ae06701fe7881df71847666c37925033c6cb01c916111a8f76df134491645f4d1e1dd48a008bd2831 SHA512 319e12b73853b74f5ef2c520d64795bb586ffd495ceab6518f7844de6e0a054aea821976c470108d346f8090c7d3949920d9c435432e33004b7caa7a77a5cdca
-DIST postgresql-9.4.20.tar.bz2 17905682 BLAKE2B cb65228f8e78dc8b6303a06480a68de58ecac1fefa1342e4563f2c4051c9f5506b366b36c2dbd54207d25ae497625f8fc5e3e771174a6b3ec33c3c19d2c9ea08 SHA512 664c6e97979f38d263d1dc75a7db442f193a230435cad43ddfa2afcd42ac0d73b2aef0e846fddcc9008cd6d89cba2d5c0a4db93b111665646d3ff4d8f6fbe1e8
-DIST postgresql-9.4.21.tar.bz2 16871522 BLAKE2B e6b8957f52a95d5fa56bc39756f1de83459882e40eee07c3ddf9e33eab39a0d61ee492864a920e7714ca1914a772dcc9048bc34072349197597cfb116aa94422 SHA512 850d1f59369457d9a8a42de8f0e4811f60e9164d2e7d7605fdabc04cc5ba2e3794d51e155d709419d06b8e070f214f7d3ef2328c6d37f125264ea008ca18ff5a
 DIST postgresql-9.4.22.tar.bz2 16848787 BLAKE2B 5c2aaef13ef0cf33c421e6839877a8e4e1fc5dbe41d9cabefddd369925869f92f6c6b8a124b5778f9b25359103f0a7ada1eddcaf4bac498709f563928f25e7e3 SHA512 f11623a89b2320616fd53eda52da544bdfcb63bff08cb78fccde134ef628eee7ee90b3de6952f4e08c10297d356624faabf0e5b181b0105f51797796cd04efef
-DIST postgresql-9.5.15.tar.bz2 18707696 BLAKE2B f1be26085953d5a15a6545aed3527b9eec6eb57c72f2e05401e43200e628b3a42ee824dd1cb0138556b97fe4922a991489dffa77329b653475874766c1d5b944 SHA512 2ea241b6751a2812c689da9bde40151ebb7cdabdd14e93d92f8bea1e3fcf5bc0d4854834999f33270329e22a09c5aeaf8d59d36ca6e8860704f81f3adcfb30d5
-DIST postgresql-9.5.16.tar.bz2 17506874 BLAKE2B ce5c804315ce5d7ac95af2455322801f581c3aa8e943ffae40b7e14a95a4610b71956568a418f2f22b8a9814ff9fd1f9296efc974716c0096aa22dcdb7609ff7 SHA512 4583c825ed00a5ba915863b41c39cd9580492444ff299e44c3856db55fb4f0607d184534fe8977d915fb0730e6d638d8560be11915ce21b9d1f6971e7a285c7c
 DIST postgresql-9.5.17.tar.bz2 17563469 BLAKE2B d40b7f95d03db594144b4882f36bbe22f348faab0b8d67eda3f946448bb0e09188eccdeb4d1c92742fb29a920b30ede55e536a863b22d2009283eab66679122d SHA512 bb468528b1f18166cda0be136f31a632859ffe6e6800233b1cb0e91ce11d2d00d3dc108a74580b5552a4d30b9f1b6849c91576cd497beac788c429815c66eac5
-DIST postgresql-9.6.11.tar.bz2 20009048 BLAKE2B aa3e5b1e63c983226ea71737982e62eaff655af7e0f55f20ec886f5d7406b1e30e2fe5378b0dd1ef59e777f862ccc2386121653853d4c186a1b4853a9bbb1591 SHA512 a4314f92d1a661af4076d8c120533ecae76d91461043b8a6ad22dd6e5b562e0bf019bc7f3157a26d9666ba5866e254613ae5b690310168b029795dc088f8c060
-DIST postgresql-9.6.12.tar.bz2 18759442 BLAKE2B 067b307318f65616651ee4502f420a84df26e906350f07ce5ab4a769608075f0d017b6d84b0ce5045662ab379e236b66cf751f7950d026f011d0915efcdfab3e SHA512 3a7a96caf682461f1f9bffdbe2b72b1ce00cc6680145e00c139e4af8b9dc8b8679fda1626de65921d6e187fa9290efc930584b98f1fd2aba1ba3d790a741a415
 DIST postgresql-9.6.13.tar.bz2 18767279 BLAKE2B c1ec780a7f938f878425cbd6556145e60a613135129daaacc52e9a699cc448a22481b01fac20d0c09373ea6a026f39bc58234aae4f1126333b94f621981a8135 SHA512 65cc70410ad4a1a738b92855b92eecdbb9efbbca0eb9a45a138d47b696c8f9c9cd19073fbfdf5c80eea7633d0be29b4ed8acbadd38724acf8f18c90bb30f9b26

diff --git a/dev-db/postgresql/files/postgresql-9.3-no-server.patch b/dev-db/postgresql/files/postgresql-9.3-no-server.patch
deleted file mode 100644
index 48e5377f2b1..00000000000
--- a/dev-db/postgresql/files/postgresql-9.3-no-server.patch
+++ /dev/null
@@ -1,144 +0,0 @@
---- a/contrib/Makefile
-+++ b/contrib/Makefile
-@@ -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
---- a/src/backend/Makefile
-+++ b/src/backend/Makefile
-@@ -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)'
---- a/src/bin/Makefile
-+++ b/src/bin/Makefile
-@@ -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
---- a/src/Makefile
-+++ b/src/Makefile
-@@ -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/postgresql-10.6.ebuild b/dev-db/postgresql/postgresql-10.6.ebuild
deleted file mode 100644
index b4ca072111b..00000000000
--- a/dev-db/postgresql/postgresql-10.6.ebuild
+++ /dev/null
@@ -1,460 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		 zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT=$(get_major_version)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl python +readline
-	  selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-10.7.ebuild b/dev-db/postgresql/postgresql-10.7.ebuild
deleted file mode 100644
index 12803d61530..00000000000
--- a/dev-db/postgresql/postgresql-10.7.ebuild
+++ /dev/null
@@ -1,460 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		 zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT=$(get_major_version)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl python +readline
-	  selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-11.1.ebuild b/dev-db/postgresql/postgresql-11.1.ebuild
deleted file mode 100644
index dea7d4a57d4..00000000000
--- a/dev-db/postgresql/postgresql-11.1.ebuild
+++ /dev/null
@@ -1,460 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		 zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(get_major_version)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl llvm nls pam perl python +readline
-	  selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-llvm? ( sys-devel/llvm:=
-	sys-devel/clang:= )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-11.2.ebuild b/dev-db/postgresql/postgresql-11.2.ebuild
deleted file mode 100644
index 7329f538987..00000000000
--- a/dev-db/postgresql/postgresql-11.2.ebuild
+++ /dev/null
@@ -1,460 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		 zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(get_major_version)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl llvm nls pam perl python +readline
-	  selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-llvm? ( sys-devel/llvm:=
-	sys-devel/clang:= )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-12_beta1.ebuild b/dev-db/postgresql/postgresql-12_beta1.ebuild
deleted file mode 100644
index bea7f351ec9..00000000000
--- a/dev-db/postgresql/postgresql-12_beta1.ebuild
+++ /dev/null
@@ -1,460 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		 zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(get_major_version)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="http://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl llvm nls pam perl python +readline
-	  selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-llvm? ( sys-devel/llvm:=
-	sys-devel/clang:= )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.3.25.ebuild b/dev-db/postgresql/postgresql-9.3.25.ebuild
deleted file mode 100644
index 99535f9c8c4..00000000000
--- a/dev-db/postgresql/postgresql-9.3.25.ebuild
+++ /dev/null
@@ -1,443 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with kerberos krb5) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		$(use_with uuid ossp-uuid) \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.4.20.ebuild b/dev-db/postgresql/postgresql-9.4.20.ebuild
deleted file mode 100644
index 9463417f714..00000000000
--- a/dev-db/postgresql/postgresql-9.4.20.ebuild
+++ /dev/null
@@ -1,475 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.4.21.ebuild b/dev-db/postgresql/postgresql-9.4.21.ebuild
deleted file mode 100644
index 3dfe4e3fdb2..00000000000
--- a/dev-db/postgresql/postgresql-9.4.21.ebuild
+++ /dev/null
@@ -1,475 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm hppa ~ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.5.15.ebuild b/dev-db/postgresql/postgresql-9.5.15.ebuild
deleted file mode 100644
index cdbace433fe..00000000000
--- a/dev-db/postgresql/postgresql-9.5.15.ebuild
+++ /dev/null
@@ -1,481 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-9.5.5-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	if use alpha && use server ; then
-		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
-		ewarn "As a result, performance will be extremely degraded."
-	fi
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.5.16.ebuild b/dev-db/postgresql/postgresql-9.5.16.ebuild
deleted file mode 100644
index b8c8eb9949c..00000000000
--- a/dev-db/postgresql/postgresql-9.5.16.ebuild
+++ /dev/null
@@ -1,481 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-9.5.5-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	if use alpha && use server ; then
-		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
-		ewarn "As a result, performance will be extremely degraded."
-	fi
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.11.ebuild b/dev-db/postgresql/postgresql-9.6.11.ebuild
deleted file mode 100644
index 8c7844abba3..00000000000
--- a/dev-db/postgresql/postgresql-9.6.11.ebuild
+++ /dev/null
@@ -1,486 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-server? ( systemd? ( sys-apps/systemd ) )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-9.6.12.ebuild b/dev-db/postgresql/postgresql-9.6.12.ebuild
deleted file mode 100644
index a557fdcbf71..00000000000
--- a/dev-db/postgresql/postgresql-9.6.12.ebuild
+++ /dev/null
@@ -1,486 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-PYTHON_COMPAT=( python2_7 python3_{5,6} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user versionator
-
-KEYWORDS="alpha amd64 arm ~arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT="$(get_version_component_range 1-2)"
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
-	  python +readline selinux +server systemd ssl static-libs tcl threads uuid
-	  xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( virtual/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-server? ( systemd? ( sys-apps/systemd ) )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX%/}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--docdir="${PO}/usr/share/doc/${PF}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable !pg_legacytimestamp integer-datetimes) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	use static-libs || find "${ED}" -name '*.a' -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT%/}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT%/}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT%/}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2020-08-14  0:53 Aaron W. Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron W. Swenson @ 2020-08-14  0:53 UTC (permalink / raw
  To: gentoo-commits

commit:     a707ca62afd34d785eea1f41e9a2769780d893d3
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 14 00:53:28 2020 +0000
Commit:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 00:53:36 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a707ca62

dev-db/postgresql: Remove 9.4

Package-Manager: Portage-2.3.103, Repoman-2.3.23
Signed-off-by: Aaron W. Swenson <titanofold <AT> gentoo.org>

 dev-db/postgresql/Manifest                         |   1 -
 .../files/postgresql-9.4.10-no-server.patch        | 147 -------
 dev-db/postgresql/postgresql-9.4.26.ebuild         | 479 ---------------------
 3 files changed, 627 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 54f2990f868..07fb66e50b3 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -5,7 +5,6 @@ DIST postgresql-11.8.tar.bz2 19922770 BLAKE2B a646b585bbafc95957fa60c7d119c02b69
 DIST postgresql-12.2.tar.bz2 20363545 BLAKE2B 7b0cfe841d46b117ff5dd793be5537e916f92255eb0d000681ed62c497eef34c5d1261126be408f2b7f95274485e2787869cd4063461ab248b650c168b62548d SHA512 0e0ce8e21856e8f43e58b840c10c4e3ffae6d5207e0d778e9176e36f8e20e34633cbb06f0030a7c963c3491bb7e941456d91b55444c561cfc6f283fba76f33ee
 DIST postgresql-12.3.tar.bz2 20439892 BLAKE2B f7a44725f235c55a2849acd444de3a9c932314e2ae8c68d7f8e827439263b052bdf0fd5b6cdaa8197c4ce9ad1d4fbb02b5ec1af030365363993a36d8d95a4231 SHA512 68e2d244ae2a9f2138d7569bcadc1cf6f62a410fa56ad1d4ac53206f2adefabb5ae136110b41ca9246df0f8b8cb039918997e0f8a81fc7e6efb7ad10b3a59ba1
 DIST postgresql-13beta2.tar.bz2 21365208 BLAKE2B db223d769e378af40a41d1bfa8aa2f05a31b325c80e375aad6ee6e30c35f8e3dadc7865ff1b19c685032c1714da34aa2630c4ac190ee5450734ff436575131b2 SHA512 7307b26422e78d3ebf4fead25a8ba7de181406490a5d354decb0324fc2d9216de94cfc19fc4eaba7eef51153f159606fc40d8650eb57131cdbc8e6948299e40f
-DIST postgresql-9.4.26.tar.bz2 16871195 BLAKE2B f26fd335293669a815a51ceb994b66e154c66f96f91e4c68d7df3490ad25f4b0366ebf7bfe2b209ff34965ea27a08562ace050f40d49cec94eb576d7a1becd1c SHA512 7d379d139c7b2bdac1df38743cbb46a1790a8d5174e8cf1141b7b4febcbc8f612e347bf4d355684eef24dfc73bb2796f85fc532908f26ba7195c685f198cbb72
 DIST postgresql-9.5.21.tar.bz2 17640928 BLAKE2B 8ffcf0befc331317a32d63d3cdfe44f7743f72f18b4bc46bee5ee80f8c489b4b1ef26abc8219f277acc922657fc21e3dc31f3fc9838621f44d95cc9405fca43b SHA512 8527356ee3b4f151c832aef50a8b96e923e0a6c77e5fe6ad597f50527f9d084a8feab7bede8fdbe29aab44383577d3f86e5286fb34e2d2b696cde34bd922e69d
 DIST postgresql-9.5.22.tar.bz2 17667386 BLAKE2B 6fe8ccf638af466e57f239c9d7f1a19bb6c33f6019955824f54f2fe63870675d841811318fb28707cc85ab8a9db550e6655773db0d89d801e26459c9d0d01a43 SHA512 489321fa49e17308d3a78353edf73a16295c1377ad429a94636df069d2bf55f538ba6570e3d2991dd28bcca45fee77c6c41fa9bade35ea7f9e581abff4c9a401
 DIST postgresql-9.6.17.tar.bz2 18812282 BLAKE2B 0bb48445201aae1d6b4f5a77652aefaaa629799a019c3b81a14e554a88167530002931c2b0d658731b26a38bd09487f79a6ef514b0955982d6037b383c021819 SHA512 a76f328523517f664e4fc59a4d27e476bc6300e49370712030caae40aa160acb1e6aecc7cd3b3440125713069932df812eb8d75377a3df63e59c9292419c2aa8

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
deleted file mode 100644
index 0eb750847cf..00000000000
--- a/dev-db/postgresql/files/postgresql-9.4.10-no-server.patch
+++ /dev/null
@@ -1,147 +0,0 @@
---- a/contrib/Makefile
-+++ b/contrib/Makefile
-@@ -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
---- a/src/backend/Makefile
-+++ b/src/backend/Makefile
-@@ -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)'
---- a/src/bin/Makefile
-+++ b/src/bin/Makefile
-@@ -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
---- a/src/Makefile
-+++ b/src/Makefile
-@@ -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/postgresql-9.4.26.ebuild b/dev-db/postgresql/postgresql-9.4.26.ebuild
deleted file mode 100644
index c662926d91f..00000000000
--- a/dev-db/postgresql/postgresql-9.4.26.ebuild
+++ /dev/null
@@ -1,479 +0,0 @@
-# Copyright 1999-2020 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{6,7} )
-
-PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
-		  zh_TW"
-
-inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
-		systemd user
-
-KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~ppc-macos ~x86-solaris"
-
-SLOT=$(ver_cut 1-2)
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${PV}/postgresql-${PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc kerberos kernel_linux ldap libressl nls pam perl
-	  -pg-legacytimestamp python +readline selinux +server systemd ssl
-	  static-libs tcl threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-sys-apps/less
-virtual/libintl
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-ssl? (
-	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-	libressl? ( dev-libs/libressl:= )
-)
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
-BSD_LIBC=( elibc_{Free,Net,Open}BSD )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-!!<sys-apps/sandbox-2.0
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-!dev-db/postgresql-docs:${SLOT}
-!dev-db/postgresql-base:${SLOT}
-!dev-db/postgresql-server:${SLOT}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	enewgroup postgres 70
-	enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-9.4.10-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		for i in ${BSD_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=bsd"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !pg-legacytimestamp integer-datetimes) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls nls "'$(l10n_get_locales)'")
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-
-		docinto sgml
-		dodoc doc/src/sgml/*.{sgml,dsl}
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.2" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql96). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst(). This
-	# is only necessary for 9.7 and earlier. 10 and later were never
-	# handled in this manner.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
-
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
-			rm "${l}" || ewarn "Couldn't remove ${l}"
-		fi
-	done
-
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
-}
-
-pkg_postinst() {
-	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	einfo "The PostgreSQL server, by default, will log events to:"
-	einfo "    ${DATA_DIR%/}/postmaster.log"
-	einfo
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2020-08-14  1:59 Aaron W. Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron W. Swenson @ 2020-08-14  1:59 UTC (permalink / raw
  To: gentoo-commits

commit:     749b4ceae0540c4f6d74793cf0246d4b843b389c
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 14 01:59:21 2020 +0000
Commit:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 01:59:39 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=749b4cea

dev-db/postgresql: Version Bumps

12.4, 11.9, 10.14, 9.6.19, 9.5.23, and 13 Beta 3

Package-Manager: Portage-2.3.103, Repoman-2.3.23
Signed-off-by: Aaron W. Swenson <titanofold <AT> gentoo.org>

 dev-db/postgresql/Manifest                         |   6 +
 .../files/postgresql-13_beta1-no-server.patch      | 149 +++++++
 dev-db/postgresql/postgresql-10.14.ebuild          | 456 +++++++++++++++++++
 dev-db/postgresql/postgresql-11.9.ebuild           | 458 ++++++++++++++++++++
 dev-db/postgresql/postgresql-12.4.ebuild           | 458 ++++++++++++++++++++
 dev-db/postgresql/postgresql-13_beta3.ebuild       | 458 ++++++++++++++++++++
 dev-db/postgresql/postgresql-9.5.23.ebuild         | 476 ++++++++++++++++++++
 dev-db/postgresql/postgresql-9.6.19.ebuild         | 481 +++++++++++++++++++++
 8 files changed, 2942 insertions(+)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 07fb66e50b3..deb4d1fa96f 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,11 +1,17 @@
 DIST postgresql-10.12.tar.bz2 19020488 BLAKE2B 2177e9b63e21a634e1d8ea060b5bd0a7360d81ece64f50dd614e6cdd6b0cf0dcbd3896ef2c11bd1431ce7a964ac8876d24f368d7f7eb309e3d432856d7546f2a SHA512 6accc66cbbae811509095c33e8a8d17ddd11d9e307267312e3d09df90469db4700a5806166d66f25d77769d3ef88653c98dfc7d05dd053f10434b03e0a9e33b7
 DIST postgresql-10.13.tar.bz2 19028339 BLAKE2B 8adb1be902863778ca6a0396f1bc3ffa3e69b9e27bd830523472f4895e225831ba98716c07dc3f8dcab68623d434fc3d2d7b71f753f4105c69ecb05365c94789 SHA512 7b268aa4476ed9b168814891e8b19d182683ab4994d4a9b30e75eec93ffd9c860f8a0979ba1b7408acf8e217437b5cc20037b6ebf6ef01e9cf5ee99f091c8c92
+DIST postgresql-10.14.tar.bz2 19042154 BLAKE2B addddf00179190780bd30ed97cf6881670d18fda77062cdb5dc7cc161c64c3d5522db288902d0612db30fc6fcc1b619c7a102887ed438e27739e936bf5659425 SHA512 eecd2aa8df7e4779606ec547b7bf0207ebb2be10a4b332f06c3b72116f0619fe27fb651f2fd4504c73b740ab7f92468919244a615d460bb9c35085174a0dbc78
 DIST postgresql-11.7.tar.bz2 19890063 BLAKE2B 461c372567ff0b4ff4da52889be5d2822b56889e4890b33c9a71f1105ad629b4f5bec95c4fbf5aebbdd4445e0ff451a7d8df04ae7b5bf7cf0075c3226a41b19b SHA512 32c7ace228f9895241ce0d925fbfc60c0cd39f4cd35368fb10dc7db046151ffd59a9895b4c30a529627f0103051e84b4992ed60312cccd292489f3037076ca1e
 DIST postgresql-11.8.tar.bz2 19922770 BLAKE2B a646b585bbafc95957fa60c7d119c02b69b727759d2189588508f8a690dc97a0ed1429a3379bc6fd48fb22ee92f3d811dedbf8aa43271361f9b7ac2c8d42a31b SHA512 fc3d0ebd224de60bda3fa71b6832958698238e9088cf46a80c376b8996cc3b2d017fde5dce1c1da1e5e6e23b78054aafad7ee1caa744bfb12c52317ccc8a1922
+DIST postgresql-11.9.tar.bz2 19959019 BLAKE2B 655d1c9e6eebde19402a4c220ee674c589641c5b6f4e6298c8c06d3330069178952455f5af58f90b9af196ba9c8fd03db0ccd70b8bc49335e465f0ed537eaf59 SHA512 2c5c2f51aa01f02af4aa0849441767383e30fef69dd52efa442892f39d2456bfa8bf01f633a265e00eca0745e792609d2c1d33f77d8f29a02f5f374c84f2bf6e
 DIST postgresql-12.2.tar.bz2 20363545 BLAKE2B 7b0cfe841d46b117ff5dd793be5537e916f92255eb0d000681ed62c497eef34c5d1261126be408f2b7f95274485e2787869cd4063461ab248b650c168b62548d SHA512 0e0ce8e21856e8f43e58b840c10c4e3ffae6d5207e0d778e9176e36f8e20e34633cbb06f0030a7c963c3491bb7e941456d91b55444c561cfc6f283fba76f33ee
 DIST postgresql-12.3.tar.bz2 20439892 BLAKE2B f7a44725f235c55a2849acd444de3a9c932314e2ae8c68d7f8e827439263b052bdf0fd5b6cdaa8197c4ce9ad1d4fbb02b5ec1af030365363993a36d8d95a4231 SHA512 68e2d244ae2a9f2138d7569bcadc1cf6f62a410fa56ad1d4ac53206f2adefabb5ae136110b41ca9246df0f8b8cb039918997e0f8a81fc7e6efb7ad10b3a59ba1
+DIST postgresql-12.4.tar.bz2 20669776 BLAKE2B fb3f865a8a5e5280e7cc5da43f8658029170cd15dae8cc5fb1e741a122ea1f13418ac7743ec417ab4436976bc0ce12753fc8a301200143c975e8739d59816fa7 SHA512 36daf10878ca153370829178786dd6ee366ab4d4d6dc9c527536740fdb14b688ae4c33f850eb4243a7667d23f87e4bfd1ddee0755447ad4f3996e423e391c2f3
 DIST postgresql-13beta2.tar.bz2 21365208 BLAKE2B db223d769e378af40a41d1bfa8aa2f05a31b325c80e375aad6ee6e30c35f8e3dadc7865ff1b19c685032c1714da34aa2630c4ac190ee5450734ff436575131b2 SHA512 7307b26422e78d3ebf4fead25a8ba7de181406490a5d354decb0324fc2d9216de94cfc19fc4eaba7eef51153f159606fc40d8650eb57131cdbc8e6948299e40f
+DIST postgresql-13beta3.tar.bz2 21411847 BLAKE2B 6195e246f683c0da8b7fc8bb185474cfec9d556897f8a9f9ebf6138a644760c2e74fd9981de236280879bd78f9aba25c765ed065c84b7789b8ff0776fe9532ae SHA512 62804ab44dbfaad8f3d498eacc687620077023d4ce27fe817185a85ebea3aa55f673f2d83eb5477efbe980e3c536f328369c906b4ba71fc0702393bffb6fe2c0
 DIST postgresql-9.5.21.tar.bz2 17640928 BLAKE2B 8ffcf0befc331317a32d63d3cdfe44f7743f72f18b4bc46bee5ee80f8c489b4b1ef26abc8219f277acc922657fc21e3dc31f3fc9838621f44d95cc9405fca43b SHA512 8527356ee3b4f151c832aef50a8b96e923e0a6c77e5fe6ad597f50527f9d084a8feab7bede8fdbe29aab44383577d3f86e5286fb34e2d2b696cde34bd922e69d
 DIST postgresql-9.5.22.tar.bz2 17667386 BLAKE2B 6fe8ccf638af466e57f239c9d7f1a19bb6c33f6019955824f54f2fe63870675d841811318fb28707cc85ab8a9db550e6655773db0d89d801e26459c9d0d01a43 SHA512 489321fa49e17308d3a78353edf73a16295c1377ad429a94636df069d2bf55f538ba6570e3d2991dd28bcca45fee77c6c41fa9bade35ea7f9e581abff4c9a401
+DIST postgresql-9.5.23.tar.bz2 17682366 BLAKE2B 74713d6483ae1ad3d2dfc4b1ac9d30a6785ff34f61b735924f2d469861516ad5160cbfda9c09b96adf264237b6f3ad8fd6ddeef60b6af6b5b63d6c1a36fb9354 SHA512 b7a1e936a0043b57b3ece79610855820d2ea6a86e4a4be0c4c8358bf3e1ef8fa88bc60106d6b865d86231d16b5e3c098b4dbd93125a125b3cc5d468ffea64db1
 DIST postgresql-9.6.17.tar.bz2 18812282 BLAKE2B 0bb48445201aae1d6b4f5a77652aefaaa629799a019c3b81a14e554a88167530002931c2b0d658731b26a38bd09487f79a6ef514b0955982d6037b383c021819 SHA512 a76f328523517f664e4fc59a4d27e476bc6300e49370712030caae40aa160acb1e6aecc7cd3b3440125713069932df812eb8d75377a3df63e59c9292419c2aa8
 DIST postgresql-9.6.18.tar.bz2 18836490 BLAKE2B 43f2d8a14e4fcad72af1f2e2814546368f7c2c0bb3c9957527e96df0ae6984d6b05008619855cf74fefeab0f35b13de4f0a437f79fa13c6e3a4ca2c8bc272aab SHA512 78aad7042d22be4486511a9f3b5df2578b65a911b9e969e6196c945d84b9d9a79b40c01a8bdd3859cc67cd9a5d023cca5d83c1360cb14a9bb076ff3b5c1fff70
+DIST postgresql-9.6.19.tar.bz2 18880036 BLAKE2B ad9c5684e2c0fb276589560f7dbe01241b5caf763f5a20991244ad7b473397576c9530658eb91e085e8416156b0ac81750f08ed85d5e5a689321891d10b6e114 SHA512 4d8d4a0e4645d71683a5fccb9cd88917e1870ba139f102e0ea82da9c8d1ad669f029e0feb6d409e2016dfd247229ec7daf04f7f2de3ab6c5b4053834ac244a26

diff --git a/dev-db/postgresql/files/postgresql-13_beta1-no-server.patch b/dev-db/postgresql/files/postgresql-13_beta1-no-server.patch
new file mode 100644
index 00000000000..ceb0e3a61d2
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-13_beta1-no-server.patch
@@ -0,0 +1,149 @@
+diff -Naruw postgresql-13beta1.orig/contrib/Makefile postgresql-13beta1/contrib/Makefile
+--- postgresql-13beta1.orig/contrib/Makefile	2020-05-18 16:09:19.000000000 -0400
++++ postgresql-13beta1/contrib/Makefile	2020-05-22 19:56:42.560113731 -0400
+@@ -5,56 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-		adminpack	\
+-		amcheck		\
+-		auth_delay	\
+-		auto_explain	\
+-		bloom		\
+-		btree_gin	\
+-		btree_gist	\
+-		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 postgresql-13beta1.orig/src/backend/Makefile postgresql-13beta1/src/backend/Makefile
+--- postgresql-13beta1.orig/src/backend/Makefile	2020-05-18 16:09:19.000000000 -0400
++++ postgresql-13beta1/src/backend/Makefile	2020-05-22 19:58:14.403299909 -0400
+@@ -56,7 +56,7 @@
+ 
+ ##########################################################################
+ 
+-all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
++all: generated-headers
+ 
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -195,23 +195,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
+-	$(MAKE) -C utils 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:
+ 
+ ifeq ($(with_llvm), yes)
+ install-bin: install-postgres-bitcode
+diff -Naruw postgresql-13beta1.orig/src/bin/Makefile postgresql-13beta1/src/bin/Makefile
+--- postgresql-13beta1.orig/src/bin/Makefile	2020-05-18 16:09:19.000000000 -0400
++++ postgresql-13beta1/src/bin/Makefile	2020-05-22 19:59:11.399875256 -0400
+@@ -14,22 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-	initdb \
+-	pg_archivecleanup \
+-	pg_basebackup \
+-	pg_checksums \
+ 	pg_config \
+-	pg_controldata \
+-	pg_ctl \
+ 	pg_dump \
+-	pg_resetwal \
+-	pg_rewind \
+-	pg_test_fsync \
+-	pg_test_timing \
+-	pg_upgrade \
+-	pg_verifybackup \
+-	pg_waldump \
+-	pgbench \
+ 	psql \
+ 	scripts
+ 
+diff -Naruw postgresql-13beta1.orig/src/Makefile postgresql-13beta1/src/Makefile
+--- postgresql-13beta1.orig/src/Makefile	2020-05-18 16:09:19.000000000 -0400
++++ postgresql-13beta1/src/Makefile	2020-05-22 19:59:59.656464613 -0400
+@@ -15,21 +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/isolation \
+-	test/perl
++	makefiles
+ 
+ ifeq ($(with_llvm), yes)
+ SUBDIRS += backend/jit/llvm

diff --git a/dev-db/postgresql/postgresql-10.14.ebuild b/dev-db/postgresql/postgresql-10.14.ebuild
new file mode 100644
index 00000000000..54610ae9a34
--- /dev/null
+++ b/dev-db/postgresql/postgresql-10.14.ebuild
@@ -0,0 +1,456 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7} )
+
+inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-macos ~x86-solaris"
+
+SLOT=$(ver_cut 1)
+
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
+
+LICENSE="POSTGRESQL GPL-2"
+DESCRIPTION="PostgreSQL RDBMS"
+HOMEPAGE="https://www.postgresql.org/"
+
+IUSE="debug doc icu kerberos kernel_linux ldap libressl nls pam perl
+	  python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+CDEPEND="
+>=app-eselect/eselect-postgresql-2.0
+acct-group/postgres
+acct-user/postgres
+sys-apps/less
+virtual/libintl
+icu? ( dev-libs/icu:= )
+kerberos? ( virtual/krb5 )
+ldap? ( net-nds/openldap )
+pam? ( sys-libs/pam )
+perl? ( >=dev-lang/perl-5.8:= )
+python? ( ${PYTHON_DEPS} )
+readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
+ssl? (
+	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
+	libressl? ( dev-libs/libressl:= )
+)
+tcl? ( >=dev-lang/tcl-8:0= )
+xml? ( dev-libs/libxml2 dev-libs/libxslt )
+zlib? ( sys-libs/zlib )
+"
+
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
+DEPEND="${CDEPEND}
+sys-devel/bison
+sys-devel/flex
+nls? ( sys-devel/gettext )
+xml? ( virtual/pkgconfig )
+"
+
+RDEPEND="${CDEPEND}
+selinux? ( sec-policy/selinux-postgresql )
+"
+
+pkg_setup() {
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	# Work around PPC{,64} compilation bug where bool is already defined
+	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
+
+	# Set proper run directory
+	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
+		-i src/include/pg_config_manual.h || die
+
+	# Rely on $PATH being in the proper order so that the correct
+	# install program is used for modules utilizing PGXS in both
+	# hardened and non-hardened environments. (Bug #528786)
+	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
+
+	use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
+
+	if use pam ; then
+		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+			-i src/backend/libpq/auth.c || \
+			die 'PGSQL_PAM_SERVICE rename failed.'
+	fi
+
+	eapply_user
+}
+
+src_configure() {
+	case ${CHOST} in
+		*-darwin*|*-solaris*)
+			use nls && append-libs intl
+			;;
+	esac
+
+	export LDFLAGS_SL="${LDFLAGS}"
+	export LDFLAGS_EX="${LDFLAGS}"
+
+	local PO="${EPREFIX}"
+
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
+	econf \
+		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
+		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
+		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
+		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
+		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
+		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
+		$(use_enable debug) \
+		$(use_enable threads thread-safety) \
+		$(use_with icu) \
+		$(use_with kerberos gssapi) \
+		$(use_with ldap) \
+		$(use_with pam) \
+		$(use_with perl) \
+		$(use_with python) \
+		$(use_with readline) \
+		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
+		$(use_with tcl) \
+		${uuid_config} \
+		$(use_with xml libxml) \
+		$(use_with xml libxslt) \
+		$(use_with zlib) \
+		$(use_enable nls)
+}
+
+src_compile() {
+	emake
+	emake -C contrib
+}
+
+src_install() {
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
+
+	dodoc README HISTORY doc/{TODO,bug.template}
+
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
+
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
+
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
+			bn=$(basename "${f}")
+			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
+		done
+
+		popd > /dev/null
+	done
+
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
+
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
+
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
+	done
+
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_postinst() {
+	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
+	postgresql-config update
+
+	elog "If you need a global psqlrc-file, you can place it in:"
+	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
+
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
+}
+
+pkg_prerm() {
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
+		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
+		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
+
+		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
+		sleep 10
+		eend 0
+	fi
+}
+
+pkg_postrm() {
+	postgresql-config update
+}
+
+pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
+	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
+		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
+	[[ -z "${DATA_DIR}" ]] \
+		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
+
+	# environment.bz2 may not contain the same locale as the current system
+	# locale. Unset and source from the current system locale.
+	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
+		unset LANG
+		unset LC_CTYPE
+		unset LC_NUMERIC
+		unset LC_TIME
+		unset LC_COLLATE
+		unset LC_MONETARY
+		unset LC_MESSAGES
+		unset LC_ALL
+		source "${EROOT}/etc/env.d/02locale"
+		[ -n "${LANG}" ] && export LANG
+		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
+		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
+		[ -n "${LC_TIME}" ] && export LC_TIME
+		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
+		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
+		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
+		[ -n "${LC_ALL}" ] && export LC_ALL
+	fi
+
+	einfo "You can modify the paths and options passed to initdb by editing:"
+	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	einfo
+	einfo "Information on options that can be passed to initdb are found at:"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
+	einfo
+	einfo "PG_INITDB_OPTS is currently set to:"
+	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
+		einfo "    (none)"
+	else
+		einfo "    ${PG_INITDB_OPTS}"
+	fi
+	einfo
+	einfo "Configuration files will be installed to:"
+	einfo "    ${PGDATA}"
+	einfo
+	einfo "The database cluster will be created in:"
+	einfo "    ${DATA_DIR}"
+	einfo
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
+
+	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
+		eerror "The given directory, '${DATA_DIR}', is not empty."
+		eerror "Modify DATA_DIR to point to an empty directory."
+		die "${DATA_DIR} is not empty."
+	fi
+
+	einfo "Creating the data directory ..."
+	if [[ ${EUID} == 0 ]] ; then
+		mkdir -p "${DATA_DIR}"
+		chown -Rf postgres:postgres "${DATA_DIR}"
+		chmod 0700 "${DATA_DIR}"
+	fi
+
+	einfo "Initializing the database ..."
+
+	if [[ ${EUID} == 0 ]] ; then
+		su postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
+	else
+		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
+	fi
+
+	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
+		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
+		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
+	fi
+
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
+	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
+		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
+		# On the off-chance that you might need to work with UTF-8 encoded
+		# characters in PL/Perl
+		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
+	EOF
+
+	einfo "The autovacuum function, which was in contrib, has been moved to the main"
+	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
+	einfo "by default. You can disable it in the cluster's:"
+	einfo "    ${PGDATA%/}/postgresql.conf"
+	einfo
+	if ! use systemd; then
+		einfo "The PostgreSQL server, by default, will log events to:"
+		einfo "    ${DATA_DIR%/}/postmaster.log"
+		einfo
+	fi
+	if use prefix ; then
+		einfo "The location of the configuration files have moved to:"
+		einfo "    ${PGDATA}"
+		einfo "To start the server:"
+		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
+		einfo "To stop:"
+		einfo "    pg_ctl stop -D ${DATA_DIR}"
+		einfo
+		einfo "Or move the configuration files back:"
+		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	elif use systemd; then
+		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	else
+		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	fi
+}
+
+src_test() {
+	if use server && [[ ${UID} -ne 0 ]] ; then
+		emake check
+
+		einfo "If you think other tests besides the regression tests are necessary, please"
+		einfo "submit a bug including a patch for this ebuild to enable them."
+	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
+		ewarn 'Skipping.'
+	fi
+}

diff --git a/dev-db/postgresql/postgresql-11.9.ebuild b/dev-db/postgresql/postgresql-11.9.ebuild
new file mode 100644
index 00000000000..e17cfba0e92
--- /dev/null
+++ b/dev-db/postgresql/postgresql-11.9.ebuild
@@ -0,0 +1,458 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7} )
+
+inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+
+SLOT=$(ver_cut 1)
+
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
+
+LICENSE="POSTGRESQL GPL-2"
+DESCRIPTION="PostgreSQL RDBMS"
+HOMEPAGE="https://www.postgresql.org/"
+
+IUSE="debug doc icu kerberos kernel_linux ldap libressl llvm nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+CDEPEND="
+>=app-eselect/eselect-postgresql-2.0
+acct-group/postgres
+acct-user/postgres
+sys-apps/less
+virtual/libintl
+icu? ( dev-libs/icu:= )
+kerberos? ( virtual/krb5 )
+ldap? ( net-nds/openldap )
+llvm? (
+	sys-devel/llvm:=
+	sys-devel/clang:=
+)
+pam? ( sys-libs/pam )
+perl? ( >=dev-lang/perl-5.8:= )
+python? ( ${PYTHON_DEPS} )
+readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
+ssl? (
+	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
+	libressl? ( dev-libs/libressl:= )
+)
+tcl? ( >=dev-lang/tcl-8:0= )
+xml? ( dev-libs/libxml2 dev-libs/libxslt )
+zlib? ( sys-libs/zlib )
+"
+
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
+DEPEND="${CDEPEND}
+sys-devel/bison
+sys-devel/flex
+nls? ( sys-devel/gettext )
+xml? ( virtual/pkgconfig )
+"
+
+RDEPEND="${CDEPEND}
+selinux? ( sec-policy/selinux-postgresql )
+"
+
+pkg_setup() {
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	# Set proper run directory
+	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
+		-i src/include/pg_config_manual.h || die
+
+	# Rely on $PATH being in the proper order so that the correct
+	# install program is used for modules utilizing PGXS in both
+	# hardened and non-hardened environments. (Bug #528786)
+	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
+
+	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
+
+	if use pam ; then
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+			-i src/backend/libpq/auth.c || \
+			die 'PGSQL_PAM_SERVICE rename failed.'
+	fi
+
+	eapply_user
+}
+
+src_configure() {
+	case ${CHOST} in
+		*-darwin*|*-solaris*)
+			use nls && append-libs intl
+			;;
+	esac
+
+	export LDFLAGS_SL="${LDFLAGS}"
+	export LDFLAGS_EX="${LDFLAGS}"
+
+	local PO="${EPREFIX}"
+
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
+	econf \
+		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
+		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
+		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
+		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
+		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
+		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
+		$(use_enable debug) \
+		$(use_enable threads thread-safety) \
+		$(use_with icu) \
+		$(use_with kerberos gssapi) \
+		$(use_with ldap) \
+		$(use_with llvm) \
+		$(use_with pam) \
+		$(use_with perl) \
+		$(use_with python) \
+		$(use_with readline) \
+		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
+		$(use_with tcl) \
+		${uuid_config} \
+		$(use_with xml libxml) \
+		$(use_with xml libxslt) \
+		$(use_with zlib) \
+		$(use_enable nls)
+}
+
+src_compile() {
+	emake
+	emake -C contrib
+}
+
+src_install() {
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
+
+	dodoc README HISTORY doc/{TODO,bug.template}
+
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
+
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
+
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
+			bn=$(basename "${f}")
+			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
+		done
+
+		popd > /dev/null
+	done
+
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
+
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
+
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
+	done
+
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_postinst() {
+	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
+	postgresql-config update
+
+	elog "If you need a global psqlrc-file, you can place it in:"
+	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
+
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
+}
+
+pkg_prerm() {
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
+		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
+		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
+
+		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
+		sleep 10
+		eend 0
+	fi
+}
+
+pkg_postrm() {
+	postgresql-config update
+}
+
+pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
+	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
+		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
+	[[ -z "${DATA_DIR}" ]] \
+		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
+
+	# environment.bz2 may not contain the same locale as the current system
+	# locale. Unset and source from the current system locale.
+	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
+		unset LANG
+		unset LC_CTYPE
+		unset LC_NUMERIC
+		unset LC_TIME
+		unset LC_COLLATE
+		unset LC_MONETARY
+		unset LC_MESSAGES
+		unset LC_ALL
+		source "${EROOT}/etc/env.d/02locale"
+		[ -n "${LANG}" ] && export LANG
+		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
+		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
+		[ -n "${LC_TIME}" ] && export LC_TIME
+		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
+		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
+		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
+		[ -n "${LC_ALL}" ] && export LC_ALL
+	fi
+
+	einfo "You can modify the paths and options passed to initdb by editing:"
+	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	einfo
+	einfo "Information on options that can be passed to initdb are found at:"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
+	einfo
+	einfo "PG_INITDB_OPTS is currently set to:"
+	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
+		einfo "    (none)"
+	else
+		einfo "    ${PG_INITDB_OPTS}"
+	fi
+	einfo
+	einfo "Configuration files will be installed to:"
+	einfo "    ${PGDATA}"
+	einfo
+	einfo "The database cluster will be created in:"
+	einfo "    ${DATA_DIR}"
+	einfo
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
+
+	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
+		eerror "The given directory, '${DATA_DIR}', is not empty."
+		eerror "Modify DATA_DIR to point to an empty directory."
+		die "${DATA_DIR} is not empty."
+	fi
+
+	einfo "Creating the data directory ..."
+	if [[ ${EUID} == 0 ]] ; then
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
+	fi
+
+	einfo "Initializing the database ..."
+
+	if [[ ${EUID} == 0 ]] ; then
+		su postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
+	else
+		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
+	fi
+
+	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
+		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
+		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
+	fi
+
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
+	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
+		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
+		# On the off-chance that you might need to work with UTF-8 encoded
+		# characters in PL/Perl
+		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
+	EOF
+
+	einfo "The autovacuum function, which was in contrib, has been moved to the main"
+	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
+	einfo "by default. You can disable it in the cluster's:"
+	einfo "    ${PGDATA%/}/postgresql.conf"
+	einfo
+	if ! use systemd; then
+		einfo "The PostgreSQL server, by default, will log events to:"
+		einfo "    ${DATA_DIR%/}/postmaster.log"
+		einfo
+	fi
+	if use prefix ; then
+		einfo "The location of the configuration files have moved to:"
+		einfo "    ${PGDATA}"
+		einfo "To start the server:"
+		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
+		einfo "To stop:"
+		einfo "    pg_ctl stop -D ${DATA_DIR}"
+		einfo
+		einfo "Or move the configuration files back:"
+		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	elif use systemd; then
+		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	else
+		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	fi
+}
+
+src_test() {
+	if use server && [[ ${UID} -ne 0 ]] ; then
+		emake check
+
+		einfo "If you think other tests besides the regression tests are necessary, please"
+		einfo "submit a bug including a patch for this ebuild to enable them."
+	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
+		ewarn 'Skipping.'
+	fi
+}

diff --git a/dev-db/postgresql/postgresql-12.4.ebuild b/dev-db/postgresql/postgresql-12.4.ebuild
new file mode 100644
index 00000000000..cfae19554b2
--- /dev/null
+++ b/dev-db/postgresql/postgresql-12.4.ebuild
@@ -0,0 +1,458 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7} )
+
+inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+
+SLOT=$(ver_cut 1)
+
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
+
+LICENSE="POSTGRESQL GPL-2"
+DESCRIPTION="PostgreSQL RDBMS"
+HOMEPAGE="https://www.postgresql.org/"
+
+IUSE="debug doc icu kerberos kernel_linux ldap libressl llvm nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+CDEPEND="
+>=app-eselect/eselect-postgresql-2.0
+acct-group/postgres
+acct-user/postgres
+sys-apps/less
+virtual/libintl
+icu? ( dev-libs/icu:= )
+kerberos? ( virtual/krb5 )
+ldap? ( net-nds/openldap )
+llvm? (
+	sys-devel/llvm:=
+	sys-devel/clang:=
+)
+pam? ( sys-libs/pam )
+perl? ( >=dev-lang/perl-5.8:= )
+python? ( ${PYTHON_DEPS} )
+readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
+ssl? (
+	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
+	libressl? ( dev-libs/libressl:= )
+)
+tcl? ( >=dev-lang/tcl-8:0= )
+xml? ( dev-libs/libxml2 dev-libs/libxslt )
+zlib? ( sys-libs/zlib )
+"
+
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
+DEPEND="${CDEPEND}
+sys-devel/bison
+sys-devel/flex
+nls? ( sys-devel/gettext )
+xml? ( virtual/pkgconfig )
+"
+
+RDEPEND="${CDEPEND}
+selinux? ( sec-policy/selinux-postgresql )
+"
+
+pkg_setup() {
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	# Set proper run directory
+	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
+		-i src/include/pg_config_manual.h || die
+
+	# Rely on $PATH being in the proper order so that the correct
+	# install program is used for modules utilizing PGXS in both
+	# hardened and non-hardened environments. (Bug #528786)
+	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
+
+	use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch"
+
+	if use pam ; then
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+			-i src/backend/libpq/auth.c || \
+			die 'PGSQL_PAM_SERVICE rename failed.'
+	fi
+
+	eapply_user
+}
+
+src_configure() {
+	case ${CHOST} in
+		*-darwin*|*-solaris*)
+			use nls && append-libs intl
+			;;
+	esac
+
+	export LDFLAGS_SL="${LDFLAGS}"
+	export LDFLAGS_EX="${LDFLAGS}"
+
+	local PO="${EPREFIX}"
+
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
+	econf \
+		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
+		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
+		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
+		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
+		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
+		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
+		$(use_enable debug) \
+		$(use_enable threads thread-safety) \
+		$(use_with icu) \
+		$(use_with kerberos gssapi) \
+		$(use_with ldap) \
+		$(use_with llvm) \
+		$(use_with pam) \
+		$(use_with perl) \
+		$(use_with python) \
+		$(use_with readline) \
+		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
+		$(use_with tcl) \
+		${uuid_config} \
+		$(use_with xml libxml) \
+		$(use_with xml libxslt) \
+		$(use_with zlib) \
+		$(use_enable nls)
+}
+
+src_compile() {
+	emake
+	emake -C contrib
+}
+
+src_install() {
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
+
+	dodoc README HISTORY
+
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
+
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
+
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
+			bn=$(basename "${f}")
+			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
+		done
+
+		popd > /dev/null
+	done
+
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
+
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
+
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
+	done
+
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_postinst() {
+	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
+	postgresql-config update
+
+	elog "If you need a global psqlrc-file, you can place it in:"
+	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
+
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
+}
+
+pkg_prerm() {
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
+		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
+		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
+
+		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
+		sleep 10
+		eend 0
+	fi
+}
+
+pkg_postrm() {
+	postgresql-config update
+}
+
+pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
+	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
+		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
+	[[ -z "${DATA_DIR}" ]] \
+		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
+
+	# environment.bz2 may not contain the same locale as the current system
+	# locale. Unset and source from the current system locale.
+	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
+		unset LANG
+		unset LC_CTYPE
+		unset LC_NUMERIC
+		unset LC_TIME
+		unset LC_COLLATE
+		unset LC_MONETARY
+		unset LC_MESSAGES
+		unset LC_ALL
+		source "${EROOT}/etc/env.d/02locale"
+		[ -n "${LANG}" ] && export LANG
+		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
+		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
+		[ -n "${LC_TIME}" ] && export LC_TIME
+		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
+		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
+		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
+		[ -n "${LC_ALL}" ] && export LC_ALL
+	fi
+
+	einfo "You can modify the paths and options passed to initdb by editing:"
+	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	einfo
+	einfo "Information on options that can be passed to initdb are found at:"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
+	einfo
+	einfo "PG_INITDB_OPTS is currently set to:"
+	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
+		einfo "    (none)"
+	else
+		einfo "    ${PG_INITDB_OPTS}"
+	fi
+	einfo
+	einfo "Configuration files will be installed to:"
+	einfo "    ${PGDATA}"
+	einfo
+	einfo "The database cluster will be created in:"
+	einfo "    ${DATA_DIR}"
+	einfo
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
+
+	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
+		eerror "The given directory, '${DATA_DIR}', is not empty."
+		eerror "Modify DATA_DIR to point to an empty directory."
+		die "${DATA_DIR} is not empty."
+	fi
+
+	einfo "Creating the data directory ..."
+	if [[ ${EUID} == 0 ]] ; then
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
+	fi
+
+	einfo "Initializing the database ..."
+
+	if [[ ${EUID} == 0 ]] ; then
+		su postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
+	else
+		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
+	fi
+
+	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
+		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
+		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
+	fi
+
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
+	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
+		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
+		# On the off-chance that you might need to work with UTF-8 encoded
+		# characters in PL/Perl
+		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
+	EOF
+
+	einfo "The autovacuum function, which was in contrib, has been moved to the main"
+	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
+	einfo "by default. You can disable it in the cluster's:"
+	einfo "    ${PGDATA%/}/postgresql.conf"
+	einfo
+	if ! use systemd; then
+		einfo "The PostgreSQL server, by default, will log events to:"
+		einfo "    ${DATA_DIR%/}/postmaster.log"
+		einfo
+	fi
+	if use prefix ; then
+		einfo "The location of the configuration files have moved to:"
+		einfo "    ${PGDATA}"
+		einfo "To start the server:"
+		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
+		einfo "To stop:"
+		einfo "    pg_ctl stop -D ${DATA_DIR}"
+		einfo
+		einfo "Or move the configuration files back:"
+		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	elif use systemd; then
+		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	else
+		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	fi
+}
+
+src_test() {
+	if use server && [[ ${UID} -ne 0 ]] ; then
+		emake check
+
+		einfo "If you think other tests besides the regression tests are necessary, please"
+		einfo "submit a bug including a patch for this ebuild to enable them."
+	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
+		ewarn 'Skipping.'
+	fi
+}

diff --git a/dev-db/postgresql/postgresql-13_beta3.ebuild b/dev-db/postgresql/postgresql-13_beta3.ebuild
new file mode 100644
index 00000000000..210d6e3dfda
--- /dev/null
+++ b/dev-db/postgresql/postgresql-13_beta3.ebuild
@@ -0,0 +1,458 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7} )
+
+inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd
+
+KEYWORDS=""
+
+SLOT=$(ver_cut 1)
+
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
+
+LICENSE="POSTGRESQL GPL-2"
+DESCRIPTION="PostgreSQL RDBMS"
+HOMEPAGE="https://www.postgresql.org/"
+
+IUSE="debug doc icu kerberos kernel_linux ldap libressl llvm nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+CDEPEND="
+>=app-eselect/eselect-postgresql-2.0
+acct-group/postgres
+acct-user/postgres
+sys-apps/less
+virtual/libintl
+icu? ( dev-libs/icu:= )
+kerberos? ( virtual/krb5 )
+ldap? ( net-nds/openldap )
+llvm? (
+	sys-devel/llvm:=
+	sys-devel/clang:=
+)
+pam? ( sys-libs/pam )
+perl? ( >=dev-lang/perl-5.8:= )
+python? ( ${PYTHON_DEPS} )
+readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
+ssl? (
+	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
+	libressl? ( dev-libs/libressl:= )
+)
+tcl? ( >=dev-lang/tcl-8:0= )
+xml? ( dev-libs/libxml2 dev-libs/libxslt )
+zlib? ( sys-libs/zlib )
+"
+
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
+DEPEND="${CDEPEND}
+sys-devel/bison
+sys-devel/flex
+nls? ( sys-devel/gettext )
+xml? ( virtual/pkgconfig )
+"
+
+RDEPEND="${CDEPEND}
+selinux? ( sec-policy/selinux-postgresql )
+"
+
+pkg_setup() {
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	# Set proper run directory
+	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
+		-i src/include/pg_config_manual.h || die
+
+	# Rely on $PATH being in the proper order so that the correct
+	# install program is used for modules utilizing PGXS in both
+	# hardened and non-hardened environments. (Bug #528786)
+	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
+
+	use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch"
+
+	if use pam ; then
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+			-i src/backend/libpq/auth.c || \
+			die 'PGSQL_PAM_SERVICE rename failed.'
+	fi
+
+	eapply_user
+}
+
+src_configure() {
+	case ${CHOST} in
+		*-darwin*|*-solaris*)
+			use nls && append-libs intl
+			;;
+	esac
+
+	export LDFLAGS_SL="${LDFLAGS}"
+	export LDFLAGS_EX="${LDFLAGS}"
+
+	local PO="${EPREFIX}"
+
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
+	econf \
+		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
+		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
+		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
+		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
+		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
+		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
+		$(use_enable debug) \
+		$(use_enable threads thread-safety) \
+		$(use_with icu) \
+		$(use_with kerberos gssapi) \
+		$(use_with ldap) \
+		$(use_with llvm) \
+		$(use_with pam) \
+		$(use_with perl) \
+		$(use_with python) \
+		$(use_with readline) \
+		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
+		$(use_with tcl) \
+		${uuid_config} \
+		$(use_with xml libxml) \
+		$(use_with xml libxslt) \
+		$(use_with zlib) \
+		$(use_enable nls)
+}
+
+src_compile() {
+	emake
+	emake -C contrib
+}
+
+src_install() {
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
+
+	dodoc README HISTORY
+
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
+
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
+
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
+			bn=$(basename "${f}")
+			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
+		done
+
+		popd > /dev/null
+	done
+
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
+
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
+
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
+	done
+
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_postinst() {
+	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
+	postgresql-config update
+
+	elog "If you need a global psqlrc-file, you can place it in:"
+	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
+
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
+}
+
+pkg_prerm() {
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
+		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
+		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
+
+		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
+		sleep 10
+		eend 0
+	fi
+}
+
+pkg_postrm() {
+	postgresql-config update
+}
+
+pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
+	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
+		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
+	[[ -z "${DATA_DIR}" ]] \
+		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
+
+	# environment.bz2 may not contain the same locale as the current system
+	# locale. Unset and source from the current system locale.
+	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
+		unset LANG
+		unset LC_CTYPE
+		unset LC_NUMERIC
+		unset LC_TIME
+		unset LC_COLLATE
+		unset LC_MONETARY
+		unset LC_MESSAGES
+		unset LC_ALL
+		source "${EROOT}/etc/env.d/02locale"
+		[ -n "${LANG}" ] && export LANG
+		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
+		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
+		[ -n "${LC_TIME}" ] && export LC_TIME
+		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
+		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
+		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
+		[ -n "${LC_ALL}" ] && export LC_ALL
+	fi
+
+	einfo "You can modify the paths and options passed to initdb by editing:"
+	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	einfo
+	einfo "Information on options that can be passed to initdb are found at:"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
+	einfo
+	einfo "PG_INITDB_OPTS is currently set to:"
+	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
+		einfo "    (none)"
+	else
+		einfo "    ${PG_INITDB_OPTS}"
+	fi
+	einfo
+	einfo "Configuration files will be installed to:"
+	einfo "    ${PGDATA}"
+	einfo
+	einfo "The database cluster will be created in:"
+	einfo "    ${DATA_DIR}"
+	einfo
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
+
+	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
+		eerror "The given directory, '${DATA_DIR}', is not empty."
+		eerror "Modify DATA_DIR to point to an empty directory."
+		die "${DATA_DIR} is not empty."
+	fi
+
+	einfo "Creating the data directory ..."
+	if [[ ${EUID} == 0 ]] ; then
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
+	fi
+
+	einfo "Initializing the database ..."
+
+	if [[ ${EUID} == 0 ]] ; then
+		su postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
+	else
+		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
+	fi
+
+	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
+		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
+		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
+	fi
+
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
+	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
+		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
+		# On the off-chance that you might need to work with UTF-8 encoded
+		# characters in PL/Perl
+		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
+	EOF
+
+	einfo "The autovacuum function, which was in contrib, has been moved to the main"
+	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
+	einfo "by default. You can disable it in the cluster's:"
+	einfo "    ${PGDATA%/}/postgresql.conf"
+	einfo
+	if ! use systemd; then
+		einfo "The PostgreSQL server, by default, will log events to:"
+		einfo "    ${DATA_DIR%/}/postmaster.log"
+		einfo
+	fi
+	if use prefix ; then
+		einfo "The location of the configuration files have moved to:"
+		einfo "    ${PGDATA}"
+		einfo "To start the server:"
+		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
+		einfo "To stop:"
+		einfo "    pg_ctl stop -D ${DATA_DIR}"
+		einfo
+		einfo "Or move the configuration files back:"
+		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	elif use systemd; then
+		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	else
+		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	fi
+}
+
+src_test() {
+	if use server && [[ ${UID} -ne 0 ]] ; then
+		emake check
+
+		einfo "If you think other tests besides the regression tests are necessary, please"
+		einfo "submit a bug including a patch for this ebuild to enable them."
+	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
+		ewarn 'Skipping.'
+	fi
+}

diff --git a/dev-db/postgresql/postgresql-9.5.23.ebuild b/dev-db/postgresql/postgresql-9.5.23.ebuild
new file mode 100644
index 00000000000..7d999e9628a
--- /dev/null
+++ b/dev-db/postgresql/postgresql-9.5.23.ebuild
@@ -0,0 +1,476 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7} )
+
+inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-macos ~x86-solaris"
+
+SLOT=$(ver_cut 1-2)
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${PV}/postgresql-${PV}.tar.bz2"
+
+LICENSE="POSTGRESQL GPL-2"
+DESCRIPTION="PostgreSQL RDBMS"
+HOMEPAGE="https://www.postgresql.org/"
+
+IUSE="debug doc kerberos kernel_linux ldap libressl nls pam perl
+	  -pg-legacytimestamp python +readline selinux +server systemd ssl
+	  static-libs tcl threads uuid xml zlib"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+CDEPEND="
+>=app-eselect/eselect-postgresql-2.0
+acct-group/postgres
+acct-user/postgres
+sys-apps/less
+virtual/libintl
+kerberos? ( virtual/krb5 )
+ldap? ( net-nds/openldap )
+pam? ( sys-libs/pam )
+perl? ( >=dev-lang/perl-5.8:= )
+python? ( ${PYTHON_DEPS} )
+readline? ( sys-libs/readline:0= )
+ssl? (
+	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
+	libressl? ( dev-libs/libressl:= )
+)
+tcl? ( >=dev-lang/tcl-8:0= )
+xml? ( dev-libs/libxml2 dev-libs/libxslt )
+zlib? ( sys-libs/zlib )
+"
+
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
+DEPEND="${CDEPEND}
+sys-devel/bison
+sys-devel/flex
+nls? ( sys-devel/gettext )
+xml? ( virtual/pkgconfig )
+"
+
+RDEPEND="${CDEPEND}
+selinux? ( sec-policy/selinux-postgresql )
+"
+
+pkg_setup() {
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	# Work around PPC{,64} compilation bug where bool is already defined
+	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
+
+	# Set proper run directory
+	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
+		-i src/include/pg_config_manual.h || die
+
+	# Rely on $PATH being in the proper order so that the correct
+	# install program is used for modules utilizing PGXS in both
+	# hardened and non-hardened environments. (Bug #528786)
+	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
+
+	use server || eapply "${FILESDIR}/${PN}-9.5.5-no-server.patch"
+
+	if use pam ; then
+		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+			-i src/backend/libpq/auth.c || \
+			die 'PGSQL_PAM_SERVICE rename failed.'
+	fi
+
+	eapply_user
+}
+
+src_configure() {
+	case ${CHOST} in
+		*-darwin*|*-solaris*)
+			use nls && append-libs intl
+			;;
+	esac
+
+	export LDFLAGS_SL="${LDFLAGS}"
+	export LDFLAGS_EX="${LDFLAGS}"
+
+	local PO="${EPREFIX}"
+
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
+	econf \
+		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
+		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
+		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
+		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
+		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
+		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
+		$(use_enable !pg-legacytimestamp integer-datetimes) \
+		$(use_enable debug) \
+		$(use_enable threads thread-safety) \
+		$(use_with kerberos gssapi) \
+		$(use_with ldap) \
+		$(use_with pam) \
+		$(use_with perl) \
+		$(use_with python) \
+		$(use_with readline) \
+		$(use_with ssl openssl) \
+		$(use_with tcl) \
+		${uuid_config} \
+		$(use_with xml libxml) \
+		$(use_with xml libxslt) \
+		$(use_with zlib) \
+		$(use_enable nls)
+}
+
+src_compile() {
+	emake
+	emake -C contrib
+}
+
+src_install() {
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
+
+	dodoc README HISTORY doc/{TODO,bug.template}
+
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
+
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
+
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
+			bn=$(basename "${f}")
+			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
+		done
+
+		popd > /dev/null
+	done
+
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
+
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
+
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
+
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.2" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql96). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
+	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
+}
+
+pkg_postinst() {
+	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
+	postgresql-config update
+
+	if use alpha && use server ; then
+		ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
+		ewarn "As a result, performance will be extremely degraded."
+	fi
+
+	elog "If you need a global psqlrc-file, you can place it in:"
+	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
+
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+	fi
+}
+
+pkg_prerm() {
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
+		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
+		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
+
+		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
+		sleep 10
+		eend 0
+	fi
+}
+
+pkg_postrm() {
+	postgresql-config update
+}
+
+pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
+	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
+		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
+	[[ -z "${DATA_DIR}" ]] \
+		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
+
+	# environment.bz2 may not contain the same locale as the current system
+	# locale. Unset and source from the current system locale.
+	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
+		unset LANG
+		unset LC_CTYPE
+		unset LC_NUMERIC
+		unset LC_TIME
+		unset LC_COLLATE
+		unset LC_MONETARY
+		unset LC_MESSAGES
+		unset LC_ALL
+		source "${EROOT}/etc/env.d/02locale"
+		[ -n "${LANG}" ] && export LANG
+		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
+		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
+		[ -n "${LC_TIME}" ] && export LC_TIME
+		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
+		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
+		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
+		[ -n "${LC_ALL}" ] && export LC_ALL
+	fi
+
+	einfo "You can modify the paths and options passed to initdb by editing:"
+	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	einfo
+	einfo "Information on options that can be passed to initdb are found at:"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
+	einfo
+	einfo "PG_INITDB_OPTS is currently set to:"
+	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
+		einfo "    (none)"
+	else
+		einfo "    ${PG_INITDB_OPTS}"
+	fi
+	einfo
+	einfo "Configuration files will be installed to:"
+	einfo "    ${PGDATA}"
+	einfo
+	einfo "The database cluster will be created in:"
+	einfo "    ${DATA_DIR}"
+	einfo
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
+
+	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
+		eerror "The given directory, '${DATA_DIR}', is not empty."
+		eerror "Modify DATA_DIR to point to an empty directory."
+		die "${DATA_DIR} is not empty."
+	fi
+
+	einfo "Creating the data directory ..."
+	if [[ ${EUID} == 0 ]] ; then
+		mkdir -p "${DATA_DIR}"
+		chown -Rf postgres:postgres "${DATA_DIR}"
+		chmod 0700 "${DATA_DIR}"
+	fi
+
+	einfo "Initializing the database ..."
+
+	if [[ ${EUID} == 0 ]] ; then
+		su postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
+	else
+		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
+	fi
+
+	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
+		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
+		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
+	fi
+
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
+	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
+		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
+		# On the off-chance that you might need to work with UTF-8 encoded
+		# characters in PL/Perl
+		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
+	EOF
+
+	einfo "The autovacuum function, which was in contrib, has been moved to the main"
+	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
+	einfo "by default. You can disable it in the cluster's:"
+	einfo "    ${PGDATA%/}/postgresql.conf"
+	einfo
+	einfo "The PostgreSQL server, by default, will log events to:"
+	einfo "    ${DATA_DIR%/}/postmaster.log"
+	einfo
+	if use prefix ; then
+		einfo "The location of the configuration files have moved to:"
+		einfo "    ${PGDATA}"
+		einfo "To start the server:"
+		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
+		einfo "To stop:"
+		einfo "    pg_ctl stop -D ${DATA_DIR}"
+		einfo
+		einfo "Or move the configuration files back:"
+		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	else
+		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	fi
+}
+
+src_test() {
+	if use server && [[ ${UID} -ne 0 ]] ; then
+		emake check
+
+		einfo "If you think other tests besides the regression tests are necessary, please"
+		einfo "submit a bug including a patch for this ebuild to enable them."
+	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
+		ewarn 'Skipping.'
+	fi
+}

diff --git a/dev-db/postgresql/postgresql-9.6.19.ebuild b/dev-db/postgresql/postgresql-9.6.19.ebuild
new file mode 100644
index 00000000000..52f63bca1fb
--- /dev/null
+++ b/dev-db/postgresql/postgresql-9.6.19.ebuild
@@ -0,0 +1,481 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7} )
+
+inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+
+SLOT=$(ver_cut 1-2)
+
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
+
+LICENSE="POSTGRESQL GPL-2"
+DESCRIPTION="PostgreSQL RDBMS"
+HOMEPAGE="https://www.postgresql.org/"
+
+IUSE="debug doc kerberos kernel_linux ldap libressl nls pam perl
+	  -pg-legacytimestamp python +readline selinux +server systemd ssl
+	  static-libs tcl threads uuid xml zlib"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+CDEPEND="
+>=app-eselect/eselect-postgresql-2.0
+acct-group/postgres
+acct-user/postgres
+sys-apps/less
+virtual/libintl
+kerberos? ( virtual/krb5 )
+ldap? ( net-nds/openldap )
+pam? ( sys-libs/pam )
+perl? ( >=dev-lang/perl-5.8:= )
+python? ( ${PYTHON_DEPS} )
+readline? ( sys-libs/readline:0= )
+ssl? (
+	!libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
+	libressl? ( dev-libs/libressl:= )
+)
+server? ( systemd? ( sys-apps/systemd ) )
+tcl? ( >=dev-lang/tcl-8:0= )
+xml? ( dev-libs/libxml2 dev-libs/libxslt )
+zlib? ( sys-libs/zlib )
+"
+
+# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
+# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
+# the libc includes UUID functions.
+UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
+BSD_LIBC=( elibc_{Free,Net,Open}BSD )
+
+nest_usedep() {
+	local front back
+	while [[ ${#} -gt 1 ]]; do
+		front+="${1}? ( "
+		back+=" )"
+		shift
+	done
+	echo "${front}${1}${back}"
+}
+
+IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
+CDEPEND+="
+uuid? (
+	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
+	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
+)"
+
+DEPEND="${CDEPEND}
+sys-devel/bison
+sys-devel/flex
+nls? ( sys-devel/gettext )
+xml? ( virtual/pkgconfig )
+"
+
+RDEPEND="${CDEPEND}
+selinux? ( sec-policy/selinux-postgresql )
+"
+
+pkg_setup() {
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	# Work around PPC{,64} compilation bug where bool is already defined
+	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
+
+	# Set proper run directory
+	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
+		-i src/include/pg_config_manual.h || die
+
+	# Rely on $PATH being in the proper order so that the correct
+	# install program is used for modules utilizing PGXS in both
+	# hardened and non-hardened environments. (Bug #528786)
+	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
+
+	use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch"
+
+	if use pam ; then
+		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+			-i src/backend/libpq/auth.c || \
+			die 'PGSQL_PAM_SERVICE rename failed.'
+	fi
+
+	eapply_user
+}
+
+src_configure() {
+	case ${CHOST} in
+		*-darwin*|*-solaris*)
+			use nls && append-libs intl
+			;;
+	esac
+
+	export LDFLAGS_SL="${LDFLAGS}"
+	export LDFLAGS_EX="${LDFLAGS}"
+
+	local PO="${EPREFIX}"
+
+	local i uuid_config=""
+	if use uuid; then
+		for i in ${UTIL_LINUX_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=e2fs"
+		done
+		for i in ${BSD_LIBC[@]}; do
+			use ${i} && uuid_config="--with-uuid=bsd"
+		done
+		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
+	fi
+
+	econf \
+		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
+		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
+		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
+		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
+		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
+		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
+		$(use_enable !pg-legacytimestamp integer-datetimes) \
+		$(use_enable debug) \
+		$(use_enable threads thread-safety) \
+		$(use_with kerberos gssapi) \
+		$(use_with ldap) \
+		$(use_with pam) \
+		$(use_with perl) \
+		$(use_with python) \
+		$(use_with readline) \
+		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
+		$(use_with tcl) \
+		${uuid_config} \
+		$(use_with xml libxml) \
+		$(use_with xml libxslt) \
+		$(use_with zlib) \
+		$(use_enable nls)
+}
+
+src_compile() {
+	emake
+	emake -C contrib
+}
+
+src_install() {
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
+
+	dodoc README HISTORY doc/{TODO,bug.template}
+
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
+	fi
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
+
+	# Create slot specific man pages
+	local bn f mansec slotted_name
+	for mansec in 1 3 7 ; do
+		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
+
+		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
+		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
+
+		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
+			bn=$(basename "${f}")
+			slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
+			case ${bn} in
+				TABLE.7|WITH.7)
+					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
+					;;
+				*)
+					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
+					;;
+			esac
+		done
+
+		popd > /dev/null
+	done
+
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
+
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
+
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		# Temporarily tack on tmp to workaround a file collision
+		# issue. This is only necessary for 9.7 and earlier. 10 never
+		# had this issue.
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}tmp"
+	done
+
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+
+		docinto sgml
+		dodoc doc/src/sgml/*.{sgml,dsl}
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
+}
+
+pkg_preinst() {
+	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
+	# /usr/bin/psql96). They may have been created by the
+	# postgresql.eselect module, but they're handled within this ebuild
+	# now. It's alright if we momentarily delete /usr/bin/psql as it
+	# will be recreated by the eselect module in pkg_ppostinst(). This
+	# is only necessary for 9.7 and earlier. 10 and later were never
+	# handled in this manner.
+	local canonicalise
+	if type -p realpath > /dev/null; then
+		canonicalise=realpath
+	elif type -p readlink > /dev/null; then
+		canonicalise='readlink -f'
+	else
+		# can't die, subshell
+		die "No readlink nor realpath found, cannot canonicalise"
+	fi
+
+	local l
+	# First remove any symlinks in /usr/bin that may have been created
+	# by the old eselect
+	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
+		if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
+			rm "${l}" || ewarn "Couldn't remove ${l}"
+		fi
+	done
+
+	# Then move the symlinks created by the ebuild to their proper place.
+	for l in "${ED}"/usr/bin/*tmp ; do
+		mv "${l}" "${l%tmp}" \
+			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
+	done
+}
+
+pkg_postinst() {
+	use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
+	postgresql-config update
+
+	elog "If you need a global psqlrc-file, you can place it in:"
+	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
+
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+	fi
+}
+
+pkg_prerm() {
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
+		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
+		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
+
+		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
+		sleep 10
+		eend 0
+	fi
+}
+
+pkg_postrm() {
+	postgresql-config update
+}
+
+pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
+	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
+		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
+	[[ -z "${DATA_DIR}" ]] \
+		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
+
+	# environment.bz2 may not contain the same locale as the current system
+	# locale. Unset and source from the current system locale.
+	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
+		unset LANG
+		unset LC_CTYPE
+		unset LC_NUMERIC
+		unset LC_TIME
+		unset LC_COLLATE
+		unset LC_MONETARY
+		unset LC_MESSAGES
+		unset LC_ALL
+		source "${EROOT}/etc/env.d/02locale"
+		[ -n "${LANG}" ] && export LANG
+		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
+		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
+		[ -n "${LC_TIME}" ] && export LC_TIME
+		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
+		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
+		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
+		[ -n "${LC_ALL}" ] && export LC_ALL
+	fi
+
+	einfo "You can modify the paths and options passed to initdb by editing:"
+	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+	einfo
+	einfo "Information on options that can be passed to initdb are found at:"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
+	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
+	einfo
+	einfo "PG_INITDB_OPTS is currently set to:"
+	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
+		einfo "    (none)"
+	else
+		einfo "    ${PG_INITDB_OPTS}"
+	fi
+	einfo
+	einfo "Configuration files will be installed to:"
+	einfo "    ${PGDATA}"
+	einfo
+	einfo "The database cluster will be created in:"
+	einfo "    ${DATA_DIR}"
+	einfo
+
+	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
+	sleep 5
+	eend 0
+
+	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
+		eerror "The given directory, '${DATA_DIR}', is not empty."
+		eerror "Modify DATA_DIR to point to an empty directory."
+		die "${DATA_DIR} is not empty."
+	fi
+
+	einfo "Creating the data directory ..."
+	if [[ ${EUID} == 0 ]] ; then
+		mkdir -p "${DATA_DIR}"
+		chown -Rf postgres:postgres "${DATA_DIR}"
+		chmod 0700 "${DATA_DIR}"
+	fi
+
+	einfo "Initializing the database ..."
+
+	if [[ ${EUID} == 0 ]] ; then
+		su postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
+	else
+		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
+	fi
+
+	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
+		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
+		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
+	fi
+
+	# unix_socket_directory has no effect in postgresql.conf as it's
+	# overridden in the initscript
+	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
+
+	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
+		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
+		# On the off-chance that you might need to work with UTF-8 encoded
+		# characters in PL/Perl
+		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
+	EOF
+
+	einfo "The autovacuum function, which was in contrib, has been moved to the main"
+	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
+	einfo "by default. You can disable it in the cluster's:"
+	einfo "    ${PGDATA%/}/postgresql.conf"
+	einfo
+	if ! use systemd; then
+		einfo "The PostgreSQL server, by default, will log events to:"
+		einfo "    ${DATA_DIR%/}/postmaster.log"
+		einfo
+	fi
+	if use prefix ; then
+		einfo "The location of the configuration files have moved to:"
+		einfo "    ${PGDATA}"
+		einfo "To start the server:"
+		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
+		einfo "To stop:"
+		einfo "    pg_ctl stop -D ${DATA_DIR}"
+		einfo
+		einfo "Or move the configuration files back:"
+		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
+	elif use systemd; then
+		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	else
+		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
+		einfo "instead of 'pg_ctl'."
+	fi
+}
+
+src_test() {
+	if use server && [[ ${UID} -ne 0 ]] ; then
+		emake check
+
+		einfo "If you think other tests besides the regression tests are necessary, please"
+		einfo "submit a bug including a patch for this ebuild to enable them."
+	else
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
+		ewarn 'Skipping.'
+	fi
+}


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2021-08-13 11:37 Marek Szuba
  0 siblings, 0 replies; 14+ messages in thread
From: Marek Szuba @ 2021-08-13 11:37 UTC (permalink / raw
  To: gentoo-commits

commit:     4e6174c72b182b4e10556950cc4be63422df131a
Author:     Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 13 11:31:04 2021 +0000
Commit:     Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Fri Aug 13 11:34:03 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4e6174c7

dev-db/postgresql: enable native spinlock support on riscv

Don't bother with a revbump even though this is a run-time change
- 13.4 and 14_beta3 were released yesterday so in the rather unlikely
event of someone already running a PostgreSQL server on a Gentoo/RISC-V
system, they will receive this change along with the the
hopefully-imminent version bump.

Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>

 .../files/postgresql-13.3-riscv-spinlocks.patch    | 26 ++++++++++++++++++++++
 dev-db/postgresql/postgresql-13.3.ebuild           |  4 +++-
 dev-db/postgresql/postgresql-14_beta2.ebuild       |  4 +++-
 dev-db/postgresql/postgresql-9999.ebuild           |  5 ++++-
 4 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/dev-db/postgresql/files/postgresql-13.3-riscv-spinlocks.patch b/dev-db/postgresql/files/postgresql-13.3-riscv-spinlocks.patch
new file mode 100644
index 00000000000..86d1fae20d8
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-13.3-riscv-spinlocks.patch
@@ -0,0 +1,26 @@
+--- a/src/include/storage/s_lock.h
++++ b/src/include/storage/s_lock.h
+@@ -315,12 +315,12 @@
+ #endif	 /* __ia64__ || __ia64 */
+ 
+ /*
+- * On ARM and ARM64, we use __sync_lock_test_and_set(int *, int) if available.
++ * On ARM, ARM64 and RISC-V, we use __sync_lock_test_and_set(int *, int) if available.
+  *
+  * We use the int-width variant of the builtin because it works on more chips
+  * than other widths.
+  */
+-#if defined(__arm__) || defined(__arm) || defined(__aarch64__) || defined(__aarch64)
++#if defined(__arm__) || defined(__arm) || defined(__aarch64__) || defined(__aarch64) || defined(__riscv)
+ #ifdef HAVE_GCC__SYNC_INT32_TAS
+ #define HAS_TEST_AND_SET
+ 
+@@ -337,7 +337,7 @@
+ #define S_UNLOCK(lock) __sync_lock_release(lock)
+ 
+ #endif	 /* HAVE_GCC__SYNC_INT32_TAS */
+-#endif	 /* __arm__ || __arm || __aarch64__ || __aarch64 */
++#endif	 /* __arm__ || __arm || __aarch64__ || __aarch64 || __riscv */
+ 
+ 
+ /* S/390 and S/390x Linux (32- and 64-bit zSeries) */

diff --git a/dev-db/postgresql/postgresql-13.3.ebuild b/dev-db/postgresql/postgresql-13.3.ebuild
index 85d7618669c..4063b6442c5 100644
--- a/dev-db/postgresql/postgresql-13.3.ebuild
+++ b/dev-db/postgresql/postgresql-13.3.ebuild
@@ -91,6 +91,8 @@ pkg_setup() {
 }
 
 src_prepare() {
+	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
+
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
@@ -159,7 +161,7 @@ src_configure() {
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
 		$(use_enable nls)"
-	if use alpha || use riscv; then
+	if use alpha; then
 		myconf+=" --disable-spinlocks"
 	else
 		# Should be the default but just in case

diff --git a/dev-db/postgresql/postgresql-14_beta2.ebuild b/dev-db/postgresql/postgresql-14_beta2.ebuild
index e6463312ebc..7cf4067cc08 100644
--- a/dev-db/postgresql/postgresql-14_beta2.ebuild
+++ b/dev-db/postgresql/postgresql-14_beta2.ebuild
@@ -92,6 +92,8 @@ pkg_setup() {
 }
 
 src_prepare() {
+	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
+
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
@@ -161,7 +163,7 @@ src_configure() {
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
 		$(use_enable nls)"
-	if use alpha || use riscv; then
+	if use alpha; then
 		myconf+=" --disable-spinlocks"
 	else
 		# Should be the default but just in case

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild
index 8bdc4467a14..9b90b0ee77a 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -110,6 +110,9 @@ pkg_setup() {
 }
 
 src_prepare() {
+	# still needed as of 2021-08-13
+	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
+
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
@@ -177,7 +180,7 @@ src_configure() {
 		$(use_with zlib) \
 		$(use_with systemd) \
 		${uuid_config}"
-	if use alpha || use riscv; then
+	if use alpha; then
 		myconf+=" --disable-spinlocks"
 	else
 		# Should be the default but just in case


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2022-03-24  6:28 罗百科
  0 siblings, 0 replies; 14+ messages in thread
From: 罗百科 @ 2022-03-24  6:28 UTC (permalink / raw
  To: gentoo-commits

commit:     d49fccf6cbbbdab563c1d38718f9dc177548659b
Author:     Patrick Lauer <patrick <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 24 06:28:11 2022 +0000
Commit:     罗百科 <patrick <AT> gentoo <DOT> org>
CommitDate: Thu Mar 24 06:28:11 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d49fccf6

dev-db/postgresql: llvm14 support

Upstream patch applies to v.12+
Restrict max llvm version to 13 for v.11 as patch fails
(this should be rectified in next upstream release)

Bug: https://bugs.gentoo.org/835861
Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Patrick Lauer <patrick <AT> gentoo.org>

 dev-db/postgresql/files/postgres-llvm14.patch | 154 ++++++++++++++++++++++++++
 dev-db/postgresql/postgresql-11.14-r1.ebuild  |   9 +-
 dev-db/postgresql/postgresql-11.15-r1.ebuild  |   9 +-
 dev-db/postgresql/postgresql-12.10-r1.ebuild  |   1 +
 dev-db/postgresql/postgresql-12.9-r1.ebuild   |   1 +
 dev-db/postgresql/postgresql-13.5-r1.ebuild   |   1 +
 dev-db/postgresql/postgresql-13.6-r1.ebuild   |   1 +
 dev-db/postgresql/postgresql-14.1-r1.ebuild   |   1 +
 dev-db/postgresql/postgresql-14.2-r1.ebuild   |   1 +
 9 files changed, 172 insertions(+), 6 deletions(-)

diff --git a/dev-db/postgresql/files/postgres-llvm14.patch b/dev-db/postgresql/files/postgres-llvm14.patch
new file mode 100644
index 000000000000..2c7b91d75153
--- /dev/null
+++ b/dev-db/postgresql/files/postgres-llvm14.patch
@@ -0,0 +1,154 @@
+From d9f7ad54e552262ee0090e88d5abd3e04fcdeac8 Mon Sep 17 00:00:00 2001
+From: Thomas Munro <tmunro@postgresql.org>
+Date: Wed, 16 Mar 2022 11:35:00 +1300
+Subject: [PATCH] Back-patch LLVM 14 API changes.
+
+Since LLVM 14 has stopped changing and is about to be released,
+back-patch the following changes from the master branch:
+
+  e6a7600202105919bffd62b3dfd941f4a94e082b
+  807fee1a39de6bb8184082012e643951abb9ad1d
+  a56e7b66010f330782243de9e25ac2a6596be0e1
+
+Back-patch to 11, where LLVM JIT support came in.
+---
+ src/backend/jit/llvm/Makefile           |  6 +++++
+ src/backend/jit/llvm/llvmjit_error.cpp  | 35 +++++++++++++++++++++----
+ src/backend/jit/llvm/llvmjit_inline.cpp | 12 ++++++++-
+ 3 files changed, 47 insertions(+), 6 deletions(-)
+
+diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
+index 0268bd46d5..2da122a391 100644
+--- a/src/backend/jit/llvm/Makefile
++++ b/src/backend/jit/llvm/Makefile
+@@ -22,6 +22,12 @@ endif
+ PGFILEDESC = "llvmjit - JIT using LLVM"
+ NAME = llvmjit
+ 
++# LLVM 14 produces deprecation warnings.  We'll need to make some changes
++# before the relevant functions are removed, but for now silence the warnings.
++ifeq ($(GCC), yes)
++LLVM_CFLAGS += -Wno-deprecated-declarations
++endif
++
+ # All files in this directory use LLVM.
+ CFLAGS += $(LLVM_CFLAGS)
+ CXXFLAGS += $(LLVM_CXXFLAGS)
+diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp
+index f4720732a3..5ad92f3090 100644
+--- a/src/backend/jit/llvm/llvmjit_error.cpp
++++ b/src/backend/jit/llvm/llvmjit_error.cpp
+@@ -23,15 +23,22 @@ extern "C"
+ 
+ #include "jit/llvmjit.h"
+ 
++#include <new>
+ 
+ static int fatal_new_handler_depth = 0;
+ static std::new_handler old_new_handler = NULL;
+ 
+ static void fatal_system_new_handler(void);
+ #if LLVM_VERSION_MAJOR > 4
++static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag);
++#if LLVM_VERSION_MAJOR < 14
+ static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
+ #endif
++#endif
++static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag);
++#if LLVM_VERSION_MAJOR < 14
+ static void fatal_llvm_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
++#endif
+ 
+ 
+ /*
+@@ -129,23 +136,41 @@ fatal_system_new_handler(void)
+ #if LLVM_VERSION_MAJOR > 4
+ static void
+ fatal_llvm_new_handler(void *user_data,
+-					   const std::string& reason,
++					   const char *reason,
+ 					   bool gen_crash_diag)
+ {
+ 	ereport(FATAL,
+ 			(errcode(ERRCODE_OUT_OF_MEMORY),
+ 			 errmsg("out of memory"),
+-			 errdetail("While in LLVM: %s", reason.c_str())));
++			 errdetail("While in LLVM: %s", reason)));
++}
++#if LLVM_VERSION_MAJOR < 14
++static void
++fatal_llvm_new_handler(void *user_data,
++					   const std::string& reason,
++					   bool gen_crash_diag)
++{
++	fatal_llvm_new_handler(user_data, reason.c_str(), gen_crash_diag);
+ }
+ #endif
++#endif
+ 
+ static void
+ fatal_llvm_error_handler(void *user_data,
+-						 const std::string& reason,
++						 const char *reason,
+ 						 bool gen_crash_diag)
+ {
+ 	ereport(FATAL,
+ 			(errcode(ERRCODE_OUT_OF_MEMORY),
+-			 errmsg("fatal llvm error: %s",
+-					reason.c_str())));
++			 errmsg("fatal llvm error: %s", reason)));
+ }
++
++#if LLVM_VERSION_MAJOR < 14
++static void
++fatal_llvm_error_handler(void *user_data,
++						 const std::string& reason,
++						 bool gen_crash_diag)
++{
++	fatal_llvm_error_handler(user_data, reason.c_str(), gen_crash_diag);
++}
++#endif
+diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp
+index 6f03595db5..9bb4b672a7 100644
+--- a/src/backend/jit/llvm/llvmjit_inline.cpp
++++ b/src/backend/jit/llvm/llvmjit_inline.cpp
+@@ -594,7 +594,11 @@ function_inlinable(llvm::Function &F,
+ 	if (F.materialize())
+ 		elog(FATAL, "failed to materialize metadata");
+ 
+-	if (F.getAttributes().hasFnAttribute(llvm::Attribute::NoInline))
++#if LLVM_VERSION_MAJOR < 14
++#define hasFnAttr hasFnAttribute
++#endif
++
++	if (F.getAttributes().hasFnAttr(llvm::Attribute::NoInline))
+ 	{
+ 		ilog(DEBUG1, "ineligibile to import %s due to noinline",
+ 			 F.getName().data());
+@@ -871,7 +875,9 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
+ 	llvm::Function *AF;
+ 	llvm::BasicBlock *BB;
+ 	llvm::CallInst *fwdcall;
++#if LLVM_VERSION_MAJOR < 14
+ 	llvm::Attribute inlineAttribute;
++#endif
+ 
+ 	AF = llvm::Function::Create(F->getFunctionType(),
+ 								LinkageTypes::AvailableExternallyLinkage,
+@@ -880,9 +886,13 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
+ 
+ 	Builder.SetInsertPoint(BB);
+ 	fwdcall = Builder.CreateCall(F, &*AF->arg_begin());
++#if LLVM_VERSION_MAJOR < 14
+ 	inlineAttribute = llvm::Attribute::get(Context,
+ 										   llvm::Attribute::AlwaysInline);
+ 	fwdcall->addAttribute(~0U, inlineAttribute);
++#else
++	fwdcall->addFnAttr(llvm::Attribute::AlwaysInline);
++#endif
+ 	Builder.CreateRet(fwdcall);
+ 
+ 	return AF;
+-- 
+2.30.2
+

diff --git a/dev-db/postgresql/postgresql-11.14-r1.ebuild b/dev-db/postgresql/postgresql-11.14-r1.ebuild
index 87ce14e8127a..8ec21798e0ae 100644
--- a/dev-db/postgresql/postgresql-11.14-r1.ebuild
+++ b/dev-db/postgresql/postgresql-11.14-r1.ebuild
@@ -4,8 +4,9 @@
 EAPI=7
 
 PYTHON_COMPAT=( python3_{8,9,10} )
+LLVM_MAX_SLOT=13
 
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
+inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
 
 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
 
@@ -36,8 +37,8 @@ icu? ( dev-libs/icu:= )
 kerberos? ( virtual/krb5 )
 ldap? ( net-nds/openldap:= )
 llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
+	<sys-devel/llvm-14:=
+	<sys-devel/clang-14:=
 )
 pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
@@ -83,6 +84,8 @@ selinux? ( sec-policy/selinux-postgresql )
 "
 
 pkg_setup() {
+	use llvm && llvm_pkg_setup
+
 	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup

diff --git a/dev-db/postgresql/postgresql-11.15-r1.ebuild b/dev-db/postgresql/postgresql-11.15-r1.ebuild
index c39ca2b3e87a..4be0a8926b5d 100644
--- a/dev-db/postgresql/postgresql-11.15-r1.ebuild
+++ b/dev-db/postgresql/postgresql-11.15-r1.ebuild
@@ -4,8 +4,9 @@
 EAPI=7
 
 PYTHON_COMPAT=( python3_{8,9,10} )
+LLVM_MAX_SLOT=13
 
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
+inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
 
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
 
@@ -36,8 +37,8 @@ icu? ( dev-libs/icu:= )
 kerberos? ( virtual/krb5 )
 ldap? ( net-nds/openldap:= )
 llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
+	<sys-devel/llvm-14:=
+	<sys-devel/clang-14:=
 )
 pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
@@ -83,6 +84,8 @@ selinux? ( sec-policy/selinux-postgresql )
 "
 
 pkg_setup() {
+	use llvm && llvm_pkg_setup
+
 	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup

diff --git a/dev-db/postgresql/postgresql-12.10-r1.ebuild b/dev-db/postgresql/postgresql-12.10-r1.ebuild
index bbbce9e61a2a..614645d2a890 100644
--- a/dev-db/postgresql/postgresql-12.10-r1.ebuild
+++ b/dev-db/postgresql/postgresql-12.10-r1.ebuild
@@ -99,6 +99,7 @@ src_prepare() {
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
 	use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch"
+	use server && eapply "${FILESDIR}/postgres-llvm14.patch"
 
 	if use pam ; then
 		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \

diff --git a/dev-db/postgresql/postgresql-12.9-r1.ebuild b/dev-db/postgresql/postgresql-12.9-r1.ebuild
index e6b25b4e5b42..c011d4b2a894 100644
--- a/dev-db/postgresql/postgresql-12.9-r1.ebuild
+++ b/dev-db/postgresql/postgresql-12.9-r1.ebuild
@@ -99,6 +99,7 @@ src_prepare() {
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
 	use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch"
+	use server && eapply "${FILESDIR}/postgres-llvm14.patch"
 
 	if use pam ; then
 		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \

diff --git a/dev-db/postgresql/postgresql-13.5-r1.ebuild b/dev-db/postgresql/postgresql-13.5-r1.ebuild
index d66f1944a5b6..71f1f9853dea 100644
--- a/dev-db/postgresql/postgresql-13.5-r1.ebuild
+++ b/dev-db/postgresql/postgresql-13.5-r1.ebuild
@@ -101,6 +101,7 @@ src_prepare() {
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
 	use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch"
+	use server && eapply "${FILESDIR}/postgres-llvm14.patch"
 
 	if use pam ; then
 		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \

diff --git a/dev-db/postgresql/postgresql-13.6-r1.ebuild b/dev-db/postgresql/postgresql-13.6-r1.ebuild
index 57825100e068..b40f660c6477 100644
--- a/dev-db/postgresql/postgresql-13.6-r1.ebuild
+++ b/dev-db/postgresql/postgresql-13.6-r1.ebuild
@@ -101,6 +101,7 @@ src_prepare() {
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
 	use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch"
+	use server && eapply "${FILESDIR}/postgres-llvm14.patch"
 
 	if use pam ; then
 		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \

diff --git a/dev-db/postgresql/postgresql-14.1-r1.ebuild b/dev-db/postgresql/postgresql-14.1-r1.ebuild
index c40034ddaf1b..5d0ca44d23aa 100644
--- a/dev-db/postgresql/postgresql-14.1-r1.ebuild
+++ b/dev-db/postgresql/postgresql-14.1-r1.ebuild
@@ -100,6 +100,7 @@ src_prepare() {
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
 	use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch"
+	use server && eapply "${FILESDIR}/postgres-llvm14.patch"
 
 	if use pam ; then
 		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \

diff --git a/dev-db/postgresql/postgresql-14.2-r1.ebuild b/dev-db/postgresql/postgresql-14.2-r1.ebuild
index c40034ddaf1b..5d0ca44d23aa 100644
--- a/dev-db/postgresql/postgresql-14.2-r1.ebuild
+++ b/dev-db/postgresql/postgresql-14.2-r1.ebuild
@@ -100,6 +100,7 @@ src_prepare() {
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
 	use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch"
+	use server && eapply "${FILESDIR}/postgres-llvm14.patch"
 
 	if use pam ; then
 		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2022-08-15 16:53 Aaron W. Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron W. Swenson @ 2022-08-15 16:53 UTC (permalink / raw
  To: gentoo-commits

commit:     b02edae84b979b6a303de9a9410a57bfa33386d3
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 15 16:52:47 2022 +0000
Commit:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Mon Aug 15 16:52:47 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b02edae8

dev-db/postgresql: Security bump

Vulnerability CVE-2022-2625 addressed by bump to:
- 10.22
- 11.17
- 12.12
- 13.8
- 14.5
- 15_beta3

Also, pgbench is installed with -server again.

Removed unused eclasses multilib and prefix.

Bug: https://bugs.gentoo.org/865255
Closes: https://bugs.gentoo.org/860360

Signed-off-by: Aaron W. Swenson <titanofold <AT> gentoo.org>

 dev-db/postgresql/Manifest                         |   6 +
 .../files/postgresql-13.8-no-server.patch          | 144 ++++++++++
 .../files/postgresql-14.5-no-server.patch          | 146 +++++++++++
 .../files/postgresql-15_beta3-no-server.patch      | 146 +++++++++++
 ...tgresql-9999.ebuild => postgresql-10.22.ebuild} | 285 ++++++++++----------
 ...tgresql-9999.ebuild => postgresql-11.17.ebuild} | 289 ++++++++++-----------
 ...tgresql-9999.ebuild => postgresql-12.12.ebuild} | 289 ++++++++++-----------
 ...stgresql-9999.ebuild => postgresql-13.8.ebuild} | 273 ++++++++++---------
 ...stgresql-9999.ebuild => postgresql-14.5.ebuild} | 266 +++++++++----------
 ...esql-9999.ebuild => postgresql-15_beta3.ebuild} | 264 +++++++++----------
 dev-db/postgresql/postgresql-9999.ebuild           |   7 +-
 11 files changed, 1225 insertions(+), 890 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 30f18e1224c6..9728a27e7cda 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,16 +1,22 @@
 DIST postgresql-10.19.tar.bz2 19261478 BLAKE2B 3ccd44d68980ddb0e394b811af20c213cf89eb8d4374d2c49c9cda5165f222ca849a2db4fe4d521991f15f9cc84ec35bafa91083b9625f2a6729159f490a94c9 SHA512 41b0f5026be7d563e41b54e9ea7199dd466a132d355be0b71a91d41f533d97fbf550eccf2a2ece3d60c5dab5921ebeea3ac4780c18c54b924df52d7423305a22
 DIST postgresql-10.20.tar.bz2 19371473 BLAKE2B 24ce3e3dda749375e999206307154e79bf15d20b3cd598ba0b78bf27976241d71e88e6fa4cd459b675bc9a9047e9315321b1535dbb41ed9e558858c2a7e9dd31 SHA512 44cfca541947d58c70593b767d3c2423f20cc6904f3d4cea8f63c1802ccbc569130c4a2a15f1af152285926f6a200e13d59c21584295dafd6f6e74bd38251428
 DIST postgresql-10.21.tar.bz2 19409454 BLAKE2B 5e43abaee8156b9eb99360efeb25ba268f93a60ac2c29044d9025c4faa8753d84cb3c0c8cbcd65eb9e0eb094ebf63e0cc1cbd0ef12c0a2faa360754e63ae106a SHA512 1053e15505c0448df491119c9aad1617889b66118628a2155e3ec87e6648b2071a0a54e10d8fbbe00161b2aa86d1a6194d932a8cf5808c626e7972d135bb05c5
+DIST postgresql-10.22.tar.bz2 19455874 BLAKE2B 10a8a894ba6e649abcc68abfd829bd30bca04b6e90f987ae5771fe02474517254ea2b48c7c9f2a899309de7b84aeaf13bac025965a9cc44814727ba257a633d7 SHA512 2e1ea75be7696ffbbb947351a8e8e55aaf067f86ad318308499a6a58797f0bf86227ed33e257e261c5c71ebba2f73ba514ef195a2394b91414ce6a0c3ab62532
 DIST postgresql-11.14.tar.bz2 20172910 BLAKE2B a033752fc5fc593c96fe63a258b2cc0d4b896548a366e3fefa8afde1f96ab64aab97eb395b10ae10494709963ed924623279f76f66870c4faee435969400c1b7 SHA512 ab71461ee6fb4cdc5b4240f7ecd8af2497ce6780283fde2abf5951ffdb616bd0c8ed22b26fdfca402a346e663ff77c4d17f3284c9d700e6fd6795b2aec97c9be
 DIST postgresql-11.15.tar.bz2 20245750 BLAKE2B f6a632606fe4b34b2a44df2c165ccfa6e890b85f4f6048994f781428bbd1de6888a24493fb5d0c231f3f34e6a4e94cfd23078a9afdaf5925d284b4854847d23f SHA512 1eba7bddee1edf034617102c1d61ad0aa1b58927dad63de1d054817966c4c9a1d7d3fa6f6896af3fe5a6880b09a6ec86be298256ee6ecc3705ff2654d3d00c74
 DIST postgresql-11.16.tar.bz2 20347100 BLAKE2B 240e86b68ff8833265f10802da2fb847d72e38ac9325fc56bb6864266b2ad98939170038ccdb7044ae16f9fd29e7a9e1d404456d8bc7d53430067d714b9bb563 SHA512 e1b6be0a97e60cdd95cd0ebc756b1de6abf2f33f41f6a80da3dff25483a30146fb6bf750ab787bb5bb4f2a04718946c7429e71f891cbd491001e9f9c2ea8e63c
+DIST postgresql-11.17.tar.bz2 20385599 BLAKE2B d145bc0f5e0f277be91bf46868c78c9ce5bb2eebbbd84fbdcdbb1ec115911d124a0a054df783739fb912eeae1322fb7eb58b7b1b8d40a8f81cffe2f24d3dda01 SHA512 35304279c06577eca134581490710db976edeac8cca169d3436fcdce8eebb18159459ea3b5ef403f6a8efe85542726f9960c4ca653da4619e081ce5869866032
 DIST postgresql-12.10.tar.bz2 20990621 BLAKE2B a7a56cf75944c558ae9bb9165dfb17b30cc5f7a865961e0a588677e4dd3e53d1fab15a212a21ec12f8e7b669a448d78efa0dfe985fd4902e16485a298c7adc62 SHA512 befedb14320aa033dc55bbb93bbbec4e67d9cfced63be0e4f631c7495a0fbc6fe280bd6d2fb941d7a2e6b2ac570b7f40d8db7f07a192a81bd9cd63c6c244a9c5
 DIST postgresql-12.11.tar.bz2 21086745 BLAKE2B 7062d334f3ef3b98f69e709f5de744324c7ce53ea516384902632a454a2ccadfd7bcc0c9ef4d51a685dd7a06e1fdccc292109294517831181c3db30bc2b7be91 SHA512 705e9e1ccf8202062cce61069b5ddb7db5f804dd0736c620640ce5622b9e42fdcbc1417771e77d51aa54beb4562a09b4307f2ff7dec135bd0e31f4941ca36ac8
+DIST postgresql-12.12.tar.bz2 21089064 BLAKE2B 7285dcfc8ed6cf2dbbe29d894dbcef53fad18cbeddbfdb3a43893234a1ee75a9bf5d966968a0c481a8ab15bf8a37400bf6eb4b57a83359501b729e70398e3551 SHA512 eeff79279ac11db04fdddeb2c52ba1ec6b549223b862222540e1f659fbfc3617130699c22694b465bde46b1a4a665c01aef70b68b86d80e58a5657efd019407d
 DIST postgresql-12.9.tar.bz2 20904260 BLAKE2B fc88d61d369569a3054b889848eaf1405a4f5137cd8c2cf27282115f70853dd4d5d8b4bf0a9fc60c63db936246a0a64077c9bfdb90685d4dfe375558e4519b2b SHA512 11697d8283f5df5a9c74c2406e94d1b6da6df8358ad48f3b773825aab98e8395f9fd4e3fc8b1e6ebad3743c3dadbda8b795d4fe84a447d7913223e136cf2b88f
 DIST postgresql-13.5.tar.bz2 21186674 BLAKE2B 3e51d6d67bba09fb134cd71c48349674e0cacfaefee299620482c93f0b09edbfead578deb63083686ab691563b088fc0ea60a6281a0bcf9145689fb3ce1ec0f0 SHA512 c76effbca8ee63be48fa3aeb39c7038221848fe83ca2afc4e0904ba8c6a50b89aa2ad37080d4e3be75e9bdc2d6ca6dfefcda334ef55a5e1a8954bb955ce905e5
 DIST postgresql-13.6.tar.bz2 21257213 BLAKE2B f5ea95fd9ffc8846e0aaf5bac03b02afa71e62e796bbe40f68af727a2f3c74eddd98cb68427bcc13b87b6fa00a8e2a7b18dd7749318f0a4a32cfdbf9b0e0a873 SHA512 2852726a3031b8d469f1c38f3019af02fc5afe40ec27b22288a29acefd30c63a98806bce88a214d0c2f9177f547b0b5010ad64e70bcbe2c2f1d97a27ae1984f8
 DIST postgresql-13.7.tar.bz2 21364433 BLAKE2B 2d8a505f6de4eb31cae415529eeac750a60abafcf45e7fde29043597b385a8150fac55df659f8c2ad200822e8063d388ed606dff9108d4407f9e26b893fa62f4 SHA512 9254f21519c8d4e926f70082503bb5593c91064a3d2a4ea18ac503dfd9aa94751d6f01ce00fca9fec9b2b7af40caf8d0951b661dd8be4d6aa87c1e35b6fa7a41
+DIST postgresql-13.8.tar.bz2 21397381 BLAKE2B eb076382027a175789652a6ae8579d9b9c8856918741e8058456d22f1ef89525cff5fafe863bf615f658bc94b740b00d1268825969e37a7cefed6b5c90f402c5 SHA512 3b39448b291342a5e9b610d410c222aeb85f8acf95632e73e138ae316133af3dadc795a6e706f6447f543cf10df3c786da4f1afa1d91489b50eb77e2d9ed5d84
 DIST postgresql-14.1.tar.bz2 21887101 BLAKE2B a496dfd513c52339d1b3cb72773f9611721fd7c5d2a702d6fd71f650a1d41c3d7bf6574eba23671c7f9f11718e007f51f9547949bdc3d7fe1ea2248ebfb8d70b SHA512 4a0bec157d5464bb9e5f5c0eb0efdede55526e03f6f4d660b87d161a47705eb152fa0878960b1581bce42a5ed28a1f457825ea54e8d22e34b5b8eb36473ceefd
 DIST postgresql-14.2.tar.bz2 21964841 BLAKE2B 6460533a40064404f18642147b949cf7c85d036c45ede478fb9af8919895ee7b09dc78b89ed08a292226911f07cfc9e46d7f2d42e0aaea546c5e97a291d599b9 SHA512 19aeb6528605dbcf5df84048b2eed8f54b202576134d3fe3900bb8f073179c4258d2581acd745887e7e6fa86ebdb5f7b159ffaa0a645d601efee7c5f7730456b
 DIST postgresql-14.4.tar.bz2 22094218 BLAKE2B 05b65083d826ed2f451b31b29b4b247dfd76b3d24ef05f6be128ee9e58d521d506a3ec4ae4839cbb74d8e217dfae81a95bd97894a778ef3c47b907b85b1fb25e SHA512 dd2f80248684e331d2ffb1e26cd2a285df1fb18710807a0c31aedabf917912ce9267f8ca26318e5371d916c6fe476f8a17886d82d3ff86a974e6f24c19a6aafb
+DIST postgresql-14.5.tar.bz2 22132996 BLAKE2B 6d303850ef1e8f9f5d66a53275fc814475646c762b9747a4f0401a472ebaf59be06d6e7c08e9c1c5ad5d3b9dbc3bb3c06d58bae137806e1a437c86bcc8cae501 SHA512 3051c5ab729f6a55952c6108098b022517398b1de64f7fefbdd6c806c7e2eb0637d00f3c98a6203c5bee654656528c4ff3530db5a69470e7888864c77900178a
 DIST postgresql-15beta2.tar.bz2 23511057 BLAKE2B d1e6d8ce67998d4295587780c2cb75f33b930556e11fd95bbd4d828086f63faed6bbddbb809ebc1fddf0980c83c7cf51e3d37f110d7bb68959dab34f61b5b8c9 SHA512 139bf4f95e2bc8942666009c6680d2b61d8ea2898e9e7eb3a0afb118f0bf6acfac5f21676525cccd82e9ee5c43ad79e07e23a55333e1318426d8b9bc95a4f00d
+DIST postgresql-15beta3.tar.bz2 23585136 BLAKE2B cdea196fb62587800f7fceafcbbd781f5636323fc6b205a0e5e0081964f2d08fcb421d0d66f710150dba37f30c2b0e7f7b3119a9a83a0cc573104968b16fc043 SHA512 caf79b889ca1325bcbdce3bbbcb3a0707b8928c8bd7b97f594cfedaedc06826e829a561b2fde73210c1e2596a0201305fa350bb3f12c05783014fc0c8564298a

diff --git a/dev-db/postgresql/files/postgresql-13.8-no-server.patch b/dev-db/postgresql/files/postgresql-13.8-no-server.patch
new file mode 100644
index 000000000000..295df7087c14
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-13.8-no-server.patch
@@ -0,0 +1,144 @@
+--- a/contrib/Makefile
++++ b/contrib/Makefile
+@@ -5,56 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-		adminpack	\
+-		amcheck		\
+-		auth_delay	\
+-		auto_explain	\
+-		bloom		\
+-		btree_gin	\
+-		btree_gist	\
+-		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
+--- a/src/backend/Makefile
++++ b/src/backend/Makefile
+@@ -56,7 +56,7 @@
+ 
+ ##########################################################################
+ 
+-all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
++all: generated-headers
+ 
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -195,23 +195,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
+-	$(MAKE) -C utils 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:
+ 
+ ifeq ($(with_llvm), yes)
+ install-bin: install-postgres-bitcode
+--- a/src/bin/Makefile
++++ b/src/bin/Makefile
+@@ -14,21 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-	initdb \
+-	pg_archivecleanup \
+-	pg_basebackup \
+-	pg_checksums \
+ 	pg_config \
+-	pg_controldata \
+-	pg_ctl \
+ 	pg_dump \
+-	pg_resetwal \
+-	pg_rewind \
+-	pg_test_fsync \
+-	pg_test_timing \
+-	pg_upgrade \
+-	pg_verifybackup \
+-	pg_waldump \
+ 	pgbench \
+ 	psql \
+ 	scripts
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -15,21 +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/isolation \
+-	test/perl
++	makefiles
+ 
+ ifeq ($(with_llvm), yes)
+ SUBDIRS += backend/jit/llvm

diff --git a/dev-db/postgresql/files/postgresql-14.5-no-server.patch b/dev-db/postgresql/files/postgresql-14.5-no-server.patch
new file mode 100644
index 000000000000..87bd89b68f19
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-14.5-no-server.patch
@@ -0,0 +1,146 @@
+--- a/contrib/Makefile
++++ b/contrib/Makefile
+@@ -5,57 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-		adminpack	\
+-		amcheck		\
+-		auth_delay	\
+-		auto_explain	\
+-		bloom		\
+-		btree_gin	\
+-		btree_gist	\
+-		citext		\
+-		cube		\
+-		dblink		\
+-		dict_int	\
+-		dict_xsyn	\
+-		earthdistance	\
+-		file_fdw	\
+-		fuzzystrmatch	\
+-		hstore		\
+-		intagg		\
+-		intarray	\
+-		isn		\
+-		lo		\
+-		ltree		\
+ 		oid2name	\
+-		old_snapshot	\
+-		pageinspect	\
+-		passwordcheck	\
+-		pg_buffercache	\
+-		pg_freespacemap \
+-		pg_prewarm	\
+-		pg_stat_statements \
+-		pg_surgery	\
+-		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_ssl),openssl)
+-SUBDIRS += sslinfo
+-else
+-ALWAYS_SUBDIRS += sslinfo
+-endif
+ 
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+--- a/src/backend/Makefile
++++ b/src/backend/Makefile
+@@ -56,7 +56,7 @@
+ 
+ ##########################################################################
+ 
+-all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
++all: generated-headers
+ 
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -194,23 +194,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
+-	$(MAKE) -C utils 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:
+ 
+ ifeq ($(with_llvm), yes)
+ install-bin: install-postgres-bitcode
+--- a/src/bin/Makefile
++++ b/src/bin/Makefile
+@@ -14,22 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-	initdb \
+-	pg_amcheck \
+-	pg_archivecleanup \
+-	pg_basebackup \
+-	pg_checksums \
+ 	pg_config \
+-	pg_controldata \
+-	pg_ctl \
+ 	pg_dump \
+-	pg_resetwal \
+-	pg_rewind \
+-	pg_test_fsync \
+-	pg_test_timing \
+-	pg_upgrade \
+-	pg_verifybackup \
+-	pg_waldump \
+ 	pgbench \
+ 	psql \
+ 	scripts
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -15,21 +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/isolation \
+-	test/perl
++	makefiles
+ 
+ ifeq ($(with_llvm), yes)
+ SUBDIRS += backend/jit/llvm

diff --git a/dev-db/postgresql/files/postgresql-15_beta3-no-server.patch b/dev-db/postgresql/files/postgresql-15_beta3-no-server.patch
new file mode 100644
index 000000000000..9ada0a71d5a0
--- /dev/null
+++ b/dev-db/postgresql/files/postgresql-15_beta3-no-server.patch
@@ -0,0 +1,146 @@
+--- a/contrib/Makefile
++++ b/contrib/Makefile
+@@ -5,59 +5,9 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-		adminpack	\
+-		amcheck		\
+-		auth_delay	\
+-		auto_explain	\
+-		basic_archive	\
+-		basebackup_to_shell	\
+-		bloom		\
+-		btree_gin	\
+-		btree_gist	\
+-		citext		\
+-		cube		\
+-		dblink		\
+-		dict_int	\
+-		dict_xsyn	\
+-		earthdistance	\
+-		file_fdw	\
+-		fuzzystrmatch	\
+-		hstore		\
+-		intagg		\
+-		intarray	\
+-		isn		\
+-		lo		\
+-		ltree		\
+ 		oid2name	\
+-		old_snapshot	\
+-		pageinspect	\
+-		passwordcheck	\
+-		pg_buffercache	\
+-		pg_freespacemap \
+-		pg_prewarm	\
+-		pg_stat_statements \
+-		pg_surgery	\
+-		pg_trgm		\
+-		pgrowlocks	\
+-		pgstattuple	\
+-		pg_visibility	\
+-		pg_walinspect	\
+-		postgres_fdw	\
+-		seg		\
+-		spi		\
+-		tablefunc	\
+-		tcn		\
+-		test_decoding	\
+-		tsm_system_rows \
+-		tsm_system_time \
+-		unaccent	\
+ 		vacuumlo
+ 
+-ifeq ($(with_ssl),openssl)
+-SUBDIRS += pgcrypto sslinfo
+-else
+-ALWAYS_SUBDIRS += pgcrypto sslinfo
+-endif
+ 
+ ifneq ($(with_uuid),no)
+ SUBDIRS += uuid-ossp
+--- a/src/backend/Makefile
++++ b/src/backend/Makefile
+@@ -56,7 +56,7 @@
+ 
+ ##########################################################################
+ 
+-all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
++all: generated-headers
+ 
+ ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+@@ -194,23 +194,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
+-	$(MAKE) -C utils 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:
+ 
+ ifeq ($(with_llvm), yes)
+ install-bin: install-postgres-bitcode
+--- a/src/bin/Makefile
++++ b/src/bin/Makefile
+@@ -14,22 +14,8 @@
+ include $(top_builddir)/src/Makefile.global
+ 
+ SUBDIRS = \
+-	initdb \
+-	pg_amcheck \
+-	pg_archivecleanup \
+-	pg_basebackup \
+-	pg_checksums \
+ 	pg_config \
+-	pg_controldata \
+-	pg_ctl \
+ 	pg_dump \
+-	pg_resetwal \
+-	pg_rewind \
+-	pg_test_fsync \
+-	pg_test_timing \
+-	pg_upgrade \
+-	pg_verifybackup \
+-	pg_waldump \
+ 	pgbench \
+ 	psql \
+ 	scripts
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -17,19 +17,11 @@
+ 	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/isolation \
+-	test/perl
++	makefiles
+ 
+ ifeq ($(with_llvm), yes)
+ SUBDIRS += backend/jit/llvm

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-10.22.ebuild
similarity index 65%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-10.22.ebuild
index cce0a2f8499a..bf8414a03338 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-10.22.ebuild
@@ -1,26 +1,28 @@
 # Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
-PYTHON_COMPAT=( python3_{8,9,10} )
+PYTHON_COMPAT=( python3_{8,9,10,11} )
 
-inherit flag-o-matic git-r3 linux-info multilib pam prefix python-single-r1 \
-		systemd tmpfiles
+inherit flag-o-matic linux-info pam python-single-r1 systemd tmpfiles
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-macos ~x86-solaris"
 
-SLOT="9999"
+SLOT=$(ver_cut 1)
 
-EGIT_REPO_URI="https://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
 HOMEPAGE="https://www.postgresql.org/"
 
-IUSE="debug icu kerberos ldap llvm +lz4
-	nls pam perl python +readline selinux server systemd
-	ssl static-libs tcl threads uuid xml zlib zstd"
+IUSE="debug doc icu kerberos ldap nls pam perl
+	  python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
 
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
@@ -29,26 +31,20 @@ CDEPEND="
 acct-group/postgres
 acct-user/postgres
 sys-apps/less
+virtual/libcrypt:=
 virtual/libintl
 icu? ( dev-libs/icu:= )
 kerberos? ( virtual/krb5 )
 ldap? ( net-nds/openldap:= )
-llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
-)
-lz4? ( app-arch/lz4 )
 pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
 ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-systemd? ( sys-apps/systemd )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
-zstd? ( app-arch/zstd )
 "
 
 # uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
@@ -73,44 +69,25 @@ uuid? (
 )"
 
 DEPEND="${CDEPEND}
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.5
-app-text/docbook-xml-dtd:4.5
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
+
 RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	if ! use server; then
-		elog "You are using a live ebuild that uses the current source code as it is"
-		elog "available from PostgreSQL's Git repository at emerge time. Given such,"
-		elog "the GNU Makefiles may be altered by upstream without notice and the"
-		elog "documentation for this live version is not readily available"
-		elog "online. Ergo, the ebuild maintainers will not support building a"
-		elog "client-only and/or document-free version."
-		ewarn "Building server anyway."
-	fi
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup
 }
 
 src_prepare() {
-	# still needed as of 2021-08-13
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
+	# Work around PPC{,64} compilation bug where bool is already defined
+	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
 
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
@@ -121,12 +98,18 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
+
 	if use pam ; then
 		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
 			die 'PGSQL_PAM_SERVICE rename failed.'
 	fi
 
+	# https://bugs.gentoo.org/753257
+	# https://bugs.gentoo.org/766225
+	eapply "${FILESDIR}"/postgresql-10.0-icu68.patch
+
 	eapply_user
 }
 
@@ -150,88 +133,63 @@ src_configure() {
 		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
 	fi
 
-	local myconf="\
+	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
 		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
 		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
 		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
 		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
 		$(use_enable debug) \
-		$(use_enable nls) \
 		$(use_enable threads thread-safety) \
 		$(use_with icu) \
 		$(use_with kerberos gssapi) \
 		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with lz4) \
 		$(use_with pam) \
 		$(use_with perl) \
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
-		$(use_with zstd ) \
-		$(use_with systemd) \
-		${uuid_config}"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
+		$(use_enable nls)
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
-	dodoc README HISTORY doc/TODO
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
+	dodoc README HISTORY doc/{TODO,bug.template}
 
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-	if use systemd; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service-9.6-r1" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-		newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
 	fi
-
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
 
 	# Create slot specific man pages
 	local bn f mansec slotted_name
@@ -257,74 +215,92 @@ src_install() {
 		popd > /dev/null
 	done
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 1775 /run/postgresql
-	fi
-}
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
 
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
 
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
 	done
 
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
 }
 
 pkg_postinst() {
-	use systemd && tmpfiles_process ${PN}-${SLOT}.conf
+	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -339,6 +315,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
@@ -459,18 +437,17 @@ pkg_config() {
 }
 
 src_test() {
-	if [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
-		export LC_CTYPE=${old_ctype}
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
-		ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
 		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-11.17.ebuild
similarity index 64%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-11.17.ebuild
index cce0a2f8499a..f806fd11b70d 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-11.17.ebuild
@@ -1,26 +1,29 @@
 # Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
-PYTHON_COMPAT=( python3_{8,9,10} )
+PYTHON_COMPAT=( python3_{8,9,10,11} )
+LLVM_MAX_SLOT=13
 
-inherit flag-o-matic git-r3 linux-info multilib pam prefix python-single-r1 \
-		systemd tmpfiles
+inherit flag-o-matic linux-info llvm pam python-single-r1 systemd tmpfiles
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
 
-SLOT="9999"
+SLOT=$(ver_cut 1)
 
-EGIT_REPO_URI="https://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
 HOMEPAGE="https://www.postgresql.org/"
 
-IUSE="debug icu kerberos ldap llvm +lz4
-	nls pam perl python +readline selinux server systemd
-	ssl static-libs tcl threads uuid xml zlib zstd"
+IUSE="debug doc icu kerberos ldap llvm nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
 
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
@@ -34,21 +37,18 @@ icu? ( dev-libs/icu:= )
 kerberos? ( virtual/krb5 )
 ldap? ( net-nds/openldap:= )
 llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
+	<sys-devel/llvm-14:=
+	<sys-devel/clang-14:=
 )
-lz4? ( app-arch/lz4 )
 pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
 ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-systemd? ( sys-apps/systemd )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
-zstd? ( app-arch/zstd )
 "
 
 # uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
@@ -73,45 +73,25 @@ uuid? (
 )"
 
 DEPEND="${CDEPEND}
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.5
-app-text/docbook-xml-dtd:4.5
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
+
 RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	if ! use server; then
-		elog "You are using a live ebuild that uses the current source code as it is"
-		elog "available from PostgreSQL's Git repository at emerge time. Given such,"
-		elog "the GNU Makefiles may be altered by upstream without notice and the"
-		elog "documentation for this live version is not readily available"
-		elog "online. Ergo, the ebuild maintainers will not support building a"
-		elog "client-only and/or document-free version."
-		ewarn "Building server anyway."
-	fi
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use llvm && llvm_pkg_setup
+
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup
 }
 
 src_prepare() {
-	# still needed as of 2021-08-13
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
-
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
@@ -121,8 +101,10 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
+
 	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
 			die 'PGSQL_PAM_SERVICE rename failed.'
 	fi
@@ -150,88 +132,64 @@ src_configure() {
 		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
 	fi
 
-	local myconf="\
+	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
 		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
 		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
 		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
 		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
 		$(use_enable debug) \
-		$(use_enable nls) \
 		$(use_enable threads thread-safety) \
 		$(use_with icu) \
 		$(use_with kerberos gssapi) \
 		$(use_with ldap) \
 		$(use_with llvm) \
-		$(use_with lz4) \
 		$(use_with pam) \
 		$(use_with perl) \
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
-		$(use_with zstd ) \
-		$(use_with systemd) \
-		${uuid_config}"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
+		$(use_enable nls)
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
-
-	dodoc README HISTORY doc/TODO
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+	dodoc README HISTORY doc/{TODO,bug.template}
 
-	if use systemd; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service-9.6-r1" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-		newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
 	fi
-
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
 
 	# Create slot specific man pages
 	local bn f mansec slotted_name
@@ -257,74 +215,92 @@ src_install() {
 		popd > /dev/null
 	done
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 1775 /run/postgresql
-	fi
-}
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
 
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
 
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
 	done
 
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
 }
 
 pkg_postinst() {
-	use systemd && tmpfiles_process ${PN}-${SLOT}.conf
+	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -339,6 +315,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
@@ -400,9 +378,9 @@ pkg_config() {
 
 	einfo "Creating the data directory ..."
 	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
 	fi
 
 	einfo "Initializing the database ..."
@@ -459,18 +437,17 @@ pkg_config() {
 }
 
 src_test() {
-	if [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
-		export LC_CTYPE=${old_ctype}
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
-		ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
 		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-12.12.ebuild
similarity index 64%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-12.12.ebuild
index cce0a2f8499a..389cb9f39c9d 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-12.12.ebuild
@@ -1,26 +1,29 @@
 # Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
-PYTHON_COMPAT=( python3_{8,9,10} )
+PYTHON_COMPAT=( python3_{8,9,10,11} )
+LLVM_MAX_SLOT=14
 
-inherit flag-o-matic git-r3 linux-info multilib pam prefix python-single-r1 \
-		systemd tmpfiles
+inherit flag-o-matic linux-info llvm pam python-single-r1 systemd tmpfiles
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
 
-SLOT="9999"
+SLOT=$(ver_cut 1)
 
-EGIT_REPO_URI="https://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
 HOMEPAGE="https://www.postgresql.org/"
 
-IUSE="debug icu kerberos ldap llvm +lz4
-	nls pam perl python +readline selinux server systemd
-	ssl static-libs tcl threads uuid xml zlib zstd"
+IUSE="debug doc icu kerberos ldap llvm nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
 
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
@@ -34,21 +37,18 @@ icu? ( dev-libs/icu:= )
 kerberos? ( virtual/krb5 )
 ldap? ( net-nds/openldap:= )
 llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
+	<sys-devel/llvm-15:=
+	<sys-devel/clang-15:=
 )
-lz4? ( app-arch/lz4 )
 pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
 ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-systemd? ( sys-apps/systemd )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
-zstd? ( app-arch/zstd )
 "
 
 # uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
@@ -73,45 +73,25 @@ uuid? (
 )"
 
 DEPEND="${CDEPEND}
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.5
-app-text/docbook-xml-dtd:4.5
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
+
 RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	if ! use server; then
-		elog "You are using a live ebuild that uses the current source code as it is"
-		elog "available from PostgreSQL's Git repository at emerge time. Given such,"
-		elog "the GNU Makefiles may be altered by upstream without notice and the"
-		elog "documentation for this live version is not readily available"
-		elog "online. Ergo, the ebuild maintainers will not support building a"
-		elog "client-only and/or document-free version."
-		ewarn "Building server anyway."
-	fi
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use llvm && llvm_pkg_setup
+
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup
 }
 
 src_prepare() {
-	# still needed as of 2021-08-13
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
-
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
@@ -121,8 +101,10 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch"
+
 	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
 			die 'PGSQL_PAM_SERVICE rename failed.'
 	fi
@@ -150,88 +132,64 @@ src_configure() {
 		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
 	fi
 
-	local myconf="\
+	econf \
 		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
 		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
 		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
 		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
 		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
 		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
+		$(use_enable !alpha spinlocks) \
 		$(use_enable debug) \
-		$(use_enable nls) \
 		$(use_enable threads thread-safety) \
 		$(use_with icu) \
 		$(use_with kerberos gssapi) \
 		$(use_with ldap) \
 		$(use_with llvm) \
-		$(use_with lz4) \
 		$(use_with pam) \
 		$(use_with perl) \
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
-		$(use_with zstd ) \
-		$(use_with systemd) \
-		${uuid_config}"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
+		$(use_enable nls)
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
-
-	dodoc README HISTORY doc/TODO
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+	dodoc README HISTORY
 
-	if use systemd; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service-9.6-r1" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-		newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
 	fi
-
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
 
 	# Create slot specific man pages
 	local bn f mansec slotted_name
@@ -257,74 +215,92 @@ src_install() {
 		popd > /dev/null
 	done
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 1775 /run/postgresql
-	fi
-}
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
 
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
 
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
 	done
 
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
 }
 
 pkg_postinst() {
-	use systemd && tmpfiles_process ${PN}-${SLOT}.conf
+	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -339,6 +315,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
@@ -400,9 +378,9 @@ pkg_config() {
 
 	einfo "Creating the data directory ..."
 	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
 	fi
 
 	einfo "Initializing the database ..."
@@ -459,18 +437,17 @@ pkg_config() {
 }
 
 src_test() {
-	if [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		emake check
-		export LC_CTYPE=${old_ctype}
 
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
-		ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
 		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-13.8.ebuild
similarity index 68%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-13.8.ebuild
index cce0a2f8499a..875acbe52592 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-13.8.ebuild
@@ -1,26 +1,29 @@
 # Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
-PYTHON_COMPAT=( python3_{8,9,10} )
+PYTHON_COMPAT=( python3_{8,9,10,11} )
+LLVM_MAX_SLOT=14
 
-inherit flag-o-matic git-r3 linux-info multilib pam prefix python-single-r1 \
-		systemd tmpfiles
+inherit flag-o-matic linux-info llvm pam python-single-r1 systemd tmpfiles
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
 
-SLOT="9999"
+SLOT=$(ver_cut 1)
 
-EGIT_REPO_URI="https://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
 HOMEPAGE="https://www.postgresql.org/"
 
-IUSE="debug icu kerberos ldap llvm +lz4
-	nls pam perl python +readline selinux server systemd
-	ssl static-libs tcl threads uuid xml zlib zstd"
+IUSE="debug doc icu kerberos ldap llvm nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
 
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
@@ -34,21 +37,18 @@ icu? ( dev-libs/icu:= )
 kerberos? ( virtual/krb5 )
 ldap? ( net-nds/openldap:= )
 llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
+	<sys-devel/llvm-15:=
+	<sys-devel/clang-15:=
 )
-lz4? ( app-arch/lz4 )
 pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
 ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-systemd? ( sys-apps/systemd )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
-zstd? ( app-arch/zstd )
 "
 
 # uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
@@ -73,43 +73,25 @@ uuid? (
 )"
 
 DEPEND="${CDEPEND}
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.5
-app-text/docbook-xml-dtd:4.5
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
+
 RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	if ! use server; then
-		elog "You are using a live ebuild that uses the current source code as it is"
-		elog "available from PostgreSQL's Git repository at emerge time. Given such,"
-		elog "the GNU Makefiles may be altered by upstream without notice and the"
-		elog "documentation for this live version is not readily available"
-		elog "online. Ergo, the ebuild maintainers will not support building a"
-		elog "client-only and/or document-free version."
-		ewarn "Building server anyway."
-	fi
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use llvm && llvm_pkg_setup
+
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup
 }
 
 src_prepare() {
-	# still needed as of 2021-08-13
 	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
 
 	# Set proper run directory
@@ -121,8 +103,10 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || eapply "${FILESDIR}/${PN}-13.8-no-server.patch"
+
 	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
 			die 'PGSQL_PAM_SERVICE rename failed.'
 	fi
@@ -158,25 +142,23 @@ src_configure() {
 		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
 		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
 		$(use_enable debug) \
-		$(use_enable nls) \
 		$(use_enable threads thread-safety) \
 		$(use_with icu) \
 		$(use_with kerberos gssapi) \
 		$(use_with ldap) \
 		$(use_with llvm) \
-		$(use_with lz4) \
 		$(use_with pam) \
 		$(use_with perl) \
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
-		$(use_with zstd ) \
-		$(use_with systemd) \
-		${uuid_config}"
+		$(use_enable nls)"
 	if use alpha; then
 		myconf+=" --disable-spinlocks"
 	else
@@ -187,51 +169,35 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
-	dodoc README HISTORY doc/TODO
+	dodoc README HISTORY
 
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-	if use systemd; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service-9.6-r1" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-		newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
 	fi
-
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
 
 	# Create slot specific man pages
 	local bn f mansec slotted_name
@@ -257,74 +223,92 @@ src_install() {
 		popd > /dev/null
 	done
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 1775 /run/postgresql
-	fi
-}
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
 
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
 
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
 	done
 
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
 }
 
 pkg_postinst() {
-	use systemd && tmpfiles_process ${PN}-${SLOT}.conf
+	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -339,6 +323,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
@@ -400,9 +386,9 @@ pkg_config() {
 
 	einfo "Creating the data directory ..."
 	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
 	fi
 
 	einfo "Initializing the database ..."
@@ -459,18 +445,21 @@ pkg_config() {
 }
 
 src_test() {
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
 		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
 		local old_ctype=${LC_CTYPE}
 		export LC_CTYPE=${LC_COLLATE}
 		emake check
 		export LC_CTYPE=${old_ctype}
-
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
-		ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
 		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-14.5.ebuild
similarity index 68%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-14.5.ebuild
index cce0a2f8499a..6c2b0fe290d3 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-14.5.ebuild
@@ -1,26 +1,28 @@
 # Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
-PYTHON_COMPAT=( python3_{8,9,10} )
+PYTHON_COMPAT=( python3_{8,9,10,11} )
 
-inherit flag-o-matic git-r3 linux-info multilib pam prefix python-single-r1 \
-		systemd tmpfiles
+inherit flag-o-matic linux-info pam python-single-r1 systemd tmpfiles
 
-KEYWORDS=""
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
 
-SLOT="9999"
+SLOT=$(ver_cut 1)
 
-EGIT_REPO_URI="https://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
 HOMEPAGE="https://www.postgresql.org/"
 
-IUSE="debug icu kerberos ldap llvm +lz4
-	nls pam perl python +readline selinux server systemd
-	ssl static-libs tcl threads uuid xml zlib zstd"
+IUSE="debug doc icu kerberos ldap llvm lz4 nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib"
 
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
@@ -42,13 +44,11 @@ pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
 ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-systemd? ( sys-apps/systemd )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
-zstd? ( app-arch/zstd )
 "
 
 # uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
@@ -73,45 +73,23 @@ uuid? (
 )"
 
 DEPEND="${CDEPEND}
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.5
-app-text/docbook-xml-dtd:4.5
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
+
 RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	if ! use server; then
-		elog "You are using a live ebuild that uses the current source code as it is"
-		elog "available from PostgreSQL's Git repository at emerge time. Given such,"
-		elog "the GNU Makefiles may be altered by upstream without notice and the"
-		elog "documentation for this live version is not readily available"
-		elog "online. Ergo, the ebuild maintainers will not support building a"
-		elog "client-only and/or document-free version."
-		ewarn "Building server anyway."
-	fi
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup
 }
 
 src_prepare() {
-	# still needed as of 2021-08-13
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
-
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
@@ -121,8 +99,10 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || eapply "${FILESDIR}/${PN}-14.5-no-server.patch"
+
 	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
 			die 'PGSQL_PAM_SERVICE rename failed.'
 	fi
@@ -158,7 +138,6 @@ src_configure() {
 		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
 		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
 		$(use_enable debug) \
-		$(use_enable nls) \
 		$(use_enable threads thread-safety) \
 		$(use_with icu) \
 		$(use_with kerberos gssapi) \
@@ -170,13 +149,13 @@ src_configure() {
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
-		$(use_with zstd ) \
-		$(use_with systemd) \
-		${uuid_config}"
+		$(use_enable nls)"
 	if use alpha; then
 		myconf+=" --disable-spinlocks"
 	else
@@ -187,51 +166,35 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
-	dodoc README HISTORY doc/TODO
+	dodoc README HISTORY
 
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-	if use systemd; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service-9.6-r1" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-		newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
 	fi
-
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
 
 	# Create slot specific man pages
 	local bn f mansec slotted_name
@@ -257,74 +220,92 @@ src_install() {
 		popd > /dev/null
 	done
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 1775 /run/postgresql
-	fi
-}
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
 
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
 
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
 	done
 
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
 }
 
 pkg_postinst() {
-	use systemd && tmpfiles_process ${PN}-${SLOT}.conf
+	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -339,6 +320,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
@@ -400,9 +383,9 @@ pkg_config() {
 
 	einfo "Creating the data directory ..."
 	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
 	fi
 
 	einfo "Initializing the database ..."
@@ -459,18 +442,21 @@ pkg_config() {
 }
 
 src_test() {
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
 		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
 		local old_ctype=${LC_CTYPE}
 		export LC_CTYPE=${LC_COLLATE}
 		emake check
 		export LC_CTYPE=${old_ctype}
-
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
-		ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
 		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-15_beta3.ebuild
similarity index 68%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-15_beta3.ebuild
index cce0a2f8499a..a805f1d90ea9 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-15_beta3.ebuild
@@ -1,26 +1,28 @@
 # Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
-PYTHON_COMPAT=( python3_{8,9,10} )
+PYTHON_COMPAT=( python3_{8,9,10,11} )
 
-inherit flag-o-matic git-r3 linux-info multilib pam prefix python-single-r1 \
-		systemd tmpfiles
+inherit flag-o-matic linux-info pam python-single-r1 systemd tmpfiles
 
 KEYWORDS=""
 
-SLOT="9999"
+SLOT=$(ver_cut 1)
 
-EGIT_REPO_URI="https://git.postgresql.org/git/postgresql.git"
+MY_PV=${PV/_/}
+S="${WORKDIR}/${PN}-${MY_PV}"
+
+SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
 
 LICENSE="POSTGRESQL GPL-2"
 DESCRIPTION="PostgreSQL RDBMS"
 HOMEPAGE="https://www.postgresql.org/"
 
-IUSE="debug icu kerberos ldap llvm +lz4
-	nls pam perl python +readline selinux server systemd
-	ssl static-libs tcl threads uuid xml zlib zstd"
+IUSE="debug doc icu kerberos ldap llvm lz4 nls pam
+	  perl python +readline selinux +server systemd ssl static-libs tcl
+	  threads uuid xml zlib zstd"
 
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
@@ -42,10 +44,9 @@ pam? ( sys-libs/pam )
 perl? ( >=dev-lang/perl-5.8:= )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
+server? ( systemd? ( sys-apps/systemd ) )
 ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-systemd? ( sys-apps/systemd )
 tcl? ( >=dev-lang/tcl-8:0= )
-uuid? ( dev-libs/ossp-uuid )
 xml? ( dev-libs/libxml2 dev-libs/libxslt )
 zlib? ( sys-libs/zlib )
 zstd? ( app-arch/zstd )
@@ -73,45 +74,23 @@ uuid? (
 )"
 
 DEPEND="${CDEPEND}
->=dev-lang/perl-5.8
-app-text/docbook-dsssl-stylesheets
-app-text/docbook-sgml-dtd:4.5
-app-text/docbook-xml-dtd:4.5
-app-text/docbook-xsl-stylesheets
-app-text/openjade
-dev-libs/libxml2
-dev-libs/libxslt
 sys-devel/bison
 sys-devel/flex
 nls? ( sys-devel/gettext )
 xml? ( virtual/pkgconfig )
 "
+
 RDEPEND="${CDEPEND}
 selinux? ( sec-policy/selinux-postgresql )
 "
 
-pkg_pretend() {
-	if ! use server; then
-		elog "You are using a live ebuild that uses the current source code as it is"
-		elog "available from PostgreSQL's Git repository at emerge time. Given such,"
-		elog "the GNU Makefiles may be altered by upstream without notice and the"
-		elog "documentation for this live version is not readily available"
-		elog "online. Ergo, the ebuild maintainers will not support building a"
-		elog "client-only and/or document-free version."
-		ewarn "Building server anyway."
-	fi
-}
-
 pkg_setup() {
-	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
+	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
 
 	use python && python-single-r1_pkg_setup
 }
 
 src_prepare() {
-	# still needed as of 2021-08-13
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
-
 	# Set proper run directory
 	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
 		-i src/include/pg_config_manual.h || die
@@ -121,8 +100,10 @@ src_prepare() {
 	# hardened and non-hardened environments. (Bug #528786)
 	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
 
+	use server || eapply "${FILESDIR}/${PN}-15_beta3-no-server.patch"
+
 	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
+		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
 			-i src/backend/libpq/auth.c || \
 			die 'PGSQL_PAM_SERVICE rename failed.'
 	fi
@@ -158,7 +139,6 @@ src_configure() {
 		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
 		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
 		$(use_enable debug) \
-		$(use_enable nls) \
 		$(use_enable threads thread-safety) \
 		$(use_with icu) \
 		$(use_with kerberos gssapi) \
@@ -170,13 +150,14 @@ src_configure() {
 		$(use_with python) \
 		$(use_with readline) \
 		$(use_with ssl openssl) \
+		$(usex server "$(use_with systemd)" '--without-systemd') \
 		$(use_with tcl) \
+		${uuid_config} \
 		$(use_with xml libxml) \
 		$(use_with xml libxslt) \
 		$(use_with zlib) \
-		$(use_with zstd ) \
-		$(use_with systemd) \
-		${uuid_config}"
+		$(use_with zstd) \
+		$(use_enable nls)"
 	if use alpha; then
 		myconf+=" --disable-spinlocks"
 	else
@@ -187,51 +168,35 @@ src_configure() {
 }
 
 src_compile() {
-	emake world
+	emake
+	emake -C contrib
 }
 
 src_install() {
-	emake DESTDIR="${D}" install-world
+	emake DESTDIR="${D}" install
+	emake DESTDIR="${D}" install -C contrib
 
-	dodoc README HISTORY doc/TODO
+	dodoc README HISTORY
 
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-	if use systemd; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.service-9.6-r1" | \
-			systemd_newunit - ${PN}-${SLOT}.service
-		newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+	# man pages are already built, but if we have the target make them,
+	# they'll be generated from source before being installed so we
+	# manually install man pages.
+	# We use ${SLOT} instead of doman for postgresql.eselect
+	insinto /usr/share/postgresql-${SLOT}/man/
+	doins -r doc/src/sgml/man{1,3,7}
+	if ! use server; then
+		# Remove man pages for non-existent binaries
+		serverman=(
+			initdb
+			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
+			pg_{test_{fsync,timing},upgrade,waldump}
+			post{gres,master}
+		)
+		for m in ${serverman[@]} ; do
+			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
+		done
 	fi
-
-	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-
-	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		# Temporarily tack on tmp to workaround a file collision
-		# issue. This is only necessary for 9.7 and earlier. 10 never
-		# had this issue.
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}tmp"
-	done
+	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
 
 	# Create slot specific man pages
 	local bn f mansec slotted_name
@@ -257,74 +222,92 @@ src_install() {
 		popd > /dev/null
 	done
 
-	if use prefix ; then
-		keepdir /run/postgresql
-		fperms 1775 /run/postgresql
-	fi
-}
+	insinto /etc/postgresql-${SLOT}
+	newins src/bin/psql/psqlrc.sample psqlrc
 
-pkg_preinst() {
-	# Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
-	# /usr/bin/psql97). They may have been created by the
-	# postgresql.eselect module, but they're handled within this ebuild
-	# now. It's alright if we momentarily delete /usr/bin/psql as it
-	# will be recreated by the eselect module in pkg_ppostinst().  We
-	# only worry about the 9.7 slot as that's the last slot that had its
-	# slot-specific links generated by eselect.
-	#
-	# This can be removed when 10 is the lowest slot in the tree.
-	local canonicalise
-	if type -p realpath > /dev/null; then
-		canonicalise=realpath
-	elif type -p readlink > /dev/null; then
-		canonicalise='readlink -f'
-	else
-		# can't die, subshell
-		die "No readlink nor realpath found, cannot canonicalise"
-	fi
+	# Don't delete libpg{port,common}.a (Bug #571046). They're always
+	# needed by extensions utilizing PGXS.
+	use static-libs || \
+		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
+			 -delete
 
-	local l
-	# First remove any symlinks in /usr/bin that may have been created
-	# by the old eselect
-	for l in $(find "${ROOT}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
-		[[ $(${canonicalise} "${l}") == *postgresql-9.7* ]] && rm "${l}"
+	# Make slot specific links to programs
+	local f bn
+	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
+					-mindepth 1 -maxdepth 1)
+	do
+		bn=$(basename "${f}")
+		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
+			  "/usr/bin/${bn}${SLOT/.}"
 	done
 
-	# Then move the symlinks created by the ebuild to their proper place.
-	for l in "${ED}"/usr/bin/*tmp ; do
-		mv "${l}" "${l%tmp}" \
-			|| ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
-	done
+	if use doc ; then
+		docinto html
+		dodoc doc/src/sgml/html/*
+	fi
+
+	if use server; then
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
+
+		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
+
+		if use systemd; then
+			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+				"${FILESDIR}/${PN}.service-9.6-r1" | \
+				systemd_newunit - ${PN}-${SLOT}.service
+			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
+			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
+		fi
+
+		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+
+		if use prefix ; then
+			keepdir /run/postgresql
+			fperms 1775 /run/postgresql
+		fi
+	fi
 }
 
 pkg_postinst() {
-	use systemd && tmpfiles_process ${PN}-${SLOT}.conf
+	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
 	postgresql-config update
 
 	elog "If you need a global psqlrc-file, you can place it in:"
 	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
 
-	elog
-	elog "Gentoo specific documentation:"
-	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-	elog
-	elog "Official documentation:"
-	elog "${EROOT}/usr/share/doc/${PF}/html"
-	elog
-	elog "The default location of the Unix-domain socket is:"
-	elog "    ${EROOT}/run/postgresql/"
-	elog
-	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-	elog "so that it contains your preferred locale, and other options, in:"
-	elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	elog
-	elog "Then, execute the following command to setup the initial database"
-	elog "environment:"
-	elog "    emerge --config =${CATEGORY}/${PF}"
+	if use server ; then
+		elog
+		elog "Gentoo specific documentation:"
+		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
+		elog
+		elog "Official documentation:"
+		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
+		elog
+		elog "The default location of the Unix-domain socket is:"
+		elog "    ${EROOT}/run/postgresql/"
+		elog
+		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
+		elog "so that it contains your preferred locale in:"
+		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
+		elog
+		elog "Then, execute the following command to setup the initial database"
+		elog "environment:"
+		elog "    emerge --config =${CATEGORY}/${PF}"
+
+		if [[ -n ${REPLACING_VERSIONS} ]] ; then
+			ewarn "If your system is using 'pg_stat_statements' and you are running a"
+			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
+			ewarn "the following command after upgrading:"
+			ewarn
+			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
+		fi
+	fi
 }
 
 pkg_prerm() {
-	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
+	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
 		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
 		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
 
@@ -339,6 +322,8 @@ pkg_postrm() {
 }
 
 pkg_config() {
+	use server || die "USE flag 'server' not enabled. Nothing to configure."
+
 	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
 		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
 	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
@@ -400,9 +385,9 @@ pkg_config() {
 
 	einfo "Creating the data directory ..."
 	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
+		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
+		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
+		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
 	fi
 
 	einfo "Initializing the database ..."
@@ -459,18 +444,21 @@ pkg_config() {
 }
 
 src_test() {
-	if [[ ${UID} -ne 0 ]] ; then
+	if use server && [[ ${UID} -ne 0 ]] ; then
 		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
 		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
 		local old_ctype=${LC_CTYPE}
 		export LC_CTYPE=${LC_COLLATE}
 		emake check
 		export LC_CTYPE=${old_ctype}
-
 		einfo "If you think other tests besides the regression tests are necessary, please"
 		einfo "submit a bug including a patch for this ebuild to enable them."
 	else
-		ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+		use server || \
+			ewarn 'Tests cannot be run without the "server" use flag enabled.'
+		[[ ${UID} -eq 0 ]] || \
+			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
+
 		ewarn 'Skipping.'
 	fi
 }

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild
index cce0a2f8499a..92b4cf038a8d 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -1,12 +1,11 @@
 # Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
-PYTHON_COMPAT=( python3_{8,9,10} )
+PYTHON_COMPAT=( python3_{8,9,10,11} )
 
-inherit flag-o-matic git-r3 linux-info multilib pam prefix python-single-r1 \
-		systemd tmpfiles
+inherit flag-o-matic git-r3 linux-info pam python-single-r1 systemd tmpfiles
 
 KEYWORDS=""
 


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/
@ 2022-08-18 11:26 Aaron W. Swenson
  0 siblings, 0 replies; 14+ messages in thread
From: Aaron W. Swenson @ 2022-08-18 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     92634e10850338c32fa7b3f7751fd83c3a22bee8
Author:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 18 11:22:38 2022 +0000
Commit:     Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
CommitDate: Thu Aug 18 11:22:38 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=92634e10

dev-db/postgresql: Cleanup insecure

Bug: https://bugs.gentoo.org/865255

Signed-off-by: Aaron W. Swenson <titanofold <AT> gentoo.org>

 dev-db/postgresql/Manifest                         |  16 -
 dev-db/postgresql/files/postgres-llvm14.patch      | 154 -------
 .../files/postgresql-13_beta1-no-server.patch      | 149 -------
 .../files/postgresql-14_rc1-no-server.patch        | 151 -------
 .../files/postgresql-9.6.3-no-server.patch         | 141 -------
 dev-db/postgresql/postgresql-10.19-r1.ebuild       | 453 --------------------
 dev-db/postgresql/postgresql-10.20-r1.ebuild       | 453 --------------------
 dev-db/postgresql/postgresql-10.21.ebuild          | 453 --------------------
 dev-db/postgresql/postgresql-11.14-r1.ebuild       | 453 --------------------
 dev-db/postgresql/postgresql-11.15-r1.ebuild       | 453 --------------------
 dev-db/postgresql/postgresql-11.16.ebuild          | 453 --------------------
 dev-db/postgresql/postgresql-12.10-r1.ebuild       | 454 --------------------
 dev-db/postgresql/postgresql-12.11.ebuild          | 453 --------------------
 dev-db/postgresql/postgresql-12.9-r1.ebuild        | 454 --------------------
 dev-db/postgresql/postgresql-13.5-r1.ebuild        | 466 ---------------------
 dev-db/postgresql/postgresql-13.6-r2.ebuild        | 466 ---------------------
 dev-db/postgresql/postgresql-13.7.ebuild           | 465 --------------------
 dev-db/postgresql/postgresql-14.1-r1.ebuild        | 466 ---------------------
 dev-db/postgresql/postgresql-14.2-r1.ebuild        | 463 --------------------
 dev-db/postgresql/postgresql-14.4.ebuild           | 462 --------------------
 dev-db/postgresql/postgresql-15_beta2.ebuild       | 464 --------------------
 21 files changed, 7942 deletions(-)

diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
index 9728a27e7cda..856686626085 100644
--- a/dev-db/postgresql/Manifest
+++ b/dev-db/postgresql/Manifest
@@ -1,22 +1,6 @@
-DIST postgresql-10.19.tar.bz2 19261478 BLAKE2B 3ccd44d68980ddb0e394b811af20c213cf89eb8d4374d2c49c9cda5165f222ca849a2db4fe4d521991f15f9cc84ec35bafa91083b9625f2a6729159f490a94c9 SHA512 41b0f5026be7d563e41b54e9ea7199dd466a132d355be0b71a91d41f533d97fbf550eccf2a2ece3d60c5dab5921ebeea3ac4780c18c54b924df52d7423305a22
-DIST postgresql-10.20.tar.bz2 19371473 BLAKE2B 24ce3e3dda749375e999206307154e79bf15d20b3cd598ba0b78bf27976241d71e88e6fa4cd459b675bc9a9047e9315321b1535dbb41ed9e558858c2a7e9dd31 SHA512 44cfca541947d58c70593b767d3c2423f20cc6904f3d4cea8f63c1802ccbc569130c4a2a15f1af152285926f6a200e13d59c21584295dafd6f6e74bd38251428
-DIST postgresql-10.21.tar.bz2 19409454 BLAKE2B 5e43abaee8156b9eb99360efeb25ba268f93a60ac2c29044d9025c4faa8753d84cb3c0c8cbcd65eb9e0eb094ebf63e0cc1cbd0ef12c0a2faa360754e63ae106a SHA512 1053e15505c0448df491119c9aad1617889b66118628a2155e3ec87e6648b2071a0a54e10d8fbbe00161b2aa86d1a6194d932a8cf5808c626e7972d135bb05c5
 DIST postgresql-10.22.tar.bz2 19455874 BLAKE2B 10a8a894ba6e649abcc68abfd829bd30bca04b6e90f987ae5771fe02474517254ea2b48c7c9f2a899309de7b84aeaf13bac025965a9cc44814727ba257a633d7 SHA512 2e1ea75be7696ffbbb947351a8e8e55aaf067f86ad318308499a6a58797f0bf86227ed33e257e261c5c71ebba2f73ba514ef195a2394b91414ce6a0c3ab62532
-DIST postgresql-11.14.tar.bz2 20172910 BLAKE2B a033752fc5fc593c96fe63a258b2cc0d4b896548a366e3fefa8afde1f96ab64aab97eb395b10ae10494709963ed924623279f76f66870c4faee435969400c1b7 SHA512 ab71461ee6fb4cdc5b4240f7ecd8af2497ce6780283fde2abf5951ffdb616bd0c8ed22b26fdfca402a346e663ff77c4d17f3284c9d700e6fd6795b2aec97c9be
-DIST postgresql-11.15.tar.bz2 20245750 BLAKE2B f6a632606fe4b34b2a44df2c165ccfa6e890b85f4f6048994f781428bbd1de6888a24493fb5d0c231f3f34e6a4e94cfd23078a9afdaf5925d284b4854847d23f SHA512 1eba7bddee1edf034617102c1d61ad0aa1b58927dad63de1d054817966c4c9a1d7d3fa6f6896af3fe5a6880b09a6ec86be298256ee6ecc3705ff2654d3d00c74
-DIST postgresql-11.16.tar.bz2 20347100 BLAKE2B 240e86b68ff8833265f10802da2fb847d72e38ac9325fc56bb6864266b2ad98939170038ccdb7044ae16f9fd29e7a9e1d404456d8bc7d53430067d714b9bb563 SHA512 e1b6be0a97e60cdd95cd0ebc756b1de6abf2f33f41f6a80da3dff25483a30146fb6bf750ab787bb5bb4f2a04718946c7429e71f891cbd491001e9f9c2ea8e63c
 DIST postgresql-11.17.tar.bz2 20385599 BLAKE2B d145bc0f5e0f277be91bf46868c78c9ce5bb2eebbbd84fbdcdbb1ec115911d124a0a054df783739fb912eeae1322fb7eb58b7b1b8d40a8f81cffe2f24d3dda01 SHA512 35304279c06577eca134581490710db976edeac8cca169d3436fcdce8eebb18159459ea3b5ef403f6a8efe85542726f9960c4ca653da4619e081ce5869866032
-DIST postgresql-12.10.tar.bz2 20990621 BLAKE2B a7a56cf75944c558ae9bb9165dfb17b30cc5f7a865961e0a588677e4dd3e53d1fab15a212a21ec12f8e7b669a448d78efa0dfe985fd4902e16485a298c7adc62 SHA512 befedb14320aa033dc55bbb93bbbec4e67d9cfced63be0e4f631c7495a0fbc6fe280bd6d2fb941d7a2e6b2ac570b7f40d8db7f07a192a81bd9cd63c6c244a9c5
-DIST postgresql-12.11.tar.bz2 21086745 BLAKE2B 7062d334f3ef3b98f69e709f5de744324c7ce53ea516384902632a454a2ccadfd7bcc0c9ef4d51a685dd7a06e1fdccc292109294517831181c3db30bc2b7be91 SHA512 705e9e1ccf8202062cce61069b5ddb7db5f804dd0736c620640ce5622b9e42fdcbc1417771e77d51aa54beb4562a09b4307f2ff7dec135bd0e31f4941ca36ac8
 DIST postgresql-12.12.tar.bz2 21089064 BLAKE2B 7285dcfc8ed6cf2dbbe29d894dbcef53fad18cbeddbfdb3a43893234a1ee75a9bf5d966968a0c481a8ab15bf8a37400bf6eb4b57a83359501b729e70398e3551 SHA512 eeff79279ac11db04fdddeb2c52ba1ec6b549223b862222540e1f659fbfc3617130699c22694b465bde46b1a4a665c01aef70b68b86d80e58a5657efd019407d
-DIST postgresql-12.9.tar.bz2 20904260 BLAKE2B fc88d61d369569a3054b889848eaf1405a4f5137cd8c2cf27282115f70853dd4d5d8b4bf0a9fc60c63db936246a0a64077c9bfdb90685d4dfe375558e4519b2b SHA512 11697d8283f5df5a9c74c2406e94d1b6da6df8358ad48f3b773825aab98e8395f9fd4e3fc8b1e6ebad3743c3dadbda8b795d4fe84a447d7913223e136cf2b88f
-DIST postgresql-13.5.tar.bz2 21186674 BLAKE2B 3e51d6d67bba09fb134cd71c48349674e0cacfaefee299620482c93f0b09edbfead578deb63083686ab691563b088fc0ea60a6281a0bcf9145689fb3ce1ec0f0 SHA512 c76effbca8ee63be48fa3aeb39c7038221848fe83ca2afc4e0904ba8c6a50b89aa2ad37080d4e3be75e9bdc2d6ca6dfefcda334ef55a5e1a8954bb955ce905e5
-DIST postgresql-13.6.tar.bz2 21257213 BLAKE2B f5ea95fd9ffc8846e0aaf5bac03b02afa71e62e796bbe40f68af727a2f3c74eddd98cb68427bcc13b87b6fa00a8e2a7b18dd7749318f0a4a32cfdbf9b0e0a873 SHA512 2852726a3031b8d469f1c38f3019af02fc5afe40ec27b22288a29acefd30c63a98806bce88a214d0c2f9177f547b0b5010ad64e70bcbe2c2f1d97a27ae1984f8
-DIST postgresql-13.7.tar.bz2 21364433 BLAKE2B 2d8a505f6de4eb31cae415529eeac750a60abafcf45e7fde29043597b385a8150fac55df659f8c2ad200822e8063d388ed606dff9108d4407f9e26b893fa62f4 SHA512 9254f21519c8d4e926f70082503bb5593c91064a3d2a4ea18ac503dfd9aa94751d6f01ce00fca9fec9b2b7af40caf8d0951b661dd8be4d6aa87c1e35b6fa7a41
 DIST postgresql-13.8.tar.bz2 21397381 BLAKE2B eb076382027a175789652a6ae8579d9b9c8856918741e8058456d22f1ef89525cff5fafe863bf615f658bc94b740b00d1268825969e37a7cefed6b5c90f402c5 SHA512 3b39448b291342a5e9b610d410c222aeb85f8acf95632e73e138ae316133af3dadc795a6e706f6447f543cf10df3c786da4f1afa1d91489b50eb77e2d9ed5d84
-DIST postgresql-14.1.tar.bz2 21887101 BLAKE2B a496dfd513c52339d1b3cb72773f9611721fd7c5d2a702d6fd71f650a1d41c3d7bf6574eba23671c7f9f11718e007f51f9547949bdc3d7fe1ea2248ebfb8d70b SHA512 4a0bec157d5464bb9e5f5c0eb0efdede55526e03f6f4d660b87d161a47705eb152fa0878960b1581bce42a5ed28a1f457825ea54e8d22e34b5b8eb36473ceefd
-DIST postgresql-14.2.tar.bz2 21964841 BLAKE2B 6460533a40064404f18642147b949cf7c85d036c45ede478fb9af8919895ee7b09dc78b89ed08a292226911f07cfc9e46d7f2d42e0aaea546c5e97a291d599b9 SHA512 19aeb6528605dbcf5df84048b2eed8f54b202576134d3fe3900bb8f073179c4258d2581acd745887e7e6fa86ebdb5f7b159ffaa0a645d601efee7c5f7730456b
-DIST postgresql-14.4.tar.bz2 22094218 BLAKE2B 05b65083d826ed2f451b31b29b4b247dfd76b3d24ef05f6be128ee9e58d521d506a3ec4ae4839cbb74d8e217dfae81a95bd97894a778ef3c47b907b85b1fb25e SHA512 dd2f80248684e331d2ffb1e26cd2a285df1fb18710807a0c31aedabf917912ce9267f8ca26318e5371d916c6fe476f8a17886d82d3ff86a974e6f24c19a6aafb
 DIST postgresql-14.5.tar.bz2 22132996 BLAKE2B 6d303850ef1e8f9f5d66a53275fc814475646c762b9747a4f0401a472ebaf59be06d6e7c08e9c1c5ad5d3b9dbc3bb3c06d58bae137806e1a437c86bcc8cae501 SHA512 3051c5ab729f6a55952c6108098b022517398b1de64f7fefbdd6c806c7e2eb0637d00f3c98a6203c5bee654656528c4ff3530db5a69470e7888864c77900178a
-DIST postgresql-15beta2.tar.bz2 23511057 BLAKE2B d1e6d8ce67998d4295587780c2cb75f33b930556e11fd95bbd4d828086f63faed6bbddbb809ebc1fddf0980c83c7cf51e3d37f110d7bb68959dab34f61b5b8c9 SHA512 139bf4f95e2bc8942666009c6680d2b61d8ea2898e9e7eb3a0afb118f0bf6acfac5f21676525cccd82e9ee5c43ad79e07e23a55333e1318426d8b9bc95a4f00d
 DIST postgresql-15beta3.tar.bz2 23585136 BLAKE2B cdea196fb62587800f7fceafcbbd781f5636323fc6b205a0e5e0081964f2d08fcb421d0d66f710150dba37f30c2b0e7f7b3119a9a83a0cc573104968b16fc043 SHA512 caf79b889ca1325bcbdce3bbbcb3a0707b8928c8bd7b97f594cfedaedc06826e829a561b2fde73210c1e2596a0201305fa350bb3f12c05783014fc0c8564298a

diff --git a/dev-db/postgresql/files/postgres-llvm14.patch b/dev-db/postgresql/files/postgres-llvm14.patch
deleted file mode 100644
index 2c7b91d75153..000000000000
--- a/dev-db/postgresql/files/postgres-llvm14.patch
+++ /dev/null
@@ -1,154 +0,0 @@
-From d9f7ad54e552262ee0090e88d5abd3e04fcdeac8 Mon Sep 17 00:00:00 2001
-From: Thomas Munro <tmunro@postgresql.org>
-Date: Wed, 16 Mar 2022 11:35:00 +1300
-Subject: [PATCH] Back-patch LLVM 14 API changes.
-
-Since LLVM 14 has stopped changing and is about to be released,
-back-patch the following changes from the master branch:
-
-  e6a7600202105919bffd62b3dfd941f4a94e082b
-  807fee1a39de6bb8184082012e643951abb9ad1d
-  a56e7b66010f330782243de9e25ac2a6596be0e1
-
-Back-patch to 11, where LLVM JIT support came in.
----
- src/backend/jit/llvm/Makefile           |  6 +++++
- src/backend/jit/llvm/llvmjit_error.cpp  | 35 +++++++++++++++++++++----
- src/backend/jit/llvm/llvmjit_inline.cpp | 12 ++++++++-
- 3 files changed, 47 insertions(+), 6 deletions(-)
-
-diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
-index 0268bd46d5..2da122a391 100644
---- a/src/backend/jit/llvm/Makefile
-+++ b/src/backend/jit/llvm/Makefile
-@@ -22,6 +22,12 @@ endif
- PGFILEDESC = "llvmjit - JIT using LLVM"
- NAME = llvmjit
- 
-+# LLVM 14 produces deprecation warnings.  We'll need to make some changes
-+# before the relevant functions are removed, but for now silence the warnings.
-+ifeq ($(GCC), yes)
-+LLVM_CFLAGS += -Wno-deprecated-declarations
-+endif
-+
- # All files in this directory use LLVM.
- CFLAGS += $(LLVM_CFLAGS)
- CXXFLAGS += $(LLVM_CXXFLAGS)
-diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp
-index f4720732a3..5ad92f3090 100644
---- a/src/backend/jit/llvm/llvmjit_error.cpp
-+++ b/src/backend/jit/llvm/llvmjit_error.cpp
-@@ -23,15 +23,22 @@ extern "C"
- 
- #include "jit/llvmjit.h"
- 
-+#include <new>
- 
- static int fatal_new_handler_depth = 0;
- static std::new_handler old_new_handler = NULL;
- 
- static void fatal_system_new_handler(void);
- #if LLVM_VERSION_MAJOR > 4
-+static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag);
-+#if LLVM_VERSION_MAJOR < 14
- static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
- #endif
-+#endif
-+static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag);
-+#if LLVM_VERSION_MAJOR < 14
- static void fatal_llvm_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
-+#endif
- 
- 
- /*
-@@ -129,23 +136,41 @@ fatal_system_new_handler(void)
- #if LLVM_VERSION_MAJOR > 4
- static void
- fatal_llvm_new_handler(void *user_data,
--					   const std::string& reason,
-+					   const char *reason,
- 					   bool gen_crash_diag)
- {
- 	ereport(FATAL,
- 			(errcode(ERRCODE_OUT_OF_MEMORY),
- 			 errmsg("out of memory"),
--			 errdetail("While in LLVM: %s", reason.c_str())));
-+			 errdetail("While in LLVM: %s", reason)));
-+}
-+#if LLVM_VERSION_MAJOR < 14
-+static void
-+fatal_llvm_new_handler(void *user_data,
-+					   const std::string& reason,
-+					   bool gen_crash_diag)
-+{
-+	fatal_llvm_new_handler(user_data, reason.c_str(), gen_crash_diag);
- }
- #endif
-+#endif
- 
- static void
- fatal_llvm_error_handler(void *user_data,
--						 const std::string& reason,
-+						 const char *reason,
- 						 bool gen_crash_diag)
- {
- 	ereport(FATAL,
- 			(errcode(ERRCODE_OUT_OF_MEMORY),
--			 errmsg("fatal llvm error: %s",
--					reason.c_str())));
-+			 errmsg("fatal llvm error: %s", reason)));
- }
-+
-+#if LLVM_VERSION_MAJOR < 14
-+static void
-+fatal_llvm_error_handler(void *user_data,
-+						 const std::string& reason,
-+						 bool gen_crash_diag)
-+{
-+	fatal_llvm_error_handler(user_data, reason.c_str(), gen_crash_diag);
-+}
-+#endif
-diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp
-index 6f03595db5..9bb4b672a7 100644
---- a/src/backend/jit/llvm/llvmjit_inline.cpp
-+++ b/src/backend/jit/llvm/llvmjit_inline.cpp
-@@ -594,7 +594,11 @@ function_inlinable(llvm::Function &F,
- 	if (F.materialize())
- 		elog(FATAL, "failed to materialize metadata");
- 
--	if (F.getAttributes().hasFnAttribute(llvm::Attribute::NoInline))
-+#if LLVM_VERSION_MAJOR < 14
-+#define hasFnAttr hasFnAttribute
-+#endif
-+
-+	if (F.getAttributes().hasFnAttr(llvm::Attribute::NoInline))
- 	{
- 		ilog(DEBUG1, "ineligibile to import %s due to noinline",
- 			 F.getName().data());
-@@ -871,7 +875,9 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
- 	llvm::Function *AF;
- 	llvm::BasicBlock *BB;
- 	llvm::CallInst *fwdcall;
-+#if LLVM_VERSION_MAJOR < 14
- 	llvm::Attribute inlineAttribute;
-+#endif
- 
- 	AF = llvm::Function::Create(F->getFunctionType(),
- 								LinkageTypes::AvailableExternallyLinkage,
-@@ -880,9 +886,13 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
- 
- 	Builder.SetInsertPoint(BB);
- 	fwdcall = Builder.CreateCall(F, &*AF->arg_begin());
-+#if LLVM_VERSION_MAJOR < 14
- 	inlineAttribute = llvm::Attribute::get(Context,
- 										   llvm::Attribute::AlwaysInline);
- 	fwdcall->addAttribute(~0U, inlineAttribute);
-+#else
-+	fwdcall->addFnAttr(llvm::Attribute::AlwaysInline);
-+#endif
- 	Builder.CreateRet(fwdcall);
- 
- 	return AF;
--- 
-2.30.2
-

diff --git a/dev-db/postgresql/files/postgresql-13_beta1-no-server.patch b/dev-db/postgresql/files/postgresql-13_beta1-no-server.patch
deleted file mode 100644
index ceb0e3a61d25..000000000000
--- a/dev-db/postgresql/files/postgresql-13_beta1-no-server.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-diff -Naruw postgresql-13beta1.orig/contrib/Makefile postgresql-13beta1/contrib/Makefile
---- postgresql-13beta1.orig/contrib/Makefile	2020-05-18 16:09:19.000000000 -0400
-+++ postgresql-13beta1/contrib/Makefile	2020-05-22 19:56:42.560113731 -0400
-@@ -5,56 +5,9 @@
- include $(top_builddir)/src/Makefile.global
- 
- SUBDIRS = \
--		adminpack	\
--		amcheck		\
--		auth_delay	\
--		auto_explain	\
--		bloom		\
--		btree_gin	\
--		btree_gist	\
--		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 postgresql-13beta1.orig/src/backend/Makefile postgresql-13beta1/src/backend/Makefile
---- postgresql-13beta1.orig/src/backend/Makefile	2020-05-18 16:09:19.000000000 -0400
-+++ postgresql-13beta1/src/backend/Makefile	2020-05-22 19:58:14.403299909 -0400
-@@ -56,7 +56,7 @@
- 
- ##########################################################################
- 
--all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
-+all: generated-headers
- 
- ifneq ($(PORTNAME), cygwin)
- ifneq ($(PORTNAME), win32)
-@@ -195,23 +195,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
--	$(MAKE) -C utils 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:
- 
- ifeq ($(with_llvm), yes)
- install-bin: install-postgres-bitcode
-diff -Naruw postgresql-13beta1.orig/src/bin/Makefile postgresql-13beta1/src/bin/Makefile
---- postgresql-13beta1.orig/src/bin/Makefile	2020-05-18 16:09:19.000000000 -0400
-+++ postgresql-13beta1/src/bin/Makefile	2020-05-22 19:59:11.399875256 -0400
-@@ -14,22 +14,8 @@
- include $(top_builddir)/src/Makefile.global
- 
- SUBDIRS = \
--	initdb \
--	pg_archivecleanup \
--	pg_basebackup \
--	pg_checksums \
- 	pg_config \
--	pg_controldata \
--	pg_ctl \
- 	pg_dump \
--	pg_resetwal \
--	pg_rewind \
--	pg_test_fsync \
--	pg_test_timing \
--	pg_upgrade \
--	pg_verifybackup \
--	pg_waldump \
--	pgbench \
- 	psql \
- 	scripts
- 
-diff -Naruw postgresql-13beta1.orig/src/Makefile postgresql-13beta1/src/Makefile
---- postgresql-13beta1.orig/src/Makefile	2020-05-18 16:09:19.000000000 -0400
-+++ postgresql-13beta1/src/Makefile	2020-05-22 19:59:59.656464613 -0400
-@@ -15,21 +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/isolation \
--	test/perl
-+	makefiles
- 
- ifeq ($(with_llvm), yes)
- SUBDIRS += backend/jit/llvm

diff --git a/dev-db/postgresql/files/postgresql-14_rc1-no-server.patch b/dev-db/postgresql/files/postgresql-14_rc1-no-server.patch
deleted file mode 100644
index 4f2d388386a2..000000000000
--- a/dev-db/postgresql/files/postgresql-14_rc1-no-server.patch
+++ /dev/null
@@ -1,151 +0,0 @@
-diff -Naruw a/contrib/Makefile b/contrib/Makefile
---- a/contrib/Makefile	2021-09-20 17:33:01.000000000 -0400
-+++ b/contrib/Makefile	2021-09-23 16:28:52.919265033 -0400
-@@ -5,57 +5,9 @@
- include $(top_builddir)/src/Makefile.global
- 
- SUBDIRS = \
--		adminpack	\
--		amcheck		\
--		auth_delay	\
--		auto_explain	\
--		bloom		\
--		btree_gin	\
--		btree_gist	\
--		citext		\
--		cube		\
--		dblink		\
--		dict_int	\
--		dict_xsyn	\
--		earthdistance	\
--		file_fdw	\
--		fuzzystrmatch	\
--		hstore		\
--		intagg		\
--		intarray	\
--		isn		\
--		lo		\
--		ltree		\
- 		oid2name	\
--		old_snapshot	\
--		pageinspect	\
--		passwordcheck	\
--		pg_buffercache	\
--		pg_freespacemap \
--		pg_prewarm	\
--		pg_stat_statements \
--		pg_surgery	\
--		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_ssl),openssl)
--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	2021-09-20 17:33:01.000000000 -0400
-+++ b/src/backend/Makefile	2021-09-23 16:30:03.015728022 -0400
-@@ -56,7 +56,7 @@
- 
- ##########################################################################
- 
--all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
-+all: generated-headers
- 
- ifneq ($(PORTNAME), cygwin)
- ifneq ($(PORTNAME), win32)
-@@ -194,23 +194,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
--	$(MAKE) -C utils 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:
- 
- ifeq ($(with_llvm), yes)
- install-bin: install-postgres-bitcode
-diff -Naruw a/src/bin/Makefile b/src/bin/Makefile
---- a/src/bin/Makefile	2021-09-20 17:33:01.000000000 -0400
-+++ b/src/bin/Makefile	2021-09-23 16:30:50.718922745 -0400
-@@ -14,23 +14,8 @@
- include $(top_builddir)/src/Makefile.global
- 
- SUBDIRS = \
--	initdb \
--	pg_amcheck \
--	pg_archivecleanup \
--	pg_basebackup \
--	pg_checksums \
- 	pg_config \
--	pg_controldata \
--	pg_ctl \
- 	pg_dump \
--	pg_resetwal \
--	pg_rewind \
--	pg_test_fsync \
--	pg_test_timing \
--	pg_upgrade \
--	pg_verifybackup \
--	pg_waldump \
--	pgbench \
- 	psql \
- 	scripts
- 
-diff -Naruw a/src/Makefile b/src/Makefile
---- a/src/Makefile	2021-09-20 17:33:01.000000000 -0400
-+++ b/src/Makefile	2021-09-23 16:31:41.842107531 -0400
-@@ -15,21 +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/isolation \
--	test/perl
-+	makefiles
- 
- ifeq ($(with_llvm), yes)
- SUBDIRS += backend/jit/llvm

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
deleted file mode 100644
index aa7cf773a39a..000000000000
--- a/dev-db/postgresql/files/postgresql-9.6.3-no-server.patch
+++ /dev/null
@@ -1,141 +0,0 @@
---- a/contrib/Makefile
-+++ b/contrib/Makefile
-@@ -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
---- a/src/backend/Makefile
-+++ b/src/backend/Makefile
-@@ -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)'
---- a/src/bin/Makefile
-+++ b/src/bin/Makefile
-@@ -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
---- a/src/Makefile
-+++ b/src/Makefile
-@@ -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/postgresql-10.19-r1.ebuild b/dev-db/postgresql/postgresql-10.19-r1.ebuild
deleted file mode 100644
index 2bab39336a23..000000000000
--- a/dev-db/postgresql/postgresql-10.19-r1.ebuild
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~ppc-macos ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap nls pam perl
-	  python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libcrypt:=
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	# https://bugs.gentoo.org/753257
-	# https://bugs.gentoo.org/766225
-	eapply "${FILESDIR}"/postgresql-10.0-icu68.patch
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-10.20-r1.ebuild b/dev-db/postgresql/postgresql-10.20-r1.ebuild
deleted file mode 100644
index 93f17aa04271..000000000000
--- a/dev-db/postgresql/postgresql-10.20-r1.ebuild
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-macos ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap nls pam perl
-	  python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libcrypt:=
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	# https://bugs.gentoo.org/753257
-	# https://bugs.gentoo.org/766225
-	eapply "${FILESDIR}"/postgresql-10.0-icu68.patch
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-10.21.ebuild b/dev-db/postgresql/postgresql-10.21.ebuild
deleted file mode 100644
index f2b4125d2922..000000000000
--- a/dev-db/postgresql/postgresql-10.21.ebuild
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10,11} )
-
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-macos ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap nls pam perl
-	  python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libcrypt:=
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Work around PPC{,64} compilation bug where bool is already defined
-	sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
-
-	if use pam ; then
-		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	# https://bugs.gentoo.org/753257
-	# https://bugs.gentoo.org/766225
-	eapply "${FILESDIR}"/postgresql-10.0-icu68.patch
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "${DATA_DIR}"
-		chown -Rf postgres:postgres "${DATA_DIR}"
-		chmod 0700 "${DATA_DIR}"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-11.14-r1.ebuild b/dev-db/postgresql/postgresql-11.14-r1.ebuild
deleted file mode 100644
index 314f76723449..000000000000
--- a/dev-db/postgresql/postgresql-11.14-r1.ebuild
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-LLVM_MAX_SLOT=13
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-14:=
-	<sys-devel/clang-14:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-11.15-r1.ebuild b/dev-db/postgresql/postgresql-11.15-r1.ebuild
deleted file mode 100644
index 4be0a8926b5d..000000000000
--- a/dev-db/postgresql/postgresql-11.15-r1.ebuild
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-LLVM_MAX_SLOT=13
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-14:=
-	<sys-devel/clang-14:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-11.16.ebuild b/dev-db/postgresql/postgresql-11.16.ebuild
deleted file mode 100644
index 2fca671b4f2d..000000000000
--- a/dev-db/postgresql/postgresql-11.16.ebuild
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10,11} )
-LLVM_MAX_SLOT=13
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-14:=
-	<sys-devel/clang-14:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY doc/{TODO,bug.template}
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-12.10-r1.ebuild b/dev-db/postgresql/postgresql-12.10-r1.ebuild
deleted file mode 100644
index b34da8d7f42d..000000000000
--- a/dev-db/postgresql/postgresql-12.10-r1.ebuild
+++ /dev/null
@@ -1,454 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-LLVM_MAX_SLOT=14
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-15:=
-	<sys-devel/clang-15:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch"
-	use llvm && eapply "${FILESDIR}/postgres-llvm14.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-12.11.ebuild b/dev-db/postgresql/postgresql-12.11.ebuild
deleted file mode 100644
index 1930b6f2927d..000000000000
--- a/dev-db/postgresql/postgresql-12.11.ebuild
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10,11} )
-LLVM_MAX_SLOT=14
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-15:=
-	<sys-devel/clang-15:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-12.9-r1.ebuild b/dev-db/postgresql/postgresql-12.9-r1.ebuild
deleted file mode 100644
index e59f0a032797..000000000000
--- a/dev-db/postgresql/postgresql-12.9-r1.ebuild
+++ /dev/null
@@ -1,454 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-LLVM_MAX_SLOT=14
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-15:=
-	<sys-devel/clang-15:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch"
-	use llvm && eapply "${FILESDIR}/postgres-llvm14.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	econf \
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable !alpha spinlocks) \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		emake check
-
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-13.5-r1.ebuild b/dev-db/postgresql/postgresql-13.5-r1.ebuild
deleted file mode 100644
index 6e0f3bba6848..000000000000
--- a/dev-db/postgresql/postgresql-13.5-r1.ebuild
+++ /dev/null
@@ -1,466 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-LLVM_MAX_SLOT=14
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-15:=
-	<sys-devel/clang-15:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch"
-	use llvm && eapply "${FILESDIR}/postgres-llvm14.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	local myconf="\
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
-		emake check
-		export LC_CTYPE=${old_ctype}
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-13.6-r2.ebuild b/dev-db/postgresql/postgresql-13.6-r2.ebuild
deleted file mode 100644
index 3ecf907af22e..000000000000
--- a/dev-db/postgresql/postgresql-13.6-r2.ebuild
+++ /dev/null
@@ -1,466 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-LLVM_MAX_SLOT=14
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-15:=
-	<sys-devel/clang-15:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch"
-	use llvm && eapply "${FILESDIR}/postgres-llvm14.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	local myconf="\
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
-		emake check
-		export LC_CTYPE=${old_ctype}
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-13.7.ebuild b/dev-db/postgresql/postgresql-13.7.ebuild
deleted file mode 100644
index bec67b2f0353..000000000000
--- a/dev-db/postgresql/postgresql-13.7.ebuild
+++ /dev/null
@@ -1,465 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10,11} )
-LLVM_MAX_SLOT=14
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-15:=
-	<sys-devel/clang-15:=
-)
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch
-
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	local myconf="\
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
-		emake check
-		export LC_CTYPE=${old_ctype}
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-14.1-r1.ebuild b/dev-db/postgresql/postgresql-14.1-r1.ebuild
deleted file mode 100644
index 4865e372312f..000000000000
--- a/dev-db/postgresql/postgresql-14.1-r1.ebuild
+++ /dev/null
@@ -1,466 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-LLVM_MAX_SLOT=14
-
-inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm lz4 nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	<sys-devel/llvm-15:=
-	<sys-devel/clang-15:=
-)
-lz4? ( app-arch/lz4 )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use llvm && llvm_pkg_setup
-
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch"
-	use llvm && eapply "${FILESDIR}/postgres-llvm14.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	local myconf="\
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with lz4) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
-		emake check
-		export LC_CTYPE=${old_ctype}
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-14.2-r1.ebuild b/dev-db/postgresql/postgresql-14.2-r1.ebuild
deleted file mode 100644
index ba00ea41f4e1..000000000000
--- a/dev-db/postgresql/postgresql-14.2-r1.ebuild
+++ /dev/null
@@ -1,463 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10} )
-
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm lz4 nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
-)
-lz4? ( app-arch/lz4 )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch"
-	use llvm && eapply "${FILESDIR}/postgres-llvm14.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	local myconf="\
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with lz4) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
-		emake check
-		export LC_CTYPE=${old_ctype}
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-14.4.ebuild b/dev-db/postgresql/postgresql-14.4.ebuild
deleted file mode 100644
index 9e6e14b865be..000000000000
--- a/dev-db/postgresql/postgresql-14.4.ebuild
+++ /dev/null
@@ -1,462 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10,11} )
-
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm lz4 nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
-)
-lz4? ( app-arch/lz4 )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	local myconf="\
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with lz4) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_enable nls)"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
-		emake check
-		export LC_CTYPE=${old_ctype}
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}

diff --git a/dev-db/postgresql/postgresql-15_beta2.ebuild b/dev-db/postgresql/postgresql-15_beta2.ebuild
deleted file mode 100644
index 0207dd4f4251..000000000000
--- a/dev-db/postgresql/postgresql-15_beta2.ebuild
+++ /dev/null
@@ -1,464 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-PYTHON_COMPAT=( python3_{8,9,10,11} )
-
-inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles
-
-KEYWORDS=""
-
-SLOT=$(ver_cut 1)
-
-MY_PV=${PV/_/}
-S="${WORKDIR}/${PN}-${MY_PV}"
-
-SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
-
-LICENSE="POSTGRESQL GPL-2"
-DESCRIPTION="PostgreSQL RDBMS"
-HOMEPAGE="https://www.postgresql.org/"
-
-IUSE="debug doc icu kerberos ldap llvm lz4 nls pam
-	  perl python +readline selinux +server systemd ssl static-libs tcl
-	  threads uuid xml zlib zstd"
-
-REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
-
-CDEPEND="
->=app-eselect/eselect-postgresql-2.0
-acct-group/postgres
-acct-user/postgres
-sys-apps/less
-virtual/libintl
-icu? ( dev-libs/icu:= )
-kerberos? ( virtual/krb5 )
-ldap? ( net-nds/openldap:= )
-llvm? (
-	sys-devel/llvm:=
-	sys-devel/clang:=
-)
-lz4? ( app-arch/lz4 )
-pam? ( sys-libs/pam )
-perl? ( >=dev-lang/perl-5.8:= )
-python? ( ${PYTHON_DEPS} )
-readline? ( sys-libs/readline:0= )
-server? ( systemd? ( sys-apps/systemd ) )
-ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
-tcl? ( >=dev-lang/tcl-8:0= )
-xml? ( dev-libs/libxml2 dev-libs/libxslt )
-zlib? ( sys-libs/zlib )
-zstd? ( app-arch/zstd )
-"
-
-# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
-# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
-# the libc includes UUID functions.
-UTIL_LINUX_LIBC=( elibc_{glibc,musl} )
-
-nest_usedep() {
-	local front back
-	while [[ ${#} -gt 1 ]]; do
-		front+="${1}? ( "
-		back+=" )"
-		shift
-	done
-	echo "${front}${1}${back}"
-}
-
-CDEPEND+="
-uuid? (
-	${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
-	$(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid)
-)"
-
-DEPEND="${CDEPEND}
-sys-devel/bison
-sys-devel/flex
-nls? ( sys-devel/gettext )
-xml? ( virtual/pkgconfig )
-"
-
-RDEPEND="${CDEPEND}
-selinux? ( sec-policy/selinux-postgresql )
-"
-
-pkg_setup() {
-	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
-
-	use python && python-single-r1_pkg_setup
-}
-
-src_prepare() {
-	# Set proper run directory
-	sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
-		-i src/include/pg_config_manual.h || die
-
-	# Rely on $PATH being in the proper order so that the correct
-	# install program is used for modules utilizing PGXS in both
-	# hardened and non-hardened environments. (Bug #528786)
-	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
-
-	use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch"
-
-	if use pam ; then
-		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
-			-i src/backend/libpq/auth.c || \
-			die 'PGSQL_PAM_SERVICE rename failed.'
-	fi
-
-	eapply_user
-}
-
-src_configure() {
-	case ${CHOST} in
-		*-darwin*|*-solaris*)
-			use nls && append-libs intl
-			;;
-	esac
-
-	export LDFLAGS_SL="${LDFLAGS}"
-	export LDFLAGS_EX="${LDFLAGS}"
-
-	local PO="${EPREFIX}"
-
-	local i uuid_config=""
-	if use uuid; then
-		for i in ${UTIL_LINUX_LIBC[@]}; do
-			use ${i} && uuid_config="--with-uuid=e2fs"
-		done
-		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
-	fi
-
-	local myconf="\
-		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
-		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
-		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
-		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
-		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
-		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
-		$(use_enable debug) \
-		$(use_enable threads thread-safety) \
-		$(use_with icu) \
-		$(use_with kerberos gssapi) \
-		$(use_with ldap) \
-		$(use_with llvm) \
-		$(use_with lz4) \
-		$(use_with pam) \
-		$(use_with perl) \
-		$(use_with python) \
-		$(use_with readline) \
-		$(use_with ssl openssl) \
-		$(usex server "$(use_with systemd)" '--without-systemd') \
-		$(use_with tcl) \
-		${uuid_config} \
-		$(use_with xml libxml) \
-		$(use_with xml libxslt) \
-		$(use_with zlib) \
-		$(use_with zstd) \
-		$(use_enable nls)"
-	if use alpha; then
-		myconf+=" --disable-spinlocks"
-	else
-		# Should be the default but just in case
-		myconf+=" --enable-spinlocks"
-	fi
-	econf ${myconf}
-}
-
-src_compile() {
-	emake
-	emake -C contrib
-}
-
-src_install() {
-	emake DESTDIR="${D}" install
-	emake DESTDIR="${D}" install -C contrib
-
-	dodoc README HISTORY
-
-	# man pages are already built, but if we have the target make them,
-	# they'll be generated from source before being installed so we
-	# manually install man pages.
-	# We use ${SLOT} instead of doman for postgresql.eselect
-	insinto /usr/share/postgresql-${SLOT}/man/
-	doins -r doc/src/sgml/man{1,3,7}
-	if ! use server; then
-		# Remove man pages for non-existent binaries
-		serverman=(
-			initdb
-			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
-			pg_{test_{fsync,timing},upgrade,waldump}
-			post{gres,master}
-		)
-		for m in ${serverman[@]} ; do
-			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
-		done
-	fi
-	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
-
-	# Create slot specific man pages
-	local bn f mansec slotted_name
-	for mansec in 1 3 7 ; do
-		local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
-
-		mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
-		pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
-
-		for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
-			bn=$(basename "${f}")
-			slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
-			case ${bn} in
-				TABLE.7|WITH.7)
-					echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
-					;;
-				*)
-					echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
-					;;
-			esac
-		done
-
-		popd > /dev/null
-	done
-
-	insinto /etc/postgresql-${SLOT}
-	newins src/bin/psql/psqlrc.sample psqlrc
-
-	# Don't delete libpg{port,common}.a (Bug #571046). They're always
-	# needed by extensions utilizing PGXS.
-	use static-libs || \
-		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
-			 -delete
-
-	# Make slot specific links to programs
-	local f bn
-	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
-					-mindepth 1 -maxdepth 1)
-	do
-		bn=$(basename "${f}")
-		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
-			  "/usr/bin/${bn}${SLOT/.}"
-	done
-
-	if use doc ; then
-		docinto html
-		dodoc doc/src/sgml/html/*
-	fi
-
-	if use server; then
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
-
-		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
-
-		if use systemd; then
-			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
-				"${FILESDIR}/${PN}.service-9.6-r1" | \
-				systemd_newunit - ${PN}-${SLOT}.service
-			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
-			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
-		fi
-
-		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
-
-		if use prefix ; then
-			keepdir /run/postgresql
-			fperms 1775 /run/postgresql
-		fi
-	fi
-}
-
-pkg_postinst() {
-	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
-	postgresql-config update
-
-	elog "If you need a global psqlrc-file, you can place it in:"
-	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
-
-	if use server ; then
-		elog
-		elog "Gentoo specific documentation:"
-		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
-		elog
-		elog "Official documentation:"
-		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
-		elog
-		elog "The default location of the Unix-domain socket is:"
-		elog "    ${EROOT}/run/postgresql/"
-		elog
-		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
-		elog "so that it contains your preferred locale in:"
-		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-		elog
-		elog "Then, execute the following command to setup the initial database"
-		elog "environment:"
-		elog "    emerge --config =${CATEGORY}/${PF}"
-
-		if [[ -n ${REPLACING_VERSIONS} ]] ; then
-			ewarn "If your system is using 'pg_stat_statements' and you are running a"
-			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
-			ewarn "the following command after upgrading:"
-			ewarn
-			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
-		fi
-	fi
-}
-
-pkg_prerm() {
-	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
-		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
-		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
-
-		ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
-		sleep 10
-		eend 0
-	fi
-}
-
-pkg_postrm() {
-	postgresql-config update
-}
-
-pkg_config() {
-	use server || die "USE flag 'server' not enabled. Nothing to configure."
-
-	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
-		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
-	[[ -z "${DATA_DIR}" ]] \
-		&& DATA_DIR="${EROOT}/var/lib/postgresql/${SLOT}/data"
-
-	# environment.bz2 may not contain the same locale as the current system
-	# locale. Unset and source from the current system locale.
-	if [ -f "${EROOT}/etc/env.d/02locale" ]; then
-		unset LANG
-		unset LC_CTYPE
-		unset LC_NUMERIC
-		unset LC_TIME
-		unset LC_COLLATE
-		unset LC_MONETARY
-		unset LC_MESSAGES
-		unset LC_ALL
-		source "${EROOT}/etc/env.d/02locale"
-		[ -n "${LANG}" ] && export LANG
-		[ -n "${LC_CTYPE}" ] && export LC_CTYPE
-		[ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
-		[ -n "${LC_TIME}" ] && export LC_TIME
-		[ -n "${LC_COLLATE}" ] && export LC_COLLATE
-		[ -n "${LC_MONETARY}" ] && export LC_MONETARY
-		[ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
-		[ -n "${LC_ALL}" ] && export LC_ALL
-	fi
-
-	einfo "You can modify the paths and options passed to initdb by editing:"
-	einfo "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
-	einfo
-	einfo "Information on options that can be passed to initdb are found at:"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
-	einfo "    https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
-	einfo
-	einfo "PG_INITDB_OPTS is currently set to:"
-	if [[ -z "${PG_INITDB_OPTS}" ]] ; then
-		einfo "    (none)"
-	else
-		einfo "    ${PG_INITDB_OPTS}"
-	fi
-	einfo
-	einfo "Configuration files will be installed to:"
-	einfo "    ${PGDATA}"
-	einfo
-	einfo "The database cluster will be created in:"
-	einfo "    ${DATA_DIR}"
-	einfo
-
-	ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
-	sleep 5
-	eend 0
-
-	if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
-		eerror "The given directory, '${DATA_DIR}', is not empty."
-		eerror "Modify DATA_DIR to point to an empty directory."
-		die "${DATA_DIR} is not empty."
-	fi
-
-	einfo "Creating the data directory ..."
-	if [[ ${EUID} == 0 ]] ; then
-		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
-		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
-		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
-	fi
-
-	einfo "Initializing the database ..."
-
-	if [[ ${EUID} == 0 ]] ; then
-		su - postgres -c "${EROOT}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
-	else
-		"${EROOT}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
-	fi
-
-	if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
-		mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
-		ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
-	fi
-
-	# unix_socket_directory has no effect in postgresql.conf as it's
-	# overridden in the initscript
-	sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
-
-	cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
-		# This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
-		# On the off-chance that you might need to work with UTF-8 encoded
-		# characters in PL/Perl
-		plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
-	EOF
-
-	einfo "The autovacuum function, which was in contrib, has been moved to the main"
-	einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
-	einfo "by default. You can disable it in the cluster's:"
-	einfo "    ${PGDATA%/}/postgresql.conf"
-	einfo
-	if ! use systemd; then
-		einfo "The PostgreSQL server, by default, will log events to:"
-		einfo "    ${DATA_DIR%/}/postmaster.log"
-		einfo
-	fi
-	if use prefix ; then
-		einfo "The location of the configuration files have moved to:"
-		einfo "    ${PGDATA}"
-		einfo "To start the server:"
-		einfo "    pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
-		einfo "To stop:"
-		einfo "    pg_ctl stop -D ${DATA_DIR}"
-		einfo
-		einfo "Or move the configuration files back:"
-		einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
-	elif use systemd; then
-		einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	else
-		einfo "You should use the '${EROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
-		einfo "instead of 'pg_ctl'."
-	fi
-}
-
-src_test() {
-	if use server && [[ ${UID} -ne 0 ]] ; then
-		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
-		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
-		local old_ctype=${LC_CTYPE}
-		export LC_CTYPE=${LC_COLLATE}
-		emake check
-		export LC_CTYPE=${old_ctype}
-		einfo "If you think other tests besides the regression tests are necessary, please"
-		einfo "submit a bug including a patch for this ebuild to enable them."
-	else
-		use server || \
-			ewarn 'Tests cannot be run without the "server" use flag enabled.'
-		[[ ${UID} -eq 0 ]] || \
-			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
-
-		ewarn 'Skipping.'
-	fi
-}


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-08-18 11:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-18 11:26 [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/files/, dev-db/postgresql/ Aaron W. Swenson
  -- strict thread matches above, loose matches on Subject: below --
2022-08-15 16:53 Aaron W. Swenson
2022-03-24  6:28 罗百科
2021-08-13 11:37 Marek Szuba
2020-08-14  1:59 Aaron W. Swenson
2020-08-14  0:53 Aaron W. Swenson
2019-06-15 10:58 Aaron W. Swenson
2018-05-20  9:42 Aaron Swenson
2018-02-11 15:55 Aaron Swenson
2017-08-10 15:16 Aaron Swenson
2017-07-13 15:34 Aaron Swenson
2017-05-31 16:48 Patrice Clement
2017-04-17 15:48 Aaron Swenson
2015-10-25 21:10 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox