commit:     88f82c7a279e6222a7801862c48a99f249b503d7
Author:     Julian Ospald <hasufell <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 20:46:51 2015 +0000
Commit:     Julian Ospald <hasufell <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 20:46:51 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=88f82c7a

dev-db/postgresql: add libressl support

 ...sql-9999.ebuild => postgresql-9.0.22-r1.ebuild} | 164 ++++++++---------
 ...sql-9999.ebuild => postgresql-9.1.18-r1.ebuild} | 168 +++++++++---------
 ...sql-9999.ebuild => postgresql-9.2.13-r1.ebuild} | 154 +++++++++-------
 ...esql-9999.ebuild => postgresql-9.3.9-r1.ebuild} | 154 +++++++++-------
 ...esql-9999.ebuild => postgresql-9.4.4-r2.ebuild} | 193 ++++++++++++--------
 ...9999.ebuild => postgresql-9.5_alpha1-r1.ebuild} | 194 +++++++++++++--------
 dev-db/postgresql/postgresql-9999.ebuild           |   9 +-
 7 files changed, 602 insertions(+), 434 deletions(-)

diff --git a/dev-db/postgresql/postgresql-9999.ebuild 
b/dev-db/postgresql/postgresql-9.0.22-r1.ebuild
similarity index 71%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.0.22-r1.ebuild
index 5272ee4..66d27da 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.0.22-r1.ebuild
@@ -4,17 +4,20 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python{2_{6,7},3_{2,3,4}} )
+# Testing within Portage's environment is broken, and the patch no
+# longer applies cleanly.
+RESTRICT="test"
 
-inherit base eutils flag-o-matic git-2 linux-info multilib pam prefix \
-               python-single-r1 systemd user versionator
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-KEYWORDS=""
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+               systemd user versionator
 
-# Fix if needed
-SLOT="9.6"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc 
~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+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"
@@ -22,7 +25,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 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
@@ -49,7 +52,10 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8 )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
-ssl? ( >=dev-libs/openssl-0.9.6-r1: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 )
@@ -58,23 +64,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}
@@ -83,17 +77,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
@@ -109,6 +94,10 @@ src_prepare() {
        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"
+
        if use pam ; then
                sed -e "s/\(#define PGSQL_PAM_SERVICE 
\"postgresql\)/\1-${SLOT}/" \
                        -i src/backend/libpq/auth.c || \
@@ -141,6 +130,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) \
@@ -156,14 +146,30 @@ 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
 
@@ -173,25 +179,35 @@ src_install() {
 
        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}
+       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" | newconfd - ${PN}-${SLOT}
 
-       systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
+               sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+                       "${FILESDIR}/${PN}.init-pre_9.2" | newinitd - 
${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}.service" | \
+                       systemd_newunit - ${PN}-${SLOT}.service
 
-       use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+               systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd 
${PN}-${SLOT}.conf
 
-       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
 }
 
@@ -201,27 +217,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";
 
@@ -236,6 +254,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}/"
@@ -352,19 +372,3 @@ pkg_config() {
                einfo "instead of 'pg_ctl'."
        fi
 }
-
-src_test() {
-       einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-       if [[ ${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
-               [[ ${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-9.1.18-r1.ebuild
similarity index 69%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.1.18-r1.ebuild
index 5272ee4..94d6120 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.1.18-r1.ebuild
@@ -4,17 +4,20 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python{2_{6,7},3_{2,3,4}} )
+# Testing within Portage's environment is broken, and the patch no
+# longer applies cleanly.
+RESTRICT="test"
 
-inherit base eutils flag-o-matic git-2 linux-info multilib pam prefix \
-               python-single-r1 systemd user versionator
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-KEYWORDS=""
+inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
+               systemd user versionator
 
-# Fix if needed
-SLOT="9.6"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc 
~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
 
-EGIT_REPO_URI="git://git.postgresql.org/git/postgresql.git"
+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"
@@ -22,7 +25,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 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
@@ -49,7 +52,10 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8 )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
-ssl? ( >=dev-libs/openssl-0.9.6-r1: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 )
@@ -58,23 +64,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}
@@ -83,17 +77,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
@@ -109,6 +94,14 @@ src_prepare() {
        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 || \
@@ -141,6 +134,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) \
@@ -156,14 +150,30 @@ 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
 
@@ -173,25 +183,35 @@ src_install() {
 
        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}
+       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" | newconfd - ${PN}-${SLOT}
 
-       systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
+               sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+                       "${FILESDIR}/${PN}.init-pre_9.2" | newinitd - 
${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}.service" | \
+                       systemd_newunit - ${PN}-${SLOT}.service
 
-       use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+               systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd 
${PN}-${SLOT}.conf
 
-       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
 }
 
@@ -201,27 +221,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";
 
@@ -236,6 +258,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}/"
@@ -352,19 +376,3 @@ pkg_config() {
                einfo "instead of 'pg_ctl'."
        fi
 }
-
-src_test() {
-       einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
-
-       if [[ ${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
-               [[ ${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-9.2.13-r1.ebuild
similarity index 70%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.2.13-r1.ebuild
index 5272ee4..af0a7f3 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.2.13-r1.ebuild
@@ -4,17 +4,16 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python{2_{6,7},3_{2,3,4}} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-inherit base 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.6"
+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"
@@ -22,7 +21,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 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
@@ -49,7 +48,10 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8 )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
-ssl? ( >=dev-libs/openssl-0.9.6-r1: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 )
@@ -58,23 +60,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}
@@ -83,17 +73,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
@@ -109,6 +90,12 @@ src_prepare() {
        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 || \
@@ -141,6 +128,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) \
@@ -156,14 +144,30 @@ 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
 
@@ -173,25 +177,35 @@ src_install() {
 
        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}
+       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" | newconfd - ${PN}-${SLOT}
 
-       systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
+               sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+                       "${FILESDIR}/${PN}.init" | newinitd - ${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}.service" | \
+                       systemd_newunit - ${PN}-${SLOT}.service
 
-       use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+               systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd 
${PN}-${SLOT}.conf
 
-       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
 }
 
@@ -201,27 +215,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";
 
@@ -236,6 +252,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}/"
@@ -356,15 +374,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.9-r1.ebuild
similarity index 70%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.3.9-r1.ebuild
index 5272ee4..cfd6214 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.3.9-r1.ebuild
@@ -4,17 +4,16 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python{2_{6,7},3_{2,3,4}} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-inherit base 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.6"
+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"
@@ -22,7 +21,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 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
@@ -49,7 +48,10 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8 )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
-ssl? ( >=dev-libs/openssl-0.9.6-r1: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 )
@@ -58,23 +60,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}
@@ -83,17 +73,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
@@ -109,6 +90,12 @@ src_prepare() {
        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 || \
@@ -141,6 +128,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) \
@@ -156,14 +144,30 @@ 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
 
@@ -173,25 +177,35 @@ src_install() {
 
        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}
+       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" | newconfd - ${PN}-${SLOT}
 
-       systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
+               sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+                       "${FILESDIR}/${PN}.init-9.3" | newinitd - ${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}.service" | \
+                       systemd_newunit - ${PN}-${SLOT}.service
 
-       use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+               systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd 
${PN}-${SLOT}.conf
 
-       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
 }
 
@@ -201,27 +215,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";
 
@@ -236,6 +252,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}/"
@@ -356,15 +374,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.4-r2.ebuild
similarity index 64%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.4.4-r2.ebuild
index 5272ee4..6d720f0 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.4.4-r2.ebuild
@@ -4,17 +4,16 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python{2_{6,7},3_{2,3,4}} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-inherit base 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.6"
+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"
@@ -22,7 +21,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 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
@@ -49,32 +48,45 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8 )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
-ssl? ( >=dev-libs/openssl-0.9.6-r1: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 )
 "
 
