Gentoo Archives: gentoo-commits

From: Aaron Swenson <titanofold@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/
Date: Tue, 30 May 2017 12:29:31
Message-Id: 1496147338.fa6251515c9c37e54bb80202fc5ceadb9561c137.titanofold@gentoo
1 commit: fa6251515c9c37e54bb80202fc5ceadb9561c137
2 Author: Aaron W. Swenson <titanofold <AT> gentoo <DOT> org>
3 AuthorDate: Tue May 30 12:28:58 2017 +0000
4 Commit: Aaron Swenson <titanofold <AT> gentoo <DOT> org>
5 CommitDate: Tue May 30 12:28:58 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fa625151
7
8 dev-db/postgresql: Add Python 3.{5,6} to COMPAT
9
10 Bug: https://bugs.gentoo.org/619986
11
12 Package-Manager: Portage-2.3.3, Repoman-2.3.1
13
14 dev-db/postgresql/postgresql-9.2.21-r1.ebuild | 435 ++++++++++++++++++++++++
15 dev-db/postgresql/postgresql-9.3.17-r1.ebuild | 440 ++++++++++++++++++++++++
16 dev-db/postgresql/postgresql-9.4.12-r1.ebuild | 472 ++++++++++++++++++++++++++
17 3 files changed, 1347 insertions(+)
18
19 diff --git a/dev-db/postgresql/postgresql-9.2.21-r1.ebuild b/dev-db/postgresql/postgresql-9.2.21-r1.ebuild
20 new file mode 100644
21 index 00000000000..004acf03857
22 --- /dev/null
23 +++ b/dev-db/postgresql/postgresql-9.2.21-r1.ebuild
24 @@ -0,0 +1,435 @@
25 +# Copyright 1999-2017 Gentoo Foundation
26 +# Distributed under the terms of the GNU General Public License v2
27 +
28 +EAPI="5"
29 +
30 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
31 +
32 +inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
33 + systemd user versionator
34 +
35 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
36 +
37 +SLOT="$(get_version_component_range 1-2)"
38 +
39 +SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
40 +
41 +LICENSE="POSTGRESQL GPL-2"
42 +DESCRIPTION="PostgreSQL RDBMS"
43 +HOMEPAGE="http://www.postgresql.org/"
44 +
45 +LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
46 + zh_CN zh_TW"
47 +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
48 + +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
49 +
50 +for lingua in ${LINGUAS}; do
51 + IUSE+=" linguas_${lingua}"
52 +done
53 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
54 +
55 +wanted_languages() {
56 + local enable_langs
57 +
58 + for lingua in ${LINGUAS} ; do
59 + use linguas_${lingua} && enable_langs+="${lingua} "
60 + done
61 +
62 + echo -n ${enable_langs}
63 +}
64 +
65 +CDEPEND="
66 +>=app-eselect/eselect-postgresql-2.0
67 +sys-apps/less
68 +virtual/libintl
69 +kerberos? ( virtual/krb5 )
70 +ldap? ( net-nds/openldap )
71 +pam? ( virtual/pam )
72 +perl? ( >=dev-lang/perl-5.8:= )
73 +python? ( ${PYTHON_DEPS} )
74 +readline? ( sys-libs/readline:0= )
75 +ssl? (
76 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
77 + libressl? ( dev-libs/libressl:= )
78 +)
79 +tcl? ( >=dev-lang/tcl-8:0= )
80 +uuid? ( dev-libs/ossp-uuid )
81 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
82 +zlib? ( sys-libs/zlib )
83 +"
84 +
85 +DEPEND="${CDEPEND}
86 +!!<sys-apps/sandbox-2.0
87 +sys-devel/bison
88 +sys-devel/flex
89 +nls? ( sys-devel/gettext )
90 +xml? ( virtual/pkgconfig )
91 +"
92 +
93 +RDEPEND="${CDEPEND}
94 +!dev-db/postgresql-docs:${SLOT}
95 +!dev-db/postgresql-base:${SLOT}
96 +!dev-db/postgresql-server:${SLOT}
97 +selinux? ( sec-policy/selinux-postgresql )
98 +"
99 +
100 +pkg_setup() {
101 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
102 +
103 + enewgroup postgres 70
104 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
105 +
106 + use python && python-single-r1_pkg_setup
107 +}
108 +
109 +src_prepare() {
110 + # Work around PPC{,64} compilation bug where bool is already defined
111 + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
112 +
113 + # Set proper run directory
114 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
115 + -i src/include/pg_config_manual.h || die
116 +
117 + use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
118 +
119 + # Fix bug 486556 where the server would crash at start up because of
120 + # an infinite loop caused by a self-referencing symlink.
121 + epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
122 +
123 + if use pam ; then
124 + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
125 + -i src/backend/libpq/auth.c || \
126 + die 'PGSQL_PAM_SERVICE rename failed.'
127 + fi
128 +
129 + epatch_user
130 +}
131 +
132 +src_configure() {
133 + case ${CHOST} in
134 + *-darwin*|*-solaris*)
135 + use nls && append-libs intl
136 + ;;
137 + esac
138 +
139 + export LDFLAGS_SL="${LDFLAGS}"
140 + export LDFLAGS_EX="${LDFLAGS}"
141 +
142 + local PO="${EPREFIX%/}"
143 +
144 + econf \
145 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
146 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
147 + --docdir="${PO}/usr/share/doc/${PF}" \
148 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
149 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
150 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
151 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
152 + $(use_enable !pg_legacytimestamp integer-datetimes) \
153 + $(use_enable threads thread-safety) \
154 + $(use_with kerberos gssapi) \
155 + $(use_with kerberos krb5) \
156 + $(use_with ldap) \
157 + $(use_with pam) \
158 + $(use_with perl) \
159 + $(use_with python) \
160 + $(use_with readline) \
161 + $(use_with ssl openssl) \
162 + $(use_with tcl) \
163 + $(use_with uuid ossp-uuid) \
164 + $(use_with xml libxml) \
165 + $(use_with xml libxslt) \
166 + $(use_with zlib) \
167 + "$(use_enable nls nls "$(wanted_languages)")"
168 +}
169 +
170 +src_compile() {
171 + emake
172 + emake -C contrib
173 +}
174 +
175 +src_install() {
176 + emake DESTDIR="${D}" install
177 + emake DESTDIR="${D}" install -C contrib
178 +
179 + dodoc README HISTORY doc/{TODO,bug.template}
180 +
181 + # man pages are already built, but if we have the target make them,
182 + # they'll be generated from source before being installed so we
183 + # manually install man pages.
184 + # We use ${SLOT} instead of doman for postgresql.eselect
185 + insinto /usr/share/postgresql-${SLOT}/man/
186 + doins -r doc/src/sgml/man{1,3,7}
187 + if ! use server; then
188 + # Remove man pages for non-existent binaries
189 + for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
190 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
191 + done
192 + fi
193 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
194 +
195 + insinto /etc/postgresql-${SLOT}
196 + newins src/bin/psql/psqlrc.sample psqlrc
197 +
198 + use static-libs || find "${ED}" -name '*.a' -delete
199 +
200 + local f bn
201 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
202 + -mindepth 1 -maxdepth 1)
203 + do
204 + bn=$(basename "${f}")
205 + # Temporarily tack on tmp to workaround a file collision
206 + # issue. This is only necessary for 9.7 and earlier. 10 never
207 + # had this issue.
208 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
209 + "/usr/bin/${bn}${SLOT/.}tmp"
210 + done
211 +
212 + local linkname mansec
213 + for mansec in {1,3,7} ; do
214 + for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
215 + bn=$(basename "${f}")
216 + linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
217 + dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
218 + /usr/share/man/man${mansec}/${linkname}
219 + done
220 + done
221 +
222 + if use doc ; then
223 + docinto html
224 + dodoc doc/src/sgml/html/*
225 +
226 + docinto sgml
227 + dodoc doc/src/sgml/*.{sgml,dsl}
228 + fi
229 +
230 + if use server; then
231 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
232 + "${FILESDIR}/${PN}.confd-9.2" | newconfd - ${PN}-${SLOT}
233 +
234 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
235 + "${FILESDIR}/${PN}.init-9.2" | newinitd - ${PN}-${SLOT}
236 +
237 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
238 + "${FILESDIR}/${PN}.service" | \
239 + systemd_newunit - ${PN}-${SLOT}.service
240 +
241 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
242 +
243 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
244 +
245 + if use prefix ; then
246 + keepdir /run/postgresql
247 + fperms 0775 /run/postgresql
248 + fi
249 + fi
250 +}
251 +
252 +pkg_preinst() {
253 + # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
254 + # /usr/bin/psql96). They may have been created by the
255 + # postgresql.eselect module, but they're handled within this ebuild
256 + # now. It's alright if we momentarily delete /usr/bin/psql as it
257 + # will be recreated by the eselect module in pkg_ppostinst(). This
258 + # is only necessary for 9.7 and earlier. 10 and later were never
259 + # handled in this manner.
260 + local canonicalise
261 + if type -p realpath > /dev/null; then
262 + canonicalise=realpath
263 + elif type -p readlink > /dev/null; then
264 + canonicalise='readlink -f'
265 + else
266 + # can't die, subshell
267 + die "No readlink nor realpath found, cannot canonicalise"
268 + fi
269 +
270 + local l
271 + # First remove any symlinks in /usr/bin that may have been created
272 + # by the old eselect
273 + for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
274 + if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
275 + rm "${l}" || ewarn "Couldn't remove ${l}"
276 + fi
277 + done
278 +
279 + # Then move the symlinks created by the ebuild to their proper place.
280 + for l in "${ED}"/usr/bin/*tmp ; do
281 + mv "${l}" "${l%tmp}" \
282 + || ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
283 + done
284 +}
285 +
286 +pkg_postinst() {
287 + postgresql-config update
288 +
289 + elog "If you need a global psqlrc-file, you can place it in:"
290 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
291 +
292 + if use server ; then
293 + elog
294 + elog "Gentoo specific documentation:"
295 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
296 + elog
297 + elog "Official documentation:"
298 + elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
299 + elog
300 + elog "The default location of the Unix-domain socket is:"
301 + elog " ${EROOT%/}/run/postgresql/"
302 + elog
303 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
304 + elog "so that it contains your preferred locale in:"
305 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
306 + elog
307 + elog "Then, execute the following command to setup the initial database"
308 + elog "environment:"
309 + elog " emerge --config =${CATEGORY}/${PF}"
310 + fi
311 +}
312 +
313 +pkg_prerm() {
314 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
315 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
316 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
317 +
318 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
319 + sleep 10
320 + eend 0
321 + fi
322 +}
323 +
324 +pkg_postrm() {
325 + postgresql-config update
326 +}
327 +
328 +pkg_config() {
329 + use server || die "USE flag 'server' not enabled. Nothing to configure."
330 +
331 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
332 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
333 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
334 + [[ -z "${DATA_DIR}" ]] \
335 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
336 +
337 + # environment.bz2 may not contain the same locale as the current system
338 + # locale. Unset and source from the current system locale.
339 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
340 + unset LANG
341 + unset LC_CTYPE
342 + unset LC_NUMERIC
343 + unset LC_TIME
344 + unset LC_COLLATE
345 + unset LC_MONETARY
346 + unset LC_MESSAGES
347 + unset LC_ALL
348 + source "${EROOT%/}/etc/env.d/02locale"
349 + [ -n "${LANG}" ] && export LANG
350 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
351 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
352 + [ -n "${LC_TIME}" ] && export LC_TIME
353 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
354 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
355 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
356 + [ -n "${LC_ALL}" ] && export LC_ALL
357 + fi
358 +
359 + einfo "You can modify the paths and options passed to initdb by editing:"
360 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
361 + einfo
362 + einfo "Information on options that can be passed to initdb are found at:"
363 + einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
364 + einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
365 + einfo
366 + einfo "PG_INITDB_OPTS is currently set to:"
367 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
368 + einfo " (none)"
369 + else
370 + einfo " ${PG_INITDB_OPTS}"
371 + fi
372 + einfo
373 + einfo "Configuration files will be installed to:"
374 + einfo " ${PGDATA}"
375 + einfo
376 + einfo "The database cluster will be created in:"
377 + einfo " ${DATA_DIR}"
378 + einfo
379 +
380 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
381 + sleep 5
382 + eend 0
383 +
384 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
385 + eerror "The given directory, '${DATA_DIR}', is not empty."
386 + eerror "Modify DATA_DIR to point to an empty directory."
387 + die "${DATA_DIR} is not empty."
388 + fi
389 +
390 + einfo "Creating the data directory ..."
391 + if [[ ${EUID} == 0 ]] ; then
392 + mkdir -p "${DATA_DIR}"
393 + chown -Rf postgres:postgres "${DATA_DIR}"
394 + chmod 0700 "${DATA_DIR}"
395 + fi
396 +
397 + einfo "Initializing the database ..."
398 +
399 + if [[ ${EUID} == 0 ]] ; then
400 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
401 + else
402 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
403 + fi
404 +
405 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
406 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
407 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
408 + fi
409 +
410 + # unix_socket_directory has no effect in postgresql.conf as it's
411 + # overridden in the initscript
412 + sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf
413 +
414 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
415 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
416 + # On the off-chance that you might need to work with UTF-8 encoded
417 + # characters in PL/Perl
418 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
419 + EOF
420 +
421 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
422 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
423 + einfo "by default. You can disable it in the cluster's:"
424 + einfo " ${PGDATA%/}/postgresql.conf"
425 + einfo
426 + einfo "The PostgreSQL server, by default, will log events to:"
427 + einfo " ${DATA_DIR%/}/postmaster.log"
428 + einfo
429 + if use prefix ; then
430 + einfo "The location of the configuration files have moved to:"
431 + einfo " ${PGDATA}"
432 + einfo "To start the server:"
433 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
434 + einfo "To stop:"
435 + einfo " pg_ctl stop -D ${DATA_DIR}"
436 + einfo
437 + einfo "Or move the configuration files back:"
438 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
439 + else
440 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
441 + einfo "instead of 'pg_ctl'."
442 + fi
443 +}
444 +
445 +src_test() {
446 + if use server && [[ ${UID} -ne 0 ]] ; then
447 + emake check
448 +
449 + einfo "If you think other tests besides the regression tests are necessary, please"
450 + einfo "submit a bug including a patch for this ebuild to enable them."
451 + else
452 + use server || \
453 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
454 + [[ ${UID} -eq 0 ]] || \
455 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
456 +
457 + ewarn 'Skipping.'
458 + fi
459 +}
460
461 diff --git a/dev-db/postgresql/postgresql-9.3.17-r1.ebuild b/dev-db/postgresql/postgresql-9.3.17-r1.ebuild
462 new file mode 100644
463 index 00000000000..32606fb69ed
464 --- /dev/null
465 +++ b/dev-db/postgresql/postgresql-9.3.17-r1.ebuild
466 @@ -0,0 +1,440 @@
467 +# Copyright 1999-2017 Gentoo Foundation
468 +# Distributed under the terms of the GNU General Public License v2
469 +
470 +EAPI="5"
471 +
472 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
473 +
474 +inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
475 + systemd user versionator
476 +
477 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
478 +
479 +SLOT="$(get_version_component_range 1-2)"
480 +
481 +SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
482 +
483 +LICENSE="POSTGRESQL GPL-2"
484 +DESCRIPTION="PostgreSQL RDBMS"
485 +HOMEPAGE="http://www.postgresql.org/"
486 +
487 +LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
488 + zh_CN zh_TW"
489 +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
490 + +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
491 +
492 +for lingua in ${LINGUAS}; do
493 + IUSE+=" linguas_${lingua}"
494 +done
495 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
496 +
497 +wanted_languages() {
498 + local enable_langs
499 +
500 + for lingua in ${LINGUAS} ; do
501 + use linguas_${lingua} && enable_langs+="${lingua} "
502 + done
503 +
504 + echo -n ${enable_langs}
505 +}
506 +
507 +CDEPEND="
508 +>=app-eselect/eselect-postgresql-2.0
509 +sys-apps/less
510 +virtual/libintl
511 +kerberos? ( virtual/krb5 )
512 +ldap? ( net-nds/openldap )
513 +pam? ( virtual/pam )
514 +perl? ( >=dev-lang/perl-5.8:= )
515 +python? ( ${PYTHON_DEPS} )
516 +readline? ( sys-libs/readline:0= )
517 +ssl? (
518 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
519 + libressl? ( dev-libs/libressl:= )
520 +)
521 +tcl? ( >=dev-lang/tcl-8:0= )
522 +uuid? ( dev-libs/ossp-uuid )
523 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
524 +zlib? ( sys-libs/zlib )
525 +"
526 +
527 +DEPEND="${CDEPEND}
528 +!!<sys-apps/sandbox-2.0
529 +sys-devel/bison
530 +sys-devel/flex
531 +nls? ( sys-devel/gettext )
532 +xml? ( virtual/pkgconfig )
533 +"
534 +
535 +RDEPEND="${CDEPEND}
536 +!dev-db/postgresql-docs:${SLOT}
537 +!dev-db/postgresql-base:${SLOT}
538 +!dev-db/postgresql-server:${SLOT}
539 +selinux? ( sec-policy/selinux-postgresql )
540 +"
541 +
542 +pkg_setup() {
543 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
544 +
545 + enewgroup postgres 70
546 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
547 +
548 + use python && python-single-r1_pkg_setup
549 +}
550 +
551 +src_prepare() {
552 + # Work around PPC{,64} compilation bug where bool is already defined
553 + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
554 +
555 + # Set proper run directory
556 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
557 + -i src/include/pg_config_manual.h || die
558 +
559 + # Rely on $PATH being in the proper order so that the correct
560 + # install program is used for modules utilizing PGXS in both
561 + # hardened and non-hardened environments. (Bug #528786)
562 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
563 +
564 + use server || epatch "${FILESDIR}/${PN}-${SLOT}-no-server.patch"
565 +
566 + # Fix bug 486556 where the server would crash at start up because of
567 + # an infinite loop caused by a self-referencing symlink.
568 + epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
569 +
570 + if use pam ; then
571 + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
572 + -i src/backend/libpq/auth.c || \
573 + die 'PGSQL_PAM_SERVICE rename failed.'
574 + fi
575 +
576 + epatch_user
577 +}
578 +
579 +src_configure() {
580 + case ${CHOST} in
581 + *-darwin*|*-solaris*)
582 + use nls && append-libs intl
583 + ;;
584 + esac
585 +
586 + export LDFLAGS_SL="${LDFLAGS}"
587 + export LDFLAGS_EX="${LDFLAGS}"
588 +
589 + local PO="${EPREFIX%/}"
590 +
591 + econf \
592 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
593 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
594 + --docdir="${PO}/usr/share/doc/${PF}" \
595 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
596 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
597 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
598 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
599 + $(use_enable !pg_legacytimestamp integer-datetimes) \
600 + $(use_enable threads thread-safety) \
601 + $(use_with kerberos gssapi) \
602 + $(use_with kerberos krb5) \
603 + $(use_with ldap) \
604 + $(use_with pam) \
605 + $(use_with perl) \
606 + $(use_with python) \
607 + $(use_with readline) \
608 + $(use_with ssl openssl) \
609 + $(use_with tcl) \
610 + $(use_with uuid ossp-uuid) \
611 + $(use_with xml libxml) \
612 + $(use_with xml libxslt) \
613 + $(use_with zlib) \
614 + "$(use_enable nls nls "$(wanted_languages)")"
615 +}
616 +
617 +src_compile() {
618 + emake
619 + emake -C contrib
620 +}
621 +
622 +src_install() {
623 + emake DESTDIR="${D}" install
624 + emake DESTDIR="${D}" install -C contrib
625 +
626 + dodoc README HISTORY doc/{TODO,bug.template}
627 +
628 + # man pages are already built, but if we have the target make them,
629 + # they'll be generated from source before being installed so we
630 + # manually install man pages.
631 + # We use ${SLOT} instead of doman for postgresql.eselect
632 + insinto /usr/share/postgresql-${SLOT}/man/
633 + doins -r doc/src/sgml/man{1,3,7}
634 + if ! use server; then
635 + # Remove man pages for non-existent binaries
636 + for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
637 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
638 + done
639 + fi
640 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
641 +
642 + insinto /etc/postgresql-${SLOT}
643 + newins src/bin/psql/psqlrc.sample psqlrc
644 +
645 + use static-libs || find "${ED}" -name '*.a' -delete
646 +
647 + local f bn
648 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
649 + -mindepth 1 -maxdepth 1)
650 + do
651 + bn=$(basename "${f}")
652 + # Temporarily tack on tmp to workaround a file collision
653 + # issue. This is only necessary for 9.7 and earlier. 10 never
654 + # had this issue.
655 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
656 + "/usr/bin/${bn}${SLOT/.}tmp"
657 + done
658 +
659 + local linkname mansec
660 + for mansec in {1,3,7} ; do
661 + for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
662 + bn=$(basename "${f}")
663 + linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
664 + dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
665 + /usr/share/man/man${mansec}/${linkname}
666 + done
667 + done
668 +
669 + if use doc ; then
670 + docinto html
671 + dodoc doc/src/sgml/html/*
672 +
673 + docinto sgml
674 + dodoc doc/src/sgml/*.{sgml,dsl}
675 + fi
676 +
677 + if use server; then
678 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
679 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
680 +
681 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
682 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
683 +
684 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
685 + "${FILESDIR}/${PN}.service" | \
686 + systemd_newunit - ${PN}-${SLOT}.service
687 +
688 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
689 +
690 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
691 +
692 + if use prefix ; then
693 + keepdir /run/postgresql
694 + fperms 0775 /run/postgresql
695 + fi
696 + fi
697 +}
698 +
699 +pkg_preinst() {
700 + # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
701 + # /usr/bin/psql96). They may have been created by the
702 + # postgresql.eselect module, but they're handled within this ebuild
703 + # now. It's alright if we momentarily delete /usr/bin/psql as it
704 + # will be recreated by the eselect module in pkg_ppostinst(). This
705 + # is only necessary for 9.7 and earlier. 10 and later were never
706 + # handled in this manner.
707 + local canonicalise
708 + if type -p realpath > /dev/null; then
709 + canonicalise=realpath
710 + elif type -p readlink > /dev/null; then
711 + canonicalise='readlink -f'
712 + else
713 + # can't die, subshell
714 + die "No readlink nor realpath found, cannot canonicalise"
715 + fi
716 +
717 + local l
718 + # First remove any symlinks in /usr/bin that may have been created
719 + # by the old eselect
720 + for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
721 + if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
722 + rm "${l}" || ewarn "Couldn't remove ${l}"
723 + fi
724 + done
725 +
726 + # Then move the symlinks created by the ebuild to their proper place.
727 + for l in "${ED}"/usr/bin/*tmp ; do
728 + mv "${l}" "${l%tmp}" \
729 + || ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
730 + done
731 +}
732 +
733 +pkg_postinst() {
734 + postgresql-config update
735 +
736 + elog "If you need a global psqlrc-file, you can place it in:"
737 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
738 +
739 + if use server ; then
740 + elog
741 + elog "Gentoo specific documentation:"
742 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
743 + elog
744 + elog "Official documentation:"
745 + elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
746 + elog
747 + elog "The default location of the Unix-domain socket is:"
748 + elog " ${EROOT%/}/run/postgresql/"
749 + elog
750 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
751 + elog "so that it contains your preferred locale in:"
752 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
753 + elog
754 + elog "Then, execute the following command to setup the initial database"
755 + elog "environment:"
756 + elog " emerge --config =${CATEGORY}/${PF}"
757 + fi
758 +}
759 +
760 +pkg_prerm() {
761 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
762 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
763 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
764 +
765 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
766 + sleep 10
767 + eend 0
768 + fi
769 +}
770 +
771 +pkg_postrm() {
772 + postgresql-config update
773 +}
774 +
775 +pkg_config() {
776 + use server || die "USE flag 'server' not enabled. Nothing to configure."
777 +
778 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
779 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
780 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
781 + [[ -z "${DATA_DIR}" ]] \
782 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
783 +
784 + # environment.bz2 may not contain the same locale as the current system
785 + # locale. Unset and source from the current system locale.
786 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
787 + unset LANG
788 + unset LC_CTYPE
789 + unset LC_NUMERIC
790 + unset LC_TIME
791 + unset LC_COLLATE
792 + unset LC_MONETARY
793 + unset LC_MESSAGES
794 + unset LC_ALL
795 + source "${EROOT%/}/etc/env.d/02locale"
796 + [ -n "${LANG}" ] && export LANG
797 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
798 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
799 + [ -n "${LC_TIME}" ] && export LC_TIME
800 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
801 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
802 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
803 + [ -n "${LC_ALL}" ] && export LC_ALL
804 + fi
805 +
806 + einfo "You can modify the paths and options passed to initdb by editing:"
807 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
808 + einfo
809 + einfo "Information on options that can be passed to initdb are found at:"
810 + einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
811 + einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
812 + einfo
813 + einfo "PG_INITDB_OPTS is currently set to:"
814 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
815 + einfo " (none)"
816 + else
817 + einfo " ${PG_INITDB_OPTS}"
818 + fi
819 + einfo
820 + einfo "Configuration files will be installed to:"
821 + einfo " ${PGDATA}"
822 + einfo
823 + einfo "The database cluster will be created in:"
824 + einfo " ${DATA_DIR}"
825 + einfo
826 +
827 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
828 + sleep 5
829 + eend 0
830 +
831 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
832 + eerror "The given directory, '${DATA_DIR}', is not empty."
833 + eerror "Modify DATA_DIR to point to an empty directory."
834 + die "${DATA_DIR} is not empty."
835 + fi
836 +
837 + einfo "Creating the data directory ..."
838 + if [[ ${EUID} == 0 ]] ; then
839 + mkdir -p "${DATA_DIR}"
840 + chown -Rf postgres:postgres "${DATA_DIR}"
841 + chmod 0700 "${DATA_DIR}"
842 + fi
843 +
844 + einfo "Initializing the database ..."
845 +
846 + if [[ ${EUID} == 0 ]] ; then
847 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
848 + else
849 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
850 + fi
851 +
852 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
853 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
854 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
855 + fi
856 +
857 + # unix_socket_directory has no effect in postgresql.conf as it's
858 + # overridden in the initscript
859 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
860 +
861 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
862 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
863 + # On the off-chance that you might need to work with UTF-8 encoded
864 + # characters in PL/Perl
865 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
866 + EOF
867 +
868 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
869 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
870 + einfo "by default. You can disable it in the cluster's:"
871 + einfo " ${PGDATA%/}/postgresql.conf"
872 + einfo
873 + einfo "The PostgreSQL server, by default, will log events to:"
874 + einfo " ${DATA_DIR%/}/postmaster.log"
875 + einfo
876 + if use prefix ; then
877 + einfo "The location of the configuration files have moved to:"
878 + einfo " ${PGDATA}"
879 + einfo "To start the server:"
880 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
881 + einfo "To stop:"
882 + einfo " pg_ctl stop -D ${DATA_DIR}"
883 + einfo
884 + einfo "Or move the configuration files back:"
885 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
886 + else
887 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
888 + einfo "instead of 'pg_ctl'."
889 + fi
890 +}
891 +
892 +src_test() {
893 + if use server && [[ ${UID} -ne 0 ]] ; then
894 + emake check
895 +
896 + einfo "If you think other tests besides the regression tests are necessary, please"
897 + einfo "submit a bug including a patch for this ebuild to enable them."
898 + else
899 + use server || \
900 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
901 + [[ ${UID} -eq 0 ]] || \
902 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
903 +
904 + ewarn 'Skipping.'
905 + fi
906 +}
907
908 diff --git a/dev-db/postgresql/postgresql-9.4.12-r1.ebuild b/dev-db/postgresql/postgresql-9.4.12-r1.ebuild
909 new file mode 100644
910 index 00000000000..e46feae1864
911 --- /dev/null
912 +++ b/dev-db/postgresql/postgresql-9.4.12-r1.ebuild
913 @@ -0,0 +1,472 @@
914 +# Copyright 1999-2017 Gentoo Foundation
915 +# Distributed under the terms of the GNU General Public License v2
916 +
917 +EAPI="5"
918 +
919 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
920 +
921 +inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \
922 + systemd user versionator
923 +
924 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
925 +
926 +SLOT="$(get_version_component_range 1-2)"
927 +
928 +SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
929 +
930 +LICENSE="POSTGRESQL GPL-2"
931 +DESCRIPTION="PostgreSQL RDBMS"
932 +HOMEPAGE="http://www.postgresql.org/"
933 +
934 +LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr
935 + zh_CN zh_TW"
936 +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python
937 + +readline selinux +server ssl static-libs tcl threads uuid xml zlib"
938 +
939 +for lingua in ${LINGUAS}; do
940 + IUSE+=" linguas_${lingua}"
941 +done
942 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
943 +
944 +wanted_languages() {
945 + local enable_langs
946 +
947 + for lingua in ${LINGUAS} ; do
948 + use linguas_${lingua} && enable_langs+="${lingua} "
949 + done
950 +
951 + echo -n ${enable_langs}
952 +}
953 +
954 +CDEPEND="
955 +>=app-eselect/eselect-postgresql-2.0
956 +sys-apps/less
957 +virtual/libintl
958 +kerberos? ( virtual/krb5 )
959 +ldap? ( net-nds/openldap )
960 +pam? ( virtual/pam )
961 +perl? ( >=dev-lang/perl-5.8:= )
962 +python? ( ${PYTHON_DEPS} )
963 +readline? ( sys-libs/readline:0= )
964 +ssl? (
965 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
966 + libressl? ( dev-libs/libressl:= )
967 +)
968 +tcl? ( >=dev-lang/tcl-8:0= )
969 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
970 +zlib? ( sys-libs/zlib )
971 +"
972 +
973 +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
974 +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
975 +# the libc includes UUID functions.
976 +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
977 +BSD_LIBC=( elibc_{Free,Net,Open}BSD )
978 +
979 +nest_usedep() {
980 + local front back
981 + while [[ ${#} -gt 1 ]]; do
982 + front+="${1}? ( "
983 + back+=" )"
984 + shift
985 + done
986 + echo "${front}${1}${back}"
987 +}
988 +
989 +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
990 +CDEPEND+="
991 +uuid? (
992 + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
993 + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
994 +)"
995 +
996 +DEPEND="${CDEPEND}
997 +!!<sys-apps/sandbox-2.0
998 +sys-devel/bison
999 +sys-devel/flex
1000 +nls? ( sys-devel/gettext )
1001 +xml? ( virtual/pkgconfig )
1002 +"
1003 +
1004 +RDEPEND="${CDEPEND}
1005 +!dev-db/postgresql-docs:${SLOT}
1006 +!dev-db/postgresql-base:${SLOT}
1007 +!dev-db/postgresql-server:${SLOT}
1008 +selinux? ( sec-policy/selinux-postgresql )
1009 +"
1010 +
1011 +pkg_setup() {
1012 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
1013 +
1014 + enewgroup postgres 70
1015 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
1016 +
1017 + use python && python-single-r1_pkg_setup
1018 +}
1019 +
1020 +src_prepare() {
1021 + # Work around PPC{,64} compilation bug where bool is already defined
1022 + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
1023 +
1024 + # Set proper run directory
1025 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
1026 + -i src/include/pg_config_manual.h || die
1027 +
1028 + # Rely on $PATH being in the proper order so that the correct
1029 + # install program is used for modules utilizing PGXS in both
1030 + # hardened and non-hardened environments. (Bug #528786)
1031 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
1032 +
1033 + use server || epatch "${FILESDIR}/${PN}-9.4.10-no-server.patch"
1034 +
1035 + # Fix bug 486556 where the server would crash at start up because of
1036 + # an infinite loop caused by a self-referencing symlink.
1037 + epatch "${FILESDIR}/postgresql-9.2-9.4-tz-dir-overflow.patch"
1038 +
1039 + if use pam ; then
1040 + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
1041 + -i src/backend/libpq/auth.c || \
1042 + die 'PGSQL_PAM_SERVICE rename failed.'
1043 + fi
1044 +
1045 + epatch_user
1046 +}
1047 +
1048 +src_configure() {
1049 + case ${CHOST} in
1050 + *-darwin*|*-solaris*)
1051 + use nls && append-libs intl
1052 + ;;
1053 + esac
1054 +
1055 + export LDFLAGS_SL="${LDFLAGS}"
1056 + export LDFLAGS_EX="${LDFLAGS}"
1057 +
1058 + local PO="${EPREFIX%/}"
1059 +
1060 + local i uuid_config=""
1061 + if use uuid; then
1062 + for i in ${UTIL_LINUX_LIBC[@]}; do
1063 + use ${i} && uuid_config="--with-uuid=e2fs"
1064 + done
1065 + for i in ${BSD_LIBC[@]}; do
1066 + use ${i} && uuid_config="--with-uuid=bsd"
1067 + done
1068 + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
1069 + fi
1070 +
1071 + econf \
1072 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
1073 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
1074 + --docdir="${PO}/usr/share/doc/${PF}" \
1075 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
1076 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
1077 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
1078 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
1079 + $(use_enable !pg_legacytimestamp integer-datetimes) \
1080 + $(use_enable threads thread-safety) \
1081 + $(use_with kerberos gssapi) \
1082 + $(use_with ldap) \
1083 + $(use_with pam) \
1084 + $(use_with perl) \
1085 + $(use_with python) \
1086 + $(use_with readline) \
1087 + $(use_with ssl openssl) \
1088 + $(use_with tcl) \
1089 + ${uuid_config} \
1090 + $(use_with xml libxml) \
1091 + $(use_with xml libxslt) \
1092 + $(use_with zlib) \
1093 + "$(use_enable nls nls "$(wanted_languages)")"
1094 +}
1095 +
1096 +src_compile() {
1097 + emake
1098 + emake -C contrib
1099 +}
1100 +
1101 +src_install() {
1102 + emake DESTDIR="${D}" install
1103 + emake DESTDIR="${D}" install -C contrib
1104 +
1105 + dodoc README HISTORY doc/{TODO,bug.template}
1106 +
1107 + # man pages are already built, but if we have the target make them,
1108 + # they'll be generated from source before being installed so we
1109 + # manually install man pages.
1110 + # We use ${SLOT} instead of doman for postgresql.eselect
1111 + insinto /usr/share/postgresql-${SLOT}/man/
1112 + doins -r doc/src/sgml/man{1,3,7}
1113 + if ! use server; then
1114 + # Remove man pages for non-existent binaries
1115 + for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
1116 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
1117 + done
1118 + fi
1119 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
1120 +
1121 + insinto /etc/postgresql-${SLOT}
1122 + newins src/bin/psql/psqlrc.sample psqlrc
1123 +
1124 + use static-libs || find "${ED}" -name '*.a' -delete
1125 +
1126 + local f bn
1127 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
1128 + -mindepth 1 -maxdepth 1)
1129 + do
1130 + bn=$(basename "${f}")
1131 + # Temporarily tack on tmp to workaround a file collision
1132 + # issue. This is only necessary for 9.7 and earlier. 10 never
1133 + # had this issue.
1134 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
1135 + "/usr/bin/${bn}${SLOT/.}tmp"
1136 + done
1137 +
1138 + local linkname mansec
1139 + for mansec in {1,3,7} ; do
1140 + for f in "${ED}"/usr/share/postgresql-${SLOT}/man/man${mansec}/* ; do
1141 + bn=$(basename "${f}")
1142 + linkname=${bn/%.${mansec}/${SLOT/.}.${mansec}}
1143 + dosym ../../postgresql-${SLOT}/man/man${mansec}/$bn \
1144 + /usr/share/man/man${mansec}/${linkname}
1145 + done
1146 + done
1147 +
1148 + if use doc ; then
1149 + docinto html
1150 + dodoc doc/src/sgml/html/*
1151 +
1152 + docinto sgml
1153 + dodoc doc/src/sgml/*.{sgml,dsl}
1154 + fi
1155 +
1156 + if use server; then
1157 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1158 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
1159 +
1160 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1161 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
1162 +
1163 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1164 + "${FILESDIR}/${PN}.service" | \
1165 + systemd_newunit - ${PN}-${SLOT}.service
1166 +
1167 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
1168 +
1169 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
1170 +
1171 + if use prefix ; then
1172 + keepdir /run/postgresql
1173 + fperms 0775 /run/postgresql
1174 + fi
1175 + fi
1176 +}
1177 +
1178 +pkg_preinst() {
1179 + # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
1180 + # /usr/bin/psql96). They may have been created by the
1181 + # postgresql.eselect module, but they're handled within this ebuild
1182 + # now. It's alright if we momentarily delete /usr/bin/psql as it
1183 + # will be recreated by the eselect module in pkg_ppostinst(). This
1184 + # is only necessary for 9.7 and earlier. 10 and later were never
1185 + # handled in this manner.
1186 + local canonicalise
1187 + if type -p realpath > /dev/null; then
1188 + canonicalise=realpath
1189 + elif type -p readlink > /dev/null; then
1190 + canonicalise='readlink -f'
1191 + else
1192 + # can't die, subshell
1193 + die "No readlink nor realpath found, cannot canonicalise"
1194 + fi
1195 +
1196 + local l
1197 + # First remove any symlinks in /usr/bin that may have been created
1198 + # by the old eselect
1199 + for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
1200 + if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
1201 + rm "${l}" || ewarn "Couldn't remove ${l}"
1202 + fi
1203 + done
1204 +
1205 + # Then move the symlinks created by the ebuild to their proper place.
1206 + for l in "${ED}"/usr/bin/*tmp ; do
1207 + mv "${l}" "${l%tmp}" \
1208 + || ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
1209 + done
1210 +}
1211 +
1212 +pkg_postinst() {
1213 + postgresql-config update
1214 +
1215 + elog "If you need a global psqlrc-file, you can place it in:"
1216 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
1217 +
1218 + if use server ; then
1219 + elog
1220 + elog "Gentoo specific documentation:"
1221 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
1222 + elog
1223 + elog "Official documentation:"
1224 + elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
1225 + elog
1226 + elog "The default location of the Unix-domain socket is:"
1227 + elog " ${EROOT%/}/run/postgresql/"
1228 + elog
1229 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
1230 + elog "so that it contains your preferred locale in:"
1231 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1232 + elog
1233 + elog "Then, execute the following command to setup the initial database"
1234 + elog "environment:"
1235 + elog " emerge --config =${CATEGORY}/${PF}"
1236 + fi
1237 +}
1238 +
1239 +pkg_prerm() {
1240 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
1241 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
1242 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
1243 +
1244 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
1245 + sleep 10
1246 + eend 0
1247 + fi
1248 +}
1249 +
1250 +pkg_postrm() {
1251 + postgresql-config update
1252 +}
1253 +
1254 +pkg_config() {
1255 + use server || die "USE flag 'server' not enabled. Nothing to configure."
1256 +
1257 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
1258 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1259 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
1260 + [[ -z "${DATA_DIR}" ]] \
1261 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
1262 +
1263 + # environment.bz2 may not contain the same locale as the current system
1264 + # locale. Unset and source from the current system locale.
1265 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
1266 + unset LANG
1267 + unset LC_CTYPE
1268 + unset LC_NUMERIC
1269 + unset LC_TIME
1270 + unset LC_COLLATE
1271 + unset LC_MONETARY
1272 + unset LC_MESSAGES
1273 + unset LC_ALL
1274 + source "${EROOT%/}/etc/env.d/02locale"
1275 + [ -n "${LANG}" ] && export LANG
1276 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
1277 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
1278 + [ -n "${LC_TIME}" ] && export LC_TIME
1279 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
1280 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
1281 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
1282 + [ -n "${LC_ALL}" ] && export LC_ALL
1283 + fi
1284 +
1285 + einfo "You can modify the paths and options passed to initdb by editing:"
1286 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1287 + einfo
1288 + einfo "Information on options that can be passed to initdb are found at:"
1289 + einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
1290 + einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
1291 + einfo
1292 + einfo "PG_INITDB_OPTS is currently set to:"
1293 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
1294 + einfo " (none)"
1295 + else
1296 + einfo " ${PG_INITDB_OPTS}"
1297 + fi
1298 + einfo
1299 + einfo "Configuration files will be installed to:"
1300 + einfo " ${PGDATA}"
1301 + einfo
1302 + einfo "The database cluster will be created in:"
1303 + einfo " ${DATA_DIR}"
1304 + einfo
1305 +
1306 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
1307 + sleep 5
1308 + eend 0
1309 +
1310 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
1311 + eerror "The given directory, '${DATA_DIR}', is not empty."
1312 + eerror "Modify DATA_DIR to point to an empty directory."
1313 + die "${DATA_DIR} is not empty."
1314 + fi
1315 +
1316 + einfo "Creating the data directory ..."
1317 + if [[ ${EUID} == 0 ]] ; then
1318 + mkdir -p "${DATA_DIR}"
1319 + chown -Rf postgres:postgres "${DATA_DIR}"
1320 + chmod 0700 "${DATA_DIR}"
1321 + fi
1322 +
1323 + einfo "Initializing the database ..."
1324 +
1325 + if [[ ${EUID} == 0 ]] ; then
1326 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
1327 + else
1328 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
1329 + fi
1330 +
1331 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
1332 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
1333 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
1334 + fi
1335 +
1336 + # unix_socket_directory has no effect in postgresql.conf as it's
1337 + # overridden in the initscript
1338 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
1339 +
1340 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
1341 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
1342 + # On the off-chance that you might need to work with UTF-8 encoded
1343 + # characters in PL/Perl
1344 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
1345 + EOF
1346 +
1347 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
1348 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
1349 + einfo "by default. You can disable it in the cluster's:"
1350 + einfo " ${PGDATA%/}/postgresql.conf"
1351 + einfo
1352 + einfo "The PostgreSQL server, by default, will log events to:"
1353 + einfo " ${DATA_DIR%/}/postmaster.log"
1354 + einfo
1355 + if use prefix ; then
1356 + einfo "The location of the configuration files have moved to:"
1357 + einfo " ${PGDATA}"
1358 + einfo "To start the server:"
1359 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
1360 + einfo "To stop:"
1361 + einfo " pg_ctl stop -D ${DATA_DIR}"
1362 + einfo
1363 + einfo "Or move the configuration files back:"
1364 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
1365 + else
1366 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
1367 + einfo "instead of 'pg_ctl'."
1368 + fi
1369 +}
1370 +
1371 +src_test() {
1372 + if use server && [[ ${UID} -ne 0 ]] ; then
1373 + emake check
1374 +
1375 + einfo "If you think other tests besides the regression tests are necessary, please"
1376 + einfo "submit a bug including a patch for this ebuild to enable them."
1377 + else
1378 + use server || \
1379 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
1380 + [[ ${UID} -eq 0 ]] || \
1381 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
1382 +
1383 + ewarn 'Skipping.'
1384 + fi
1385 +}