+# 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}
@@ -83,17 +95,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
@@ -109,6 +112,15 @@ src_prepare() {
        sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
                -i src/include/pg_config_manual.h || die
 
+       # Fix bug 555198: Correct typo in assembly code for alpha architecture
+       epatch "${FILESDIR}/${PN}-${SLOT}-alpha-fix-read-memory-barrier.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.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 || \
@@ -130,6 +142,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}" \
@@ -148,7 +171,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) \
@@ -156,14 +179,30 @@ 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
 
@@ -173,25 +212,35 @@ src_install() {
 
        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}
+       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" | newconfd - ${PN}-${SLOT}
 
-       systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
+               sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+                       "${FILESDIR}/${PN}.init-9.3" | newinitd - ${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}.service" | \
+                       systemd_newunit - ${PN}-${SLOT}.service
 
-       use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+               systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd 
${PN}-${SLOT}.conf
 
-       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
 }
 
@@ -201,27 +250,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";
 
@@ -236,6 +287,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}/"
@@ -356,15 +409,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_alpha1-r1.ebuild
similarity index 64%
copy from dev-db/postgresql/postgresql-9999.ebuild
copy to dev-db/postgresql/postgresql-9.5_alpha1-r1.ebuild
index 5272ee4..50d2cec 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9.5_alpha1-r1.ebuild
@@ -4,17 +4,22 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python{2_{6,7},3_{2,3,4}} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
-inherit base 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
 
+# This is a prerelease version, so no keywords please
 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.6"
+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"
@@ -22,7 +27,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 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
@@ -49,32 +54,45 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8 )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
-ssl? ( >=dev-libs/openssl-0.9.6-r1: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 )
 "
 
+# 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}
@@ -83,17 +101,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
@@ -109,6 +118,12 @@ src_prepare() {
        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 || \
@@ -130,6 +145,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}" \
@@ -148,7 +174,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) \
@@ -156,14 +182,30 @@ 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
 
@@ -173,25 +215,35 @@ src_install() {
 
        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}
+       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" | newconfd - ${PN}-${SLOT}
 
-       systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd ${PN}-${SLOT}.conf
+               sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
+                       "${FILESDIR}/${PN}.init-9.3" | newinitd - ${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}.service" | \
+                       systemd_newunit - ${PN}-${SLOT}.service
 
-       use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
+               systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd 
${PN}-${SLOT}.conf
 
-       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
 }
 
@@ -201,27 +253,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";
 
@@ -236,6 +290,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}/"
@@ -356,15 +412,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 5272ee4..6dec347 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -4,7 +4,7 @@
 
 EAPI="5"
 
-PYTHON_COMPAT=( python{2_{6,7},3_{2,3,4}} )
+PYTHON_COMPAT=( python{2_7,3_4} )
 
 inherit base eutils flag-o-matic git-2 linux-info multilib pam prefix \
                python-single-r1 systemd user versionator
@@ -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 nls pam perl -pg_legacytimestamp python
+IUSE="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
@@ -49,7 +49,10 @@ pam? ( virtual/pam )
 perl? ( >=dev-lang/perl-5.8 )
 python? ( ${PYTHON_DEPS} )
 readline? ( sys-libs/readline:0= )
-ssl? ( >=dev-libs/openssl-0.9.6-r1: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 )

Reply via email to