Gentoo Archives: gentoo-commits

From: Patrick Lauer <patrick@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/postgresql/
Date: Fri, 15 Feb 2019 18:39:54
Message-Id: 1550255976.1c87823b986c8b2ac3c32d1d74556d98a2c8f699.patrick@gentoo
1 commit: 1c87823b986c8b2ac3c32d1d74556d98a2c8f699
2 Author: Patrick Lauer <patrick <AT> gentoo <DOT> org>
3 AuthorDate: Fri Feb 15 18:18:05 2019 +0000
4 Commit: Patrick Lauer <patrick <AT> gentoo <DOT> org>
5 CommitDate: Fri Feb 15 18:39:36 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c87823b
7
8 dev-db/postgresql: Bump
9
10 Package-Manager: Portage-2.3.60, Repoman-2.3.12
11 X-Autogenerated-SOB: Yes
12 Signed-off-by: Patrick Lauer <patrick <AT> gentoo.org>
13
14 dev-db/postgresql/Manifest | 6 +
15 dev-db/postgresql/postgresql-10.7.ebuild | 460 +++++++++++++++++++++++++++
16 dev-db/postgresql/postgresql-11.2.ebuild | 460 +++++++++++++++++++++++++++
17 dev-db/postgresql/postgresql-11_rc1.ebuild | 452 +++++++++++++++++++++++++++
18 dev-db/postgresql/postgresql-9.4.21.ebuild | 475 ++++++++++++++++++++++++++++
19 dev-db/postgresql/postgresql-9.5.16.ebuild | 481 ++++++++++++++++++++++++++++
20 dev-db/postgresql/postgresql-9.6.12.ebuild | 486 +++++++++++++++++++++++++++++
21 7 files changed, 2820 insertions(+)
22
23 diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest
24 index 5bd7dae2ced..d83030107ef 100644
25 --- a/dev-db/postgresql/Manifest
26 +++ b/dev-db/postgresql/Manifest
27 @@ -1,6 +1,12 @@
28 DIST postgresql-10.6.tar.bz2 20350612 BLAKE2B b751085b8fce73efb2531378a553c8c956f5e05a0002de8fdc58c0f2a6cf2b9dfaff6bd621047a094a51e459bc8fc5b1658d6a754a396fa3b7aedc1024ea3b4c SHA512 5d4d5cee2a19ad1820c3411bc4851904e3059cdcacc837350694d54d7d59260b66c565c72cc14a3a10541a8fc49c5185f08f57b7a8c7e4c64ed2614da6e1201f
29 +DIST postgresql-10.7.tar.bz2 18940030 BLAKE2B ce02d2c4ba97c1845b3708941bb7a9f6ee025fc4a881e35790279aadf5e35464d6716cfdeb4ad145ce4549e639ad01d333cff858f956607c0cd583af65f1cd3e SHA512 2fa8194e9ef540930eecc2a43907a77f7f185590046350d48fd625bdb1ab459095c4e2e0d2faac846935d7231ac672ace760633deeee365572768da619458ba9
30 DIST postgresql-11.1.tar.bz2 21263173 BLAKE2B d762b6e8b0e7b08b16ed252687118a0a4516172e38e8940879fd050f72d19ff045af949e72977a62c2ce0a788af7d42c9bde7748347566bec3694e337bba6f73 SHA512 35d00984e9f5f063a5b96e97aa1b40381ab76d07b2336bda5981fd80bef1324f56eefca5069ae78770ecd6ece5df85264e599fdb3478ecb71d4fdd0d7b6becca
31 +DIST postgresql-11.2.tar.bz2 19714229 BLAKE2B 459674c08a0435363da29428bef7ec49a012b534b390ce6addafac000ce58ad0ad7ba4e1522f5279da29535399836971c61536827d481af766322935d7c6d01b SHA512 dae00a543fdeed36bc338abd4ccfd9fe9a8b6b2b7eaa00b1078e4f27802de75a461c27da2800bc9dd64e658681e5787bd03764bde79940656cae1e8c8716f011
32 +DIST postgresql-11rc1.tar.bz2 21193201 BLAKE2B 4ed52937f23d4be92a8b357b608c48b3ee23980269b9a8f88315d2c0019725093087332518d4418592f24b6ab167cc04cb7e9f1c005b9dcb585945e970ea0930 SHA512 a03229b55ae632a7f2bc9f32e918cd38f6bbf8555e50355f50a913790650f2efbb56fab47ed6d3dfe9847d0bd20cb50c27aa9456d2c38ce8e32d3c845ba573c6
33 DIST postgresql-9.3.25.tar.bz2 17067593 BLAKE2B fd9ca5685e5511dcaa72da882b674846dcd5a16227e5b33ae06701fe7881df71847666c37925033c6cb01c916111a8f76df134491645f4d1e1dd48a008bd2831 SHA512 319e12b73853b74f5ef2c520d64795bb586ffd495ceab6518f7844de6e0a054aea821976c470108d346f8090c7d3949920d9c435432e33004b7caa7a77a5cdca
34 DIST postgresql-9.4.20.tar.bz2 17905682 BLAKE2B cb65228f8e78dc8b6303a06480a68de58ecac1fefa1342e4563f2c4051c9f5506b366b36c2dbd54207d25ae497625f8fc5e3e771174a6b3ec33c3c19d2c9ea08 SHA512 664c6e97979f38d263d1dc75a7db442f193a230435cad43ddfa2afcd42ac0d73b2aef0e846fddcc9008cd6d89cba2d5c0a4db93b111665646d3ff4d8f6fbe1e8
35 +DIST postgresql-9.4.21.tar.bz2 16871522 BLAKE2B e6b8957f52a95d5fa56bc39756f1de83459882e40eee07c3ddf9e33eab39a0d61ee492864a920e7714ca1914a772dcc9048bc34072349197597cfb116aa94422 SHA512 850d1f59369457d9a8a42de8f0e4811f60e9164d2e7d7605fdabc04cc5ba2e3794d51e155d709419d06b8e070f214f7d3ef2328c6d37f125264ea008ca18ff5a
36 DIST postgresql-9.5.15.tar.bz2 18707696 BLAKE2B f1be26085953d5a15a6545aed3527b9eec6eb57c72f2e05401e43200e628b3a42ee824dd1cb0138556b97fe4922a991489dffa77329b653475874766c1d5b944 SHA512 2ea241b6751a2812c689da9bde40151ebb7cdabdd14e93d92f8bea1e3fcf5bc0d4854834999f33270329e22a09c5aeaf8d59d36ca6e8860704f81f3adcfb30d5
37 +DIST postgresql-9.5.16.tar.bz2 17506874 BLAKE2B ce5c804315ce5d7ac95af2455322801f581c3aa8e943ffae40b7e14a95a4610b71956568a418f2f22b8a9814ff9fd1f9296efc974716c0096aa22dcdb7609ff7 SHA512 4583c825ed00a5ba915863b41c39cd9580492444ff299e44c3856db55fb4f0607d184534fe8977d915fb0730e6d638d8560be11915ce21b9d1f6971e7a285c7c
38 DIST postgresql-9.6.11.tar.bz2 20009048 BLAKE2B aa3e5b1e63c983226ea71737982e62eaff655af7e0f55f20ec886f5d7406b1e30e2fe5378b0dd1ef59e777f862ccc2386121653853d4c186a1b4853a9bbb1591 SHA512 a4314f92d1a661af4076d8c120533ecae76d91461043b8a6ad22dd6e5b562e0bf019bc7f3157a26d9666ba5866e254613ae5b690310168b029795dc088f8c060
39 +DIST postgresql-9.6.12.tar.bz2 18759442 BLAKE2B 067b307318f65616651ee4502f420a84df26e906350f07ce5ab4a769608075f0d017b6d84b0ce5045662ab379e236b66cf751f7950d026f011d0915efcdfab3e SHA512 3a7a96caf682461f1f9bffdbe2b72b1ce00cc6680145e00c139e4af8b9dc8b8679fda1626de65921d6e187fa9290efc930584b98f1fd2aba1ba3d790a741a415
40
41 diff --git a/dev-db/postgresql/postgresql-10.7.ebuild b/dev-db/postgresql/postgresql-10.7.ebuild
42 new file mode 100644
43 index 00000000000..905d15e3105
44 --- /dev/null
45 +++ b/dev-db/postgresql/postgresql-10.7.ebuild
46 @@ -0,0 +1,460 @@
47 +# Copyright 1999-2019 Gentoo Authors
48 +# Distributed under the terms of the GNU General Public License v2
49 +
50 +EAPI="6"
51 +
52 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
53 +
54 +PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
55 + zh_TW"
56 +
57 +inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
58 + systemd user versionator
59 +
60 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
61 +
62 +SLOT=$(get_major_version)
63 +
64 +MY_PV=${PV/_/}
65 +S="${WORKDIR}/${PN}-${MY_PV}"
66 +
67 +SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
68 +
69 +LICENSE="POSTGRESQL GPL-2"
70 +DESCRIPTION="PostgreSQL RDBMS"
71 +HOMEPAGE="https://www.postgresql.org/"
72 +
73 +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl python +readline
74 + selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
75 +
76 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
77 +
78 +CDEPEND="
79 +>=app-eselect/eselect-postgresql-2.0
80 +sys-apps/less
81 +virtual/libintl
82 +kerberos? ( virtual/krb5 )
83 +ldap? ( net-nds/openldap )
84 +pam? ( virtual/pam )
85 +perl? ( >=dev-lang/perl-5.8:= )
86 +python? ( ${PYTHON_DEPS} )
87 +readline? ( sys-libs/readline:0= )
88 +server? ( systemd? ( sys-apps/systemd ) )
89 +ssl? (
90 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
91 + libressl? ( dev-libs/libressl:= )
92 +)
93 +tcl? ( >=dev-lang/tcl-8:0= )
94 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
95 +zlib? ( sys-libs/zlib )
96 +"
97 +
98 +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
99 +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
100 +# the libc includes UUID functions.
101 +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
102 +BSD_LIBC=( elibc_{Free,Net,Open}BSD )
103 +
104 +nest_usedep() {
105 + local front back
106 + while [[ ${#} -gt 1 ]]; do
107 + front+="${1}? ( "
108 + back+=" )"
109 + shift
110 + done
111 + echo "${front}${1}${back}"
112 +}
113 +
114 +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
115 +CDEPEND+="
116 +uuid? (
117 + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
118 + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
119 +)"
120 +
121 +DEPEND="${CDEPEND}
122 +!!<sys-apps/sandbox-2.0
123 +sys-devel/bison
124 +sys-devel/flex
125 +nls? ( sys-devel/gettext )
126 +xml? ( virtual/pkgconfig )
127 +"
128 +
129 +RDEPEND="${CDEPEND}
130 +!dev-db/postgresql-docs:${SLOT}
131 +!dev-db/postgresql-base:${SLOT}
132 +!dev-db/postgresql-server:${SLOT}
133 +selinux? ( sec-policy/selinux-postgresql )
134 +"
135 +
136 +pkg_setup() {
137 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
138 +
139 + enewgroup postgres 70
140 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
141 +
142 + use python && python-single-r1_pkg_setup
143 +}
144 +
145 +src_prepare() {
146 + # Work around PPC{,64} compilation bug where bool is already defined
147 + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
148 +
149 + # Set proper run directory
150 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
151 + -i src/include/pg_config_manual.h || die
152 +
153 + # Rely on $PATH being in the proper order so that the correct
154 + # install program is used for modules utilizing PGXS in both
155 + # hardened and non-hardened environments. (Bug #528786)
156 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
157 +
158 + use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch"
159 +
160 + if use pam ; then
161 + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
162 + -i src/backend/libpq/auth.c || \
163 + die 'PGSQL_PAM_SERVICE rename failed.'
164 + fi
165 +
166 + eapply_user
167 +}
168 +
169 +src_configure() {
170 + case ${CHOST} in
171 + *-darwin*|*-solaris*)
172 + use nls && append-libs intl
173 + ;;
174 + esac
175 +
176 + export LDFLAGS_SL="${LDFLAGS}"
177 + export LDFLAGS_EX="${LDFLAGS}"
178 +
179 + local PO="${EPREFIX%/}"
180 +
181 + local i uuid_config=""
182 + if use uuid; then
183 + for i in ${UTIL_LINUX_LIBC[@]}; do
184 + use ${i} && uuid_config="--with-uuid=e2fs"
185 + done
186 + for i in ${BSD_LIBC[@]}; do
187 + use ${i} && uuid_config="--with-uuid=bsd"
188 + done
189 + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
190 + fi
191 +
192 + econf \
193 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
194 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
195 + --docdir="${PO}/usr/share/doc/${PF}" \
196 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
197 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
198 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
199 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
200 + $(use_enable !alpha spinlocks) \
201 + $(use_enable threads thread-safety) \
202 + $(use_with kerberos gssapi) \
203 + $(use_with ldap) \
204 + $(use_with pam) \
205 + $(use_with perl) \
206 + $(use_with python) \
207 + $(use_with readline) \
208 + $(use_with ssl openssl) \
209 + $(usex server "$(use_with systemd)" '--without-systemd') \
210 + $(use_with tcl) \
211 + ${uuid_config} \
212 + $(use_with xml libxml) \
213 + $(use_with xml libxslt) \
214 + $(use_with zlib) \
215 + $(use_enable nls nls "'$(l10n_get_locales)'")
216 +}
217 +
218 +src_compile() {
219 + emake
220 + emake -C contrib
221 +}
222 +
223 +src_install() {
224 + emake DESTDIR="${D}" install
225 + emake DESTDIR="${D}" install -C contrib
226 +
227 + dodoc README HISTORY doc/{TODO,bug.template}
228 +
229 + # man pages are already built, but if we have the target make them,
230 + # they'll be generated from source before being installed so we
231 + # manually install man pages.
232 + # We use ${SLOT} instead of doman for postgresql.eselect
233 + insinto /usr/share/postgresql-${SLOT}/man/
234 + doins -r doc/src/sgml/man{1,3,7}
235 + if ! use server; then
236 + # Remove man pages for non-existent binaries
237 + serverman=(
238 + initdb
239 + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
240 + pg_{test_{fsync,timing},upgrade,waldump}
241 + post{gres,master}
242 + )
243 + for m in ${serverman[@]} ; do
244 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
245 + done
246 + fi
247 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
248 +
249 + # Create slot specific man pages
250 + local bn f mansec slotted_name
251 + for mansec in 1 3 7 ; do
252 + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
253 +
254 + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
255 + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
256 +
257 + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
258 + bn=$(basename "${f}")
259 + slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
260 + case ${bn} in
261 + TABLE.7|WITH.7)
262 + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
263 + ;;
264 + *)
265 + echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
266 + ;;
267 + esac
268 + done
269 +
270 + popd > /dev/null
271 + done
272 +
273 + insinto /etc/postgresql-${SLOT}
274 + newins src/bin/psql/psqlrc.sample psqlrc
275 +
276 + use static-libs || find "${ED}" -name '*.a' -delete
277 +
278 + local f bn
279 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
280 + -mindepth 1 -maxdepth 1)
281 + do
282 + bn=$(basename "${f}")
283 + # Temporarily tack on tmp to workaround a file collision
284 + # issue. This is only necessary for 9.7 and earlier. 10 never
285 + # had this issue.
286 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
287 + "/usr/bin/${bn}${SLOT/.}"
288 + done
289 +
290 + if use doc ; then
291 + docinto html
292 + dodoc doc/src/sgml/html/*
293 + fi
294 +
295 + if use server; then
296 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
297 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
298 +
299 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
300 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
301 +
302 + if use systemd; then
303 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
304 + "${FILESDIR}/${PN}.service-9.6-r1" | \
305 + systemd_newunit - ${PN}-${SLOT}.service
306 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
307 + systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
308 + fi
309 +
310 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
311 +
312 + if use prefix ; then
313 + keepdir /run/postgresql
314 + fperms 1775 /run/postgresql
315 + fi
316 + fi
317 +}
318 +
319 +pkg_postinst() {
320 + use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
321 + postgresql-config update
322 +
323 + elog "If you need a global psqlrc-file, you can place it in:"
324 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
325 +
326 + if use server ; then
327 + elog
328 + elog "Gentoo specific documentation:"
329 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
330 + elog
331 + elog "Official documentation:"
332 + elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
333 + elog
334 + elog "The default location of the Unix-domain socket is:"
335 + elog " ${EROOT%/}/run/postgresql/"
336 + elog
337 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
338 + elog "so that it contains your preferred locale in:"
339 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
340 + elog
341 + elog "Then, execute the following command to setup the initial database"
342 + elog "environment:"
343 + elog " emerge --config =${CATEGORY}/${PF}"
344 +
345 + if [[ -n ${REPLACING_VERSIONS} ]] ; then
346 + ewarn "If your system is using 'pg_stat_statements' and you are running a"
347 + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
348 + ewarn "the following command after upgrading:"
349 + ewarn
350 + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
351 + fi
352 + fi
353 +}
354 +
355 +pkg_prerm() {
356 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
357 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
358 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
359 +
360 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
361 + sleep 10
362 + eend 0
363 + fi
364 +}
365 +
366 +pkg_postrm() {
367 + postgresql-config update
368 +}
369 +
370 +pkg_config() {
371 + use server || die "USE flag 'server' not enabled. Nothing to configure."
372 +
373 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
374 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
375 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
376 + [[ -z "${DATA_DIR}" ]] \
377 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
378 +
379 + # environment.bz2 may not contain the same locale as the current system
380 + # locale. Unset and source from the current system locale.
381 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
382 + unset LANG
383 + unset LC_CTYPE
384 + unset LC_NUMERIC
385 + unset LC_TIME
386 + unset LC_COLLATE
387 + unset LC_MONETARY
388 + unset LC_MESSAGES
389 + unset LC_ALL
390 + source "${EROOT%/}/etc/env.d/02locale"
391 + [ -n "${LANG}" ] && export LANG
392 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
393 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
394 + [ -n "${LC_TIME}" ] && export LC_TIME
395 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
396 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
397 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
398 + [ -n "${LC_ALL}" ] && export LC_ALL
399 + fi
400 +
401 + einfo "You can modify the paths and options passed to initdb by editing:"
402 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
403 + einfo
404 + einfo "Information on options that can be passed to initdb are found at:"
405 + einfo " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
406 + einfo " https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
407 + einfo
408 + einfo "PG_INITDB_OPTS is currently set to:"
409 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
410 + einfo " (none)"
411 + else
412 + einfo " ${PG_INITDB_OPTS}"
413 + fi
414 + einfo
415 + einfo "Configuration files will be installed to:"
416 + einfo " ${PGDATA}"
417 + einfo
418 + einfo "The database cluster will be created in:"
419 + einfo " ${DATA_DIR}"
420 + einfo
421 +
422 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
423 + sleep 5
424 + eend 0
425 +
426 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
427 + eerror "The given directory, '${DATA_DIR}', is not empty."
428 + eerror "Modify DATA_DIR to point to an empty directory."
429 + die "${DATA_DIR} is not empty."
430 + fi
431 +
432 + einfo "Creating the data directory ..."
433 + if [[ ${EUID} == 0 ]] ; then
434 + mkdir -p "${DATA_DIR}"
435 + chown -Rf postgres:postgres "${DATA_DIR}"
436 + chmod 0700 "${DATA_DIR}"
437 + fi
438 +
439 + einfo "Initializing the database ..."
440 +
441 + if [[ ${EUID} == 0 ]] ; then
442 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
443 + else
444 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
445 + fi
446 +
447 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
448 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
449 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
450 + fi
451 +
452 + # unix_socket_directory has no effect in postgresql.conf as it's
453 + # overridden in the initscript
454 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
455 +
456 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
457 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
458 + # On the off-chance that you might need to work with UTF-8 encoded
459 + # characters in PL/Perl
460 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
461 + EOF
462 +
463 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
464 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
465 + einfo "by default. You can disable it in the cluster's:"
466 + einfo " ${PGDATA%/}/postgresql.conf"
467 + einfo
468 + if ! use systemd; then
469 + einfo "The PostgreSQL server, by default, will log events to:"
470 + einfo " ${DATA_DIR%/}/postmaster.log"
471 + einfo
472 + fi
473 + if use prefix ; then
474 + einfo "The location of the configuration files have moved to:"
475 + einfo " ${PGDATA}"
476 + einfo "To start the server:"
477 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
478 + einfo "To stop:"
479 + einfo " pg_ctl stop -D ${DATA_DIR}"
480 + einfo
481 + einfo "Or move the configuration files back:"
482 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
483 + elif use systemd; then
484 + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
485 + einfo "instead of 'pg_ctl'."
486 + else
487 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
488 + einfo "instead of 'pg_ctl'."
489 + fi
490 +}
491 +
492 +src_test() {
493 + if use server && [[ ${UID} -ne 0 ]] ; then
494 + emake check
495 +
496 + einfo "If you think other tests besides the regression tests are necessary, please"
497 + einfo "submit a bug including a patch for this ebuild to enable them."
498 + else
499 + use server || \
500 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
501 + [[ ${UID} -eq 0 ]] || \
502 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
503 +
504 + ewarn 'Skipping.'
505 + fi
506 +}
507
508 diff --git a/dev-db/postgresql/postgresql-11.2.ebuild b/dev-db/postgresql/postgresql-11.2.ebuild
509 new file mode 100644
510 index 00000000000..f19bc98f9e9
511 --- /dev/null
512 +++ b/dev-db/postgresql/postgresql-11.2.ebuild
513 @@ -0,0 +1,460 @@
514 +# Copyright 1999-2019 Gentoo Authors
515 +# Distributed under the terms of the GNU General Public License v2
516 +
517 +EAPI="6"
518 +
519 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
520 +
521 +PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
522 + zh_TW"
523 +
524 +inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
525 + systemd user versionator
526 +
527 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
528 +
529 +SLOT=$(get_major_version)
530 +
531 +MY_PV=${PV/_/}
532 +S="${WORKDIR}/${PN}-${MY_PV}"
533 +
534 +SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
535 +
536 +LICENSE="POSTGRESQL GPL-2"
537 +DESCRIPTION="PostgreSQL RDBMS"
538 +HOMEPAGE="http://www.postgresql.org/"
539 +
540 +IUSE="doc kerberos kernel_linux ldap libressl llvm nls pam perl python +readline
541 + selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
542 +
543 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
544 +
545 +CDEPEND="
546 +>=app-eselect/eselect-postgresql-2.0
547 +sys-apps/less
548 +virtual/libintl
549 +kerberos? ( virtual/krb5 )
550 +ldap? ( net-nds/openldap )
551 +llvm? ( sys-devel/llvm:=
552 + sys-devel/clang:= )
553 +pam? ( virtual/pam )
554 +perl? ( >=dev-lang/perl-5.8:= )
555 +python? ( ${PYTHON_DEPS} )
556 +readline? ( sys-libs/readline:0= )
557 +server? ( systemd? ( sys-apps/systemd ) )
558 +ssl? (
559 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
560 + libressl? ( dev-libs/libressl:= )
561 +)
562 +tcl? ( >=dev-lang/tcl-8:0= )
563 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
564 +zlib? ( sys-libs/zlib )
565 +"
566 +
567 +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
568 +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
569 +# the libc includes UUID functions.
570 +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
571 +BSD_LIBC=( elibc_{Free,Net,Open}BSD )
572 +
573 +nest_usedep() {
574 + local front back
575 + while [[ ${#} -gt 1 ]]; do
576 + front+="${1}? ( "
577 + back+=" )"
578 + shift
579 + done
580 + echo "${front}${1}${back}"
581 +}
582 +
583 +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
584 +CDEPEND+="
585 +uuid? (
586 + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
587 + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
588 +)"
589 +
590 +DEPEND="${CDEPEND}
591 +!!<sys-apps/sandbox-2.0
592 +sys-devel/bison
593 +sys-devel/flex
594 +nls? ( sys-devel/gettext )
595 +xml? ( virtual/pkgconfig )
596 +"
597 +
598 +RDEPEND="${CDEPEND}
599 +!dev-db/postgresql-docs:${SLOT}
600 +!dev-db/postgresql-base:${SLOT}
601 +!dev-db/postgresql-server:${SLOT}
602 +selinux? ( sec-policy/selinux-postgresql )
603 +"
604 +
605 +pkg_setup() {
606 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
607 +
608 + enewgroup postgres 70
609 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
610 +
611 + use python && python-single-r1_pkg_setup
612 +}
613 +
614 +src_prepare() {
615 + # Set proper run directory
616 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
617 + -i src/include/pg_config_manual.h || die
618 +
619 + # Rely on $PATH being in the proper order so that the correct
620 + # install program is used for modules utilizing PGXS in both
621 + # hardened and non-hardened environments. (Bug #528786)
622 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
623 +
624 + use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
625 +
626 + if use pam ; then
627 + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
628 + -i src/backend/libpq/auth.c || \
629 + die 'PGSQL_PAM_SERVICE rename failed.'
630 + fi
631 +
632 + eapply_user
633 +}
634 +
635 +src_configure() {
636 + case ${CHOST} in
637 + *-darwin*|*-solaris*)
638 + use nls && append-libs intl
639 + ;;
640 + esac
641 +
642 + export LDFLAGS_SL="${LDFLAGS}"
643 + export LDFLAGS_EX="${LDFLAGS}"
644 +
645 + local PO="${EPREFIX%/}"
646 +
647 + local i uuid_config=""
648 + if use uuid; then
649 + for i in ${UTIL_LINUX_LIBC[@]}; do
650 + use ${i} && uuid_config="--with-uuid=e2fs"
651 + done
652 + for i in ${BSD_LIBC[@]}; do
653 + use ${i} && uuid_config="--with-uuid=bsd"
654 + done
655 + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
656 + fi
657 +
658 + econf \
659 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
660 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
661 + --docdir="${PO}/usr/share/doc/${PF}" \
662 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
663 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
664 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
665 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
666 + $(use_enable !alpha spinlocks) \
667 + $(use_enable threads thread-safety) \
668 + $(use_with kerberos gssapi) \
669 + $(use_with ldap) \
670 + $(use_with llvm) \
671 + $(use_with pam) \
672 + $(use_with perl) \
673 + $(use_with python) \
674 + $(use_with readline) \
675 + $(use_with ssl openssl) \
676 + $(usex server "$(use_with systemd)" '--without-systemd') \
677 + $(use_with tcl) \
678 + ${uuid_config} \
679 + $(use_with xml libxml) \
680 + $(use_with xml libxslt) \
681 + $(use_with zlib) \
682 + $(use_enable nls nls "'$(l10n_get_locales)'")
683 +}
684 +
685 +src_compile() {
686 + emake
687 + emake -C contrib
688 +}
689 +
690 +src_install() {
691 + emake DESTDIR="${D}" install
692 + emake DESTDIR="${D}" install -C contrib
693 +
694 + dodoc README HISTORY doc/{TODO,bug.template}
695 +
696 + # man pages are already built, but if we have the target make them,
697 + # they'll be generated from source before being installed so we
698 + # manually install man pages.
699 + # We use ${SLOT} instead of doman for postgresql.eselect
700 + insinto /usr/share/postgresql-${SLOT}/man/
701 + doins -r doc/src/sgml/man{1,3,7}
702 + if ! use server; then
703 + # Remove man pages for non-existent binaries
704 + serverman=(
705 + initdb
706 + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
707 + pg_{test_{fsync,timing},upgrade,waldump}
708 + post{gres,master}
709 + )
710 + for m in ${serverman[@]} ; do
711 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
712 + done
713 + fi
714 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
715 +
716 + # Create slot specific man pages
717 + local bn f mansec slotted_name
718 + for mansec in 1 3 7 ; do
719 + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
720 +
721 + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
722 + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
723 +
724 + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
725 + bn=$(basename "${f}")
726 + slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
727 + case ${bn} in
728 + TABLE.7|WITH.7)
729 + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
730 + ;;
731 + *)
732 + echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
733 + ;;
734 + esac
735 + done
736 +
737 + popd > /dev/null
738 + done
739 +
740 + insinto /etc/postgresql-${SLOT}
741 + newins src/bin/psql/psqlrc.sample psqlrc
742 +
743 + use static-libs || find "${ED}" -name '*.a' -delete
744 +
745 + local f bn
746 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
747 + -mindepth 1 -maxdepth 1)
748 + do
749 + bn=$(basename "${f}")
750 + # Temporarily tack on tmp to workaround a file collision
751 + # issue. This is only necessary for 9.7 and earlier. 10 never
752 + # had this issue.
753 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
754 + "/usr/bin/${bn}${SLOT/.}"
755 + done
756 +
757 + if use doc ; then
758 + docinto html
759 + dodoc doc/src/sgml/html/*
760 + fi
761 +
762 + if use server; then
763 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
764 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
765 +
766 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
767 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
768 +
769 + if use systemd; then
770 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
771 + "${FILESDIR}/${PN}.service-9.6-r1" | \
772 + systemd_newunit - ${PN}-${SLOT}.service
773 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
774 + systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
775 + fi
776 +
777 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
778 +
779 + if use prefix ; then
780 + keepdir /run/postgresql
781 + fperms 1775 /run/postgresql
782 + fi
783 + fi
784 +}
785 +
786 +pkg_postinst() {
787 + use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
788 + postgresql-config update
789 +
790 + elog "If you need a global psqlrc-file, you can place it in:"
791 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
792 +
793 + if use server ; then
794 + elog
795 + elog "Gentoo specific documentation:"
796 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
797 + elog
798 + elog "Official documentation:"
799 + elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
800 + elog
801 + elog "The default location of the Unix-domain socket is:"
802 + elog " ${EROOT%/}/run/postgresql/"
803 + elog
804 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
805 + elog "so that it contains your preferred locale in:"
806 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
807 + elog
808 + elog "Then, execute the following command to setup the initial database"
809 + elog "environment:"
810 + elog " emerge --config =${CATEGORY}/${PF}"
811 +
812 + if [[ -n ${REPLACING_VERSIONS} ]] ; then
813 + ewarn "If your system is using 'pg_stat_statements' and you are running a"
814 + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
815 + ewarn "the following command after upgrading:"
816 + ewarn
817 + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
818 + fi
819 + fi
820 +}
821 +
822 +pkg_prerm() {
823 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
824 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
825 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
826 +
827 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
828 + sleep 10
829 + eend 0
830 + fi
831 +}
832 +
833 +pkg_postrm() {
834 + postgresql-config update
835 +}
836 +
837 +pkg_config() {
838 + use server || die "USE flag 'server' not enabled. Nothing to configure."
839 +
840 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
841 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
842 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
843 + [[ -z "${DATA_DIR}" ]] \
844 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
845 +
846 + # environment.bz2 may not contain the same locale as the current system
847 + # locale. Unset and source from the current system locale.
848 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
849 + unset LANG
850 + unset LC_CTYPE
851 + unset LC_NUMERIC
852 + unset LC_TIME
853 + unset LC_COLLATE
854 + unset LC_MONETARY
855 + unset LC_MESSAGES
856 + unset LC_ALL
857 + source "${EROOT%/}/etc/env.d/02locale"
858 + [ -n "${LANG}" ] && export LANG
859 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
860 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
861 + [ -n "${LC_TIME}" ] && export LC_TIME
862 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
863 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
864 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
865 + [ -n "${LC_ALL}" ] && export LC_ALL
866 + fi
867 +
868 + einfo "You can modify the paths and options passed to initdb by editing:"
869 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
870 + einfo
871 + einfo "Information on options that can be passed to initdb are found at:"
872 + einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
873 + einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
874 + einfo
875 + einfo "PG_INITDB_OPTS is currently set to:"
876 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
877 + einfo " (none)"
878 + else
879 + einfo " ${PG_INITDB_OPTS}"
880 + fi
881 + einfo
882 + einfo "Configuration files will be installed to:"
883 + einfo " ${PGDATA}"
884 + einfo
885 + einfo "The database cluster will be created in:"
886 + einfo " ${DATA_DIR}"
887 + einfo
888 +
889 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
890 + sleep 5
891 + eend 0
892 +
893 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
894 + eerror "The given directory, '${DATA_DIR}', is not empty."
895 + eerror "Modify DATA_DIR to point to an empty directory."
896 + die "${DATA_DIR} is not empty."
897 + fi
898 +
899 + einfo "Creating the data directory ..."
900 + if [[ ${EUID} == 0 ]] ; then
901 + mkdir -p "${DATA_DIR}"
902 + chown -Rf postgres:postgres "${DATA_DIR}"
903 + chmod 0700 "${DATA_DIR}"
904 + fi
905 +
906 + einfo "Initializing the database ..."
907 +
908 + if [[ ${EUID} == 0 ]] ; then
909 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
910 + else
911 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
912 + fi
913 +
914 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
915 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
916 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
917 + fi
918 +
919 + # unix_socket_directory has no effect in postgresql.conf as it's
920 + # overridden in the initscript
921 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
922 +
923 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
924 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
925 + # On the off-chance that you might need to work with UTF-8 encoded
926 + # characters in PL/Perl
927 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
928 + EOF
929 +
930 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
931 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
932 + einfo "by default. You can disable it in the cluster's:"
933 + einfo " ${PGDATA%/}/postgresql.conf"
934 + einfo
935 + if ! use systemd; then
936 + einfo "The PostgreSQL server, by default, will log events to:"
937 + einfo " ${DATA_DIR%/}/postmaster.log"
938 + einfo
939 + fi
940 + if use prefix ; then
941 + einfo "The location of the configuration files have moved to:"
942 + einfo " ${PGDATA}"
943 + einfo "To start the server:"
944 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
945 + einfo "To stop:"
946 + einfo " pg_ctl stop -D ${DATA_DIR}"
947 + einfo
948 + einfo "Or move the configuration files back:"
949 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
950 + elif use systemd; then
951 + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
952 + einfo "instead of 'pg_ctl'."
953 + else
954 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
955 + einfo "instead of 'pg_ctl'."
956 + fi
957 +}
958 +
959 +src_test() {
960 + if use server && [[ ${UID} -ne 0 ]] ; then
961 + emake check
962 +
963 + einfo "If you think other tests besides the regression tests are necessary, please"
964 + einfo "submit a bug including a patch for this ebuild to enable them."
965 + else
966 + use server || \
967 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
968 + [[ ${UID} -eq 0 ]] || \
969 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
970 +
971 + ewarn 'Skipping.'
972 + fi
973 +}
974
975 diff --git a/dev-db/postgresql/postgresql-11_rc1.ebuild b/dev-db/postgresql/postgresql-11_rc1.ebuild
976 new file mode 100644
977 index 00000000000..7e1c36cd37a
978 --- /dev/null
979 +++ b/dev-db/postgresql/postgresql-11_rc1.ebuild
980 @@ -0,0 +1,452 @@
981 +# Copyright 1999-2019 Gentoo Authors
982 +# Distributed under the terms of the GNU General Public License v2
983 +
984 +EAPI="6"
985 +
986 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
987 +
988 +PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
989 + zh_TW"
990 +
991 +inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
992 + systemd user versionator
993 +
994 +KEYWORDS="~alpha ~amd64 ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
995 +
996 +SLOT=$(get_major_version)
997 +
998 +MY_PV=${PV/_/}
999 +S="${WORKDIR}/${PN}-${MY_PV}"
1000 +
1001 +SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
1002 +
1003 +LICENSE="POSTGRESQL GPL-2"
1004 +DESCRIPTION="PostgreSQL RDBMS"
1005 +HOMEPAGE="http://www.postgresql.org/"
1006 +
1007 +IUSE="doc kerberos kernel_linux ldap libressl llvm nls pam perl python +readline
1008 + selinux +server systemd ssl static-libs tcl threads uuid xml zlib"
1009 +
1010 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
1011 +
1012 +CDEPEND="
1013 +>=app-eselect/eselect-postgresql-2.0
1014 +sys-apps/less
1015 +virtual/libintl
1016 +kerberos? ( virtual/krb5 )
1017 +ldap? ( net-nds/openldap )
1018 +llvm? ( sys-devel/llvm:=
1019 + sys-devel/clang:= )
1020 +pam? ( virtual/pam )
1021 +perl? ( >=dev-lang/perl-5.8:= )
1022 +python? ( ${PYTHON_DEPS} )
1023 +readline? ( sys-libs/readline:0= )
1024 +server? ( systemd? ( sys-apps/systemd ) )
1025 +ssl? (
1026 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
1027 + libressl? ( dev-libs/libressl:= )
1028 +)
1029 +tcl? ( >=dev-lang/tcl-8:0= )
1030 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
1031 +zlib? ( sys-libs/zlib )
1032 +"
1033 +
1034 +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
1035 +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
1036 +# the libc includes UUID functions.
1037 +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
1038 +BSD_LIBC=( elibc_{Free,Net,Open}BSD )
1039 +
1040 +nest_usedep() {
1041 + local front back
1042 + while [[ ${#} -gt 1 ]]; do
1043 + front+="${1}? ( "
1044 + back+=" )"
1045 + shift
1046 + done
1047 + echo "${front}${1}${back}"
1048 +}
1049 +
1050 +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
1051 +CDEPEND+="
1052 +uuid? (
1053 + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
1054 + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
1055 +)"
1056 +
1057 +DEPEND="${CDEPEND}
1058 +!!<sys-apps/sandbox-2.0
1059 +sys-devel/bison
1060 +sys-devel/flex
1061 +nls? ( sys-devel/gettext )
1062 +xml? ( virtual/pkgconfig )
1063 +"
1064 +
1065 +RDEPEND="${CDEPEND}
1066 +!dev-db/postgresql-docs:${SLOT}
1067 +!dev-db/postgresql-base:${SLOT}
1068 +!dev-db/postgresql-server:${SLOT}
1069 +selinux? ( sec-policy/selinux-postgresql )
1070 +"
1071 +
1072 +pkg_setup() {
1073 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
1074 +
1075 + enewgroup postgres 70
1076 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
1077 +
1078 + use python && python-single-r1_pkg_setup
1079 +}
1080 +
1081 +src_prepare() {
1082 + # Set proper run directory
1083 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
1084 + -i src/include/pg_config_manual.h || die
1085 +
1086 + # Rely on $PATH being in the proper order so that the correct
1087 + # install program is used for modules utilizing PGXS in both
1088 + # hardened and non-hardened environments. (Bug #528786)
1089 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
1090 +
1091 + use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch"
1092 +
1093 + if use pam ; then
1094 + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
1095 + -i src/backend/libpq/auth.c || \
1096 + die 'PGSQL_PAM_SERVICE rename failed.'
1097 + fi
1098 +
1099 + eapply_user
1100 +}
1101 +
1102 +src_configure() {
1103 + case ${CHOST} in
1104 + *-darwin*|*-solaris*)
1105 + use nls && append-libs intl
1106 + ;;
1107 + esac
1108 +
1109 + export LDFLAGS_SL="${LDFLAGS}"
1110 + export LDFLAGS_EX="${LDFLAGS}"
1111 +
1112 + local PO="${EPREFIX%/}"
1113 +
1114 + local i uuid_config=""
1115 + if use uuid; then
1116 + for i in ${UTIL_LINUX_LIBC[@]}; do
1117 + use ${i} && uuid_config="--with-uuid=e2fs"
1118 + done
1119 + for i in ${BSD_LIBC[@]}; do
1120 + use ${i} && uuid_config="--with-uuid=bsd"
1121 + done
1122 + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
1123 + fi
1124 +
1125 + econf \
1126 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
1127 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
1128 + --docdir="${PO}/usr/share/doc/${PF}" \
1129 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
1130 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
1131 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
1132 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
1133 + $(use_enable !alpha spinlocks) \
1134 + $(use_enable threads thread-safety) \
1135 + $(use_with kerberos gssapi) \
1136 + $(use_with ldap) \
1137 + $(use_with llvm) \
1138 + $(use_with pam) \
1139 + $(use_with perl) \
1140 + $(use_with python) \
1141 + $(use_with readline) \
1142 + $(use_with ssl openssl) \
1143 + $(usex server "$(use_with systemd)" '--without-systemd') \
1144 + $(use_with tcl) \
1145 + ${uuid_config} \
1146 + $(use_with xml libxml) \
1147 + $(use_with xml libxslt) \
1148 + $(use_with zlib) \
1149 + $(use_enable nls nls "'$(l10n_get_locales)'")
1150 +}
1151 +
1152 +src_compile() {
1153 + emake
1154 + emake -C contrib
1155 +}
1156 +
1157 +src_install() {
1158 + emake DESTDIR="${D}" install
1159 + emake DESTDIR="${D}" install -C contrib
1160 +
1161 + dodoc README HISTORY doc/{TODO,bug.template}
1162 +
1163 + # man pages are already built, but if we have the target make them,
1164 + # they'll be generated from source before being installed so we
1165 + # manually install man pages.
1166 + # We use ${SLOT} instead of doman for postgresql.eselect
1167 + insinto /usr/share/postgresql-${SLOT}/man/
1168 + doins -r doc/src/sgml/man{1,3,7}
1169 + if ! use server; then
1170 + # Remove man pages for non-existent binaries
1171 + serverman=(
1172 + initdb
1173 + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
1174 + pg_{test_{fsync,timing},upgrade,waldump}
1175 + post{gres,master}
1176 + )
1177 + for m in ${serverman[@]} ; do
1178 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
1179 + done
1180 + fi
1181 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
1182 +
1183 + # Create slot specific man pages
1184 + local bn f mansec slotted_name
1185 + for mansec in 1 3 7 ; do
1186 + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
1187 +
1188 + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
1189 + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
1190 +
1191 + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
1192 + bn=$(basename "${f}")
1193 + slotted_name=${bn%.${mansec}}${SLOT}.${mansec}
1194 + case ${bn} in
1195 + TABLE.7|WITH.7)
1196 + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
1197 + ;;
1198 + *)
1199 + echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
1200 + ;;
1201 + esac
1202 + done
1203 +
1204 + popd > /dev/null
1205 + done
1206 +
1207 + insinto /etc/postgresql-${SLOT}
1208 + newins src/bin/psql/psqlrc.sample psqlrc
1209 +
1210 + use static-libs || find "${ED}" -name '*.a' -delete
1211 +
1212 + local f bn
1213 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
1214 + -mindepth 1 -maxdepth 1)
1215 + do
1216 + bn=$(basename "${f}")
1217 + # Temporarily tack on tmp to workaround a file collision
1218 + # issue. This is only necessary for 9.7 and earlier. 10 never
1219 + # had this issue.
1220 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
1221 + "/usr/bin/${bn}${SLOT/.}"
1222 + done
1223 +
1224 + if use doc ; then
1225 + docinto html
1226 + dodoc doc/src/sgml/html/*
1227 + fi
1228 +
1229 + if use server; then
1230 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1231 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
1232 +
1233 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1234 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
1235 +
1236 + if use systemd; then
1237 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1238 + "${FILESDIR}/${PN}.service-9.6-r1" | \
1239 + systemd_newunit - ${PN}-${SLOT}.service
1240 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
1241 + systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
1242 + fi
1243 +
1244 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
1245 +
1246 + if use prefix ; then
1247 + keepdir /run/postgresql
1248 + fperms 1775 /run/postgresql
1249 + fi
1250 + fi
1251 +}
1252 +
1253 +pkg_postinst() {
1254 + use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
1255 + postgresql-config update
1256 +
1257 + elog "If you need a global psqlrc-file, you can place it in:"
1258 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
1259 +
1260 + if use server ; then
1261 + elog
1262 + elog "Gentoo specific documentation:"
1263 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
1264 + elog
1265 + elog "Official documentation:"
1266 + elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
1267 + elog
1268 + elog "The default location of the Unix-domain socket is:"
1269 + elog " ${EROOT%/}/run/postgresql/"
1270 + elog
1271 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
1272 + elog "so that it contains your preferred locale in:"
1273 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1274 + elog
1275 + elog "Then, execute the following command to setup the initial database"
1276 + elog "environment:"
1277 + elog " emerge --config =${CATEGORY}/${PF}"
1278 + fi
1279 +}
1280 +
1281 +pkg_prerm() {
1282 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
1283 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
1284 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
1285 +
1286 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
1287 + sleep 10
1288 + eend 0
1289 + fi
1290 +}
1291 +
1292 +pkg_postrm() {
1293 + postgresql-config update
1294 +}
1295 +
1296 +pkg_config() {
1297 + use server || die "USE flag 'server' not enabled. Nothing to configure."
1298 +
1299 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
1300 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1301 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
1302 + [[ -z "${DATA_DIR}" ]] \
1303 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
1304 +
1305 + # environment.bz2 may not contain the same locale as the current system
1306 + # locale. Unset and source from the current system locale.
1307 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
1308 + unset LANG
1309 + unset LC_CTYPE
1310 + unset LC_NUMERIC
1311 + unset LC_TIME
1312 + unset LC_COLLATE
1313 + unset LC_MONETARY
1314 + unset LC_MESSAGES
1315 + unset LC_ALL
1316 + source "${EROOT%/}/etc/env.d/02locale"
1317 + [ -n "${LANG}" ] && export LANG
1318 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
1319 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
1320 + [ -n "${LC_TIME}" ] && export LC_TIME
1321 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
1322 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
1323 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
1324 + [ -n "${LC_ALL}" ] && export LC_ALL
1325 + fi
1326 +
1327 + einfo "You can modify the paths and options passed to initdb by editing:"
1328 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1329 + einfo
1330 + einfo "Information on options that can be passed to initdb are found at:"
1331 + einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
1332 + einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
1333 + einfo
1334 + einfo "PG_INITDB_OPTS is currently set to:"
1335 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
1336 + einfo " (none)"
1337 + else
1338 + einfo " ${PG_INITDB_OPTS}"
1339 + fi
1340 + einfo
1341 + einfo "Configuration files will be installed to:"
1342 + einfo " ${PGDATA}"
1343 + einfo
1344 + einfo "The database cluster will be created in:"
1345 + einfo " ${DATA_DIR}"
1346 + einfo
1347 +
1348 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
1349 + sleep 5
1350 + eend 0
1351 +
1352 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
1353 + eerror "The given directory, '${DATA_DIR}', is not empty."
1354 + eerror "Modify DATA_DIR to point to an empty directory."
1355 + die "${DATA_DIR} is not empty."
1356 + fi
1357 +
1358 + einfo "Creating the data directory ..."
1359 + if [[ ${EUID} == 0 ]] ; then
1360 + mkdir -p "${DATA_DIR}"
1361 + chown -Rf postgres:postgres "${DATA_DIR}"
1362 + chmod 0700 "${DATA_DIR}"
1363 + fi
1364 +
1365 + einfo "Initializing the database ..."
1366 +
1367 + if [[ ${EUID} == 0 ]] ; then
1368 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
1369 + else
1370 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
1371 + fi
1372 +
1373 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
1374 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
1375 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
1376 + fi
1377 +
1378 + # unix_socket_directory has no effect in postgresql.conf as it's
1379 + # overridden in the initscript
1380 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
1381 +
1382 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
1383 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
1384 + # On the off-chance that you might need to work with UTF-8 encoded
1385 + # characters in PL/Perl
1386 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
1387 + EOF
1388 +
1389 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
1390 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
1391 + einfo "by default. You can disable it in the cluster's:"
1392 + einfo " ${PGDATA%/}/postgresql.conf"
1393 + einfo
1394 + if ! use systemd; then
1395 + einfo "The PostgreSQL server, by default, will log events to:"
1396 + einfo " ${DATA_DIR%/}/postmaster.log"
1397 + einfo
1398 + fi
1399 + if use prefix ; then
1400 + einfo "The location of the configuration files have moved to:"
1401 + einfo " ${PGDATA}"
1402 + einfo "To start the server:"
1403 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
1404 + einfo "To stop:"
1405 + einfo " pg_ctl stop -D ${DATA_DIR}"
1406 + einfo
1407 + einfo "Or move the configuration files back:"
1408 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
1409 + elif use systemd; then
1410 + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
1411 + einfo "instead of 'pg_ctl'."
1412 + else
1413 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
1414 + einfo "instead of 'pg_ctl'."
1415 + fi
1416 +}
1417 +
1418 +src_test() {
1419 + if use server && [[ ${UID} -ne 0 ]] ; then
1420 + emake check
1421 +
1422 + einfo "If you think other tests besides the regression tests are necessary, please"
1423 + einfo "submit a bug including a patch for this ebuild to enable them."
1424 + else
1425 + use server || \
1426 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
1427 + [[ ${UID} -eq 0 ]] || \
1428 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
1429 +
1430 + ewarn 'Skipping.'
1431 + fi
1432 +}
1433
1434 diff --git a/dev-db/postgresql/postgresql-9.4.21.ebuild b/dev-db/postgresql/postgresql-9.4.21.ebuild
1435 new file mode 100644
1436 index 00000000000..89dee23428b
1437 --- /dev/null
1438 +++ b/dev-db/postgresql/postgresql-9.4.21.ebuild
1439 @@ -0,0 +1,475 @@
1440 +# Copyright 1999-2019 Gentoo Authors
1441 +# Distributed under the terms of the GNU General Public License v2
1442 +
1443 +EAPI="6"
1444 +
1445 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
1446 +
1447 +PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
1448 + zh_TW"
1449 +
1450 +inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
1451 + systemd user versionator
1452 +
1453 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
1454 +
1455 +SLOT="$(get_version_component_range 1-2)"
1456 +
1457 +SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
1458 +
1459 +LICENSE="POSTGRESQL GPL-2"
1460 +DESCRIPTION="PostgreSQL RDBMS"
1461 +HOMEPAGE="https://www.postgresql.org/"
1462 +
1463 +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
1464 + python +readline selinux +server systemd ssl static-libs tcl threads uuid
1465 + xml zlib"
1466 +
1467 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
1468 +
1469 +CDEPEND="
1470 +>=app-eselect/eselect-postgresql-2.0
1471 +sys-apps/less
1472 +virtual/libintl
1473 +kerberos? ( virtual/krb5 )
1474 +ldap? ( net-nds/openldap )
1475 +pam? ( virtual/pam )
1476 +perl? ( >=dev-lang/perl-5.8:= )
1477 +python? ( ${PYTHON_DEPS} )
1478 +readline? ( sys-libs/readline:0= )
1479 +ssl? (
1480 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
1481 + libressl? ( dev-libs/libressl:= )
1482 +)
1483 +tcl? ( >=dev-lang/tcl-8:0= )
1484 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
1485 +zlib? ( sys-libs/zlib )
1486 +"
1487 +
1488 +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
1489 +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
1490 +# the libc includes UUID functions.
1491 +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
1492 +BSD_LIBC=( elibc_{Free,Net,Open}BSD )
1493 +
1494 +nest_usedep() {
1495 + local front back
1496 + while [[ ${#} -gt 1 ]]; do
1497 + front+="${1}? ( "
1498 + back+=" )"
1499 + shift
1500 + done
1501 + echo "${front}${1}${back}"
1502 +}
1503 +
1504 +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
1505 +CDEPEND+="
1506 +uuid? (
1507 + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
1508 + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
1509 +)"
1510 +
1511 +DEPEND="${CDEPEND}
1512 +!!<sys-apps/sandbox-2.0
1513 +sys-devel/bison
1514 +sys-devel/flex
1515 +nls? ( sys-devel/gettext )
1516 +xml? ( virtual/pkgconfig )
1517 +"
1518 +
1519 +RDEPEND="${CDEPEND}
1520 +!dev-db/postgresql-docs:${SLOT}
1521 +!dev-db/postgresql-base:${SLOT}
1522 +!dev-db/postgresql-server:${SLOT}
1523 +selinux? ( sec-policy/selinux-postgresql )
1524 +"
1525 +
1526 +pkg_setup() {
1527 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
1528 +
1529 + enewgroup postgres 70
1530 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
1531 +
1532 + use python && python-single-r1_pkg_setup
1533 +}
1534 +
1535 +src_prepare() {
1536 + # Work around PPC{,64} compilation bug where bool is already defined
1537 + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
1538 +
1539 + # Set proper run directory
1540 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
1541 + -i src/include/pg_config_manual.h || die
1542 +
1543 + # Rely on $PATH being in the proper order so that the correct
1544 + # install program is used for modules utilizing PGXS in both
1545 + # hardened and non-hardened environments. (Bug #528786)
1546 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
1547 +
1548 + use server || eapply "${FILESDIR}/${PN}-9.4.10-no-server.patch"
1549 +
1550 + if use pam ; then
1551 + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
1552 + -i src/backend/libpq/auth.c || \
1553 + die 'PGSQL_PAM_SERVICE rename failed.'
1554 + fi
1555 +
1556 + eapply_user
1557 +}
1558 +
1559 +src_configure() {
1560 + case ${CHOST} in
1561 + *-darwin*|*-solaris*)
1562 + use nls && append-libs intl
1563 + ;;
1564 + esac
1565 +
1566 + export LDFLAGS_SL="${LDFLAGS}"
1567 + export LDFLAGS_EX="${LDFLAGS}"
1568 +
1569 + local PO="${EPREFIX%/}"
1570 +
1571 + local i uuid_config=""
1572 + if use uuid; then
1573 + for i in ${UTIL_LINUX_LIBC[@]}; do
1574 + use ${i} && uuid_config="--with-uuid=e2fs"
1575 + done
1576 + for i in ${BSD_LIBC[@]}; do
1577 + use ${i} && uuid_config="--with-uuid=bsd"
1578 + done
1579 + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
1580 + fi
1581 +
1582 + econf \
1583 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
1584 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
1585 + --docdir="${PO}/usr/share/doc/${PF}" \
1586 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
1587 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
1588 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
1589 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
1590 + $(use_enable !pg_legacytimestamp integer-datetimes) \
1591 + $(use_enable threads thread-safety) \
1592 + $(use_with kerberos gssapi) \
1593 + $(use_with ldap) \
1594 + $(use_with pam) \
1595 + $(use_with perl) \
1596 + $(use_with python) \
1597 + $(use_with readline) \
1598 + $(use_with ssl openssl) \
1599 + $(use_with tcl) \
1600 + ${uuid_config} \
1601 + $(use_with xml libxml) \
1602 + $(use_with xml libxslt) \
1603 + $(use_with zlib) \
1604 + $(use_enable nls nls "'$(l10n_get_locales)'")
1605 +}
1606 +
1607 +src_compile() {
1608 + emake
1609 + emake -C contrib
1610 +}
1611 +
1612 +src_install() {
1613 + emake DESTDIR="${D}" install
1614 + emake DESTDIR="${D}" install -C contrib
1615 +
1616 + dodoc README HISTORY doc/{TODO,bug.template}
1617 +
1618 + # man pages are already built, but if we have the target make them,
1619 + # they'll be generated from source before being installed so we
1620 + # manually install man pages.
1621 + # We use ${SLOT} instead of doman for postgresql.eselect
1622 + insinto /usr/share/postgresql-${SLOT}/man/
1623 + doins -r doc/src/sgml/man{1,3,7}
1624 + if ! use server; then
1625 + # Remove man pages for non-existent binaries
1626 + for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
1627 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
1628 + done
1629 + fi
1630 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
1631 +
1632 + # Create slot specific man pages
1633 + local bn f mansec slotted_name
1634 + for mansec in 1 3 7 ; do
1635 + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
1636 +
1637 + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
1638 + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
1639 +
1640 + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
1641 + bn=$(basename "${f}")
1642 + slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
1643 + case ${bn} in
1644 + TABLE.7|WITH.7)
1645 + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
1646 + ;;
1647 + *)
1648 + echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
1649 + ;;
1650 + esac
1651 + done
1652 +
1653 + popd > /dev/null
1654 + done
1655 +
1656 + insinto /etc/postgresql-${SLOT}
1657 + newins src/bin/psql/psqlrc.sample psqlrc
1658 +
1659 + use static-libs || find "${ED}" -name '*.a' -delete
1660 +
1661 + local f bn
1662 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
1663 + -mindepth 1 -maxdepth 1)
1664 + do
1665 + bn=$(basename "${f}")
1666 + # Temporarily tack on tmp to workaround a file collision
1667 + # issue. This is only necessary for 9.7 and earlier. 10 never
1668 + # had this issue.
1669 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
1670 + "/usr/bin/${bn}${SLOT/.}tmp"
1671 + done
1672 +
1673 + if use doc ; then
1674 + docinto html
1675 + dodoc doc/src/sgml/html/*
1676 +
1677 + docinto sgml
1678 + dodoc doc/src/sgml/*.{sgml,dsl}
1679 + fi
1680 +
1681 + if use server; then
1682 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1683 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
1684 +
1685 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1686 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
1687 +
1688 + if use systemd; then
1689 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
1690 + "${FILESDIR}/${PN}.service-9.2" | \
1691 + systemd_newunit - ${PN}-${SLOT}.service
1692 + systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
1693 + fi
1694 +
1695 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
1696 +
1697 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
1698 +
1699 + if use prefix ; then
1700 + keepdir /run/postgresql
1701 + fperms 1775 /run/postgresql
1702 + fi
1703 + fi
1704 +}
1705 +
1706 +pkg_preinst() {
1707 + # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
1708 + # /usr/bin/psql96). They may have been created by the
1709 + # postgresql.eselect module, but they're handled within this ebuild
1710 + # now. It's alright if we momentarily delete /usr/bin/psql as it
1711 + # will be recreated by the eselect module in pkg_ppostinst(). This
1712 + # is only necessary for 9.7 and earlier. 10 and later were never
1713 + # handled in this manner.
1714 + local canonicalise
1715 + if type -p realpath > /dev/null; then
1716 + canonicalise=realpath
1717 + elif type -p readlink > /dev/null; then
1718 + canonicalise='readlink -f'
1719 + else
1720 + # can't die, subshell
1721 + die "No readlink nor realpath found, cannot canonicalise"
1722 + fi
1723 +
1724 + local l
1725 + # First remove any symlinks in /usr/bin that may have been created
1726 + # by the old eselect
1727 + for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
1728 + if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
1729 + rm "${l}" || ewarn "Couldn't remove ${l}"
1730 + fi
1731 + done
1732 +
1733 + # Then move the symlinks created by the ebuild to their proper place.
1734 + for l in "${ED}"/usr/bin/*tmp ; do
1735 + mv "${l}" "${l%tmp}" \
1736 + || ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
1737 + done
1738 +}
1739 +
1740 +pkg_postinst() {
1741 + use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
1742 + postgresql-config update
1743 +
1744 + elog "If you need a global psqlrc-file, you can place it in:"
1745 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
1746 +
1747 + if use server ; then
1748 + elog
1749 + elog "Gentoo specific documentation:"
1750 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
1751 + elog
1752 + elog "Official documentation:"
1753 + elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
1754 + elog
1755 + elog "The default location of the Unix-domain socket is:"
1756 + elog " ${EROOT%/}/run/postgresql/"
1757 + elog
1758 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
1759 + elog "so that it contains your preferred locale in:"
1760 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1761 + elog
1762 + elog "Then, execute the following command to setup the initial database"
1763 + elog "environment:"
1764 + elog " emerge --config =${CATEGORY}/${PF}"
1765 + fi
1766 +}
1767 +
1768 +pkg_prerm() {
1769 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
1770 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
1771 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
1772 +
1773 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
1774 + sleep 10
1775 + eend 0
1776 + fi
1777 +}
1778 +
1779 +pkg_postrm() {
1780 + postgresql-config update
1781 +}
1782 +
1783 +pkg_config() {
1784 + use server || die "USE flag 'server' not enabled. Nothing to configure."
1785 +
1786 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
1787 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1788 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
1789 + [[ -z "${DATA_DIR}" ]] \
1790 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
1791 +
1792 + # environment.bz2 may not contain the same locale as the current system
1793 + # locale. Unset and source from the current system locale.
1794 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
1795 + unset LANG
1796 + unset LC_CTYPE
1797 + unset LC_NUMERIC
1798 + unset LC_TIME
1799 + unset LC_COLLATE
1800 + unset LC_MONETARY
1801 + unset LC_MESSAGES
1802 + unset LC_ALL
1803 + source "${EROOT%/}/etc/env.d/02locale"
1804 + [ -n "${LANG}" ] && export LANG
1805 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
1806 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
1807 + [ -n "${LC_TIME}" ] && export LC_TIME
1808 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
1809 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
1810 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
1811 + [ -n "${LC_ALL}" ] && export LC_ALL
1812 + fi
1813 +
1814 + einfo "You can modify the paths and options passed to initdb by editing:"
1815 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1816 + einfo
1817 + einfo "Information on options that can be passed to initdb are found at:"
1818 + einfo " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
1819 + einfo " https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
1820 + einfo
1821 + einfo "PG_INITDB_OPTS is currently set to:"
1822 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
1823 + einfo " (none)"
1824 + else
1825 + einfo " ${PG_INITDB_OPTS}"
1826 + fi
1827 + einfo
1828 + einfo "Configuration files will be installed to:"
1829 + einfo " ${PGDATA}"
1830 + einfo
1831 + einfo "The database cluster will be created in:"
1832 + einfo " ${DATA_DIR}"
1833 + einfo
1834 +
1835 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
1836 + sleep 5
1837 + eend 0
1838 +
1839 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
1840 + eerror "The given directory, '${DATA_DIR}', is not empty."
1841 + eerror "Modify DATA_DIR to point to an empty directory."
1842 + die "${DATA_DIR} is not empty."
1843 + fi
1844 +
1845 + einfo "Creating the data directory ..."
1846 + if [[ ${EUID} == 0 ]] ; then
1847 + mkdir -p "${DATA_DIR}"
1848 + chown -Rf postgres:postgres "${DATA_DIR}"
1849 + chmod 0700 "${DATA_DIR}"
1850 + fi
1851 +
1852 + einfo "Initializing the database ..."
1853 +
1854 + if [[ ${EUID} == 0 ]] ; then
1855 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
1856 + else
1857 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
1858 + fi
1859 +
1860 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
1861 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
1862 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
1863 + fi
1864 +
1865 + # unix_socket_directory has no effect in postgresql.conf as it's
1866 + # overridden in the initscript
1867 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
1868 +
1869 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
1870 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
1871 + # On the off-chance that you might need to work with UTF-8 encoded
1872 + # characters in PL/Perl
1873 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
1874 + EOF
1875 +
1876 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
1877 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
1878 + einfo "by default. You can disable it in the cluster's:"
1879 + einfo " ${PGDATA%/}/postgresql.conf"
1880 + einfo
1881 + einfo "The PostgreSQL server, by default, will log events to:"
1882 + einfo " ${DATA_DIR%/}/postmaster.log"
1883 + einfo
1884 + if use prefix ; then
1885 + einfo "The location of the configuration files have moved to:"
1886 + einfo " ${PGDATA}"
1887 + einfo "To start the server:"
1888 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
1889 + einfo "To stop:"
1890 + einfo " pg_ctl stop -D ${DATA_DIR}"
1891 + einfo
1892 + einfo "Or move the configuration files back:"
1893 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
1894 + else
1895 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
1896 + einfo "instead of 'pg_ctl'."
1897 + fi
1898 +}
1899 +
1900 +src_test() {
1901 + if use server && [[ ${UID} -ne 0 ]] ; then
1902 + emake check
1903 +
1904 + einfo "If you think other tests besides the regression tests are necessary, please"
1905 + einfo "submit a bug including a patch for this ebuild to enable them."
1906 + else
1907 + use server || \
1908 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
1909 + [[ ${UID} -eq 0 ]] || \
1910 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
1911 +
1912 + ewarn 'Skipping.'
1913 + fi
1914 +}
1915
1916 diff --git a/dev-db/postgresql/postgresql-9.5.16.ebuild b/dev-db/postgresql/postgresql-9.5.16.ebuild
1917 new file mode 100644
1918 index 00000000000..8b0a59867f7
1919 --- /dev/null
1920 +++ b/dev-db/postgresql/postgresql-9.5.16.ebuild
1921 @@ -0,0 +1,481 @@
1922 +# Copyright 1999-2019 Gentoo Authors
1923 +# Distributed under the terms of the GNU General Public License v2
1924 +
1925 +EAPI="6"
1926 +
1927 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
1928 +
1929 +PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
1930 + zh_TW"
1931 +
1932 +inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
1933 + systemd user versionator
1934 +
1935 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris"
1936 +
1937 +SLOT="$(get_version_component_range 1-2)"
1938 +
1939 +SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2"
1940 +
1941 +LICENSE="POSTGRESQL GPL-2"
1942 +DESCRIPTION="PostgreSQL RDBMS"
1943 +HOMEPAGE="https://www.postgresql.org/"
1944 +
1945 +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
1946 + python +readline selinux +server systemd ssl static-libs tcl threads uuid
1947 + xml zlib"
1948 +
1949 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
1950 +
1951 +CDEPEND="
1952 +>=app-eselect/eselect-postgresql-2.0
1953 +sys-apps/less
1954 +virtual/libintl
1955 +kerberos? ( virtual/krb5 )
1956 +ldap? ( net-nds/openldap )
1957 +pam? ( virtual/pam )
1958 +perl? ( >=dev-lang/perl-5.8:= )
1959 +python? ( ${PYTHON_DEPS} )
1960 +readline? ( sys-libs/readline:0= )
1961 +ssl? (
1962 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
1963 + libressl? ( dev-libs/libressl:= )
1964 +)
1965 +tcl? ( >=dev-lang/tcl-8:0= )
1966 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
1967 +zlib? ( sys-libs/zlib )
1968 +"
1969 +
1970 +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
1971 +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
1972 +# the libc includes UUID functions.
1973 +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
1974 +BSD_LIBC=( elibc_{Free,Net,Open}BSD )
1975 +
1976 +nest_usedep() {
1977 + local front back
1978 + while [[ ${#} -gt 1 ]]; do
1979 + front+="${1}? ( "
1980 + back+=" )"
1981 + shift
1982 + done
1983 + echo "${front}${1}${back}"
1984 +}
1985 +
1986 +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
1987 +CDEPEND+="
1988 +uuid? (
1989 + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
1990 + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
1991 +)"
1992 +
1993 +DEPEND="${CDEPEND}
1994 +!!<sys-apps/sandbox-2.0
1995 +sys-devel/bison
1996 +sys-devel/flex
1997 +nls? ( sys-devel/gettext )
1998 +xml? ( virtual/pkgconfig )
1999 +"
2000 +
2001 +RDEPEND="${CDEPEND}
2002 +!dev-db/postgresql-docs:${SLOT}
2003 +!dev-db/postgresql-base:${SLOT}
2004 +!dev-db/postgresql-server:${SLOT}
2005 +selinux? ( sec-policy/selinux-postgresql )
2006 +"
2007 +
2008 +pkg_setup() {
2009 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
2010 +
2011 + enewgroup postgres 70
2012 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
2013 +
2014 + use python && python-single-r1_pkg_setup
2015 +}
2016 +
2017 +src_prepare() {
2018 + # Work around PPC{,64} compilation bug where bool is already defined
2019 + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
2020 +
2021 + # Set proper run directory
2022 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
2023 + -i src/include/pg_config_manual.h || die
2024 +
2025 + # Rely on $PATH being in the proper order so that the correct
2026 + # install program is used for modules utilizing PGXS in both
2027 + # hardened and non-hardened environments. (Bug #528786)
2028 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
2029 +
2030 + use server || eapply "${FILESDIR}/${PN}-9.5.5-no-server.patch"
2031 +
2032 + if use pam ; then
2033 + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
2034 + -i src/backend/libpq/auth.c || \
2035 + die 'PGSQL_PAM_SERVICE rename failed.'
2036 + fi
2037 +
2038 + eapply_user
2039 +}
2040 +
2041 +src_configure() {
2042 + case ${CHOST} in
2043 + *-darwin*|*-solaris*)
2044 + use nls && append-libs intl
2045 + ;;
2046 + esac
2047 +
2048 + export LDFLAGS_SL="${LDFLAGS}"
2049 + export LDFLAGS_EX="${LDFLAGS}"
2050 +
2051 + local PO="${EPREFIX%/}"
2052 +
2053 + local i uuid_config=""
2054 + if use uuid; then
2055 + for i in ${UTIL_LINUX_LIBC[@]}; do
2056 + use ${i} && uuid_config="--with-uuid=e2fs"
2057 + done
2058 + for i in ${BSD_LIBC[@]}; do
2059 + use ${i} && uuid_config="--with-uuid=bsd"
2060 + done
2061 + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
2062 + fi
2063 +
2064 + econf \
2065 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
2066 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
2067 + --docdir="${PO}/usr/share/doc/${PF}" \
2068 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
2069 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
2070 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
2071 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
2072 + $(use_enable !alpha spinlocks) \
2073 + $(use_enable !pg_legacytimestamp integer-datetimes) \
2074 + $(use_enable threads thread-safety) \
2075 + $(use_with kerberos gssapi) \
2076 + $(use_with ldap) \
2077 + $(use_with pam) \
2078 + $(use_with perl) \
2079 + $(use_with python) \
2080 + $(use_with readline) \
2081 + $(use_with ssl openssl) \
2082 + $(use_with tcl) \
2083 + ${uuid_config} \
2084 + $(use_with xml libxml) \
2085 + $(use_with xml libxslt) \
2086 + $(use_with zlib) \
2087 + $(use_enable nls nls "'$(l10n_get_locales)'")
2088 +}
2089 +
2090 +src_compile() {
2091 + emake
2092 + emake -C contrib
2093 +}
2094 +
2095 +src_install() {
2096 + emake DESTDIR="${D}" install
2097 + emake DESTDIR="${D}" install -C contrib
2098 +
2099 + dodoc README HISTORY doc/{TODO,bug.template}
2100 +
2101 + # man pages are already built, but if we have the target make them,
2102 + # they'll be generated from source before being installed so we
2103 + # manually install man pages.
2104 + # We use ${SLOT} instead of doman for postgresql.eselect
2105 + insinto /usr/share/postgresql-${SLOT}/man/
2106 + doins -r doc/src/sgml/man{1,3,7}
2107 + if ! use server; then
2108 + # Remove man pages for non-existent binaries
2109 + for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
2110 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
2111 + done
2112 + fi
2113 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
2114 +
2115 + # Create slot specific man pages
2116 + local bn f mansec slotted_name
2117 + for mansec in 1 3 7 ; do
2118 + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
2119 +
2120 + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
2121 + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
2122 +
2123 + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
2124 + bn=$(basename "${f}")
2125 + slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
2126 + case ${bn} in
2127 + TABLE.7|WITH.7)
2128 + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
2129 + ;;
2130 + *)
2131 + echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
2132 + ;;
2133 + esac
2134 + done
2135 +
2136 + popd > /dev/null
2137 + done
2138 +
2139 + insinto /etc/postgresql-${SLOT}
2140 + newins src/bin/psql/psqlrc.sample psqlrc
2141 +
2142 + use static-libs || find "${ED}" -name '*.a' -delete
2143 +
2144 + local f bn
2145 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
2146 + -mindepth 1 -maxdepth 1)
2147 + do
2148 + bn=$(basename "${f}")
2149 + # Temporarily tack on tmp to workaround a file collision
2150 + # issue. This is only necessary for 9.7 and earlier. 10 never
2151 + # had this issue.
2152 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
2153 + "/usr/bin/${bn}${SLOT/.}tmp"
2154 + done
2155 +
2156 + if use doc ; then
2157 + docinto html
2158 + dodoc doc/src/sgml/html/*
2159 +
2160 + docinto sgml
2161 + dodoc doc/src/sgml/*.{sgml,dsl}
2162 + fi
2163 +
2164 + if use server; then
2165 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
2166 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
2167 +
2168 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
2169 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
2170 +
2171 + if use systemd; then
2172 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
2173 + "${FILESDIR}/${PN}.service-9.2" | \
2174 + systemd_newunit - ${PN}-${SLOT}.service
2175 + systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
2176 + fi
2177 +
2178 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
2179 +
2180 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
2181 +
2182 + if use prefix ; then
2183 + keepdir /run/postgresql
2184 + fperms 1775 /run/postgresql
2185 + fi
2186 + fi
2187 +}
2188 +
2189 +pkg_preinst() {
2190 + # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
2191 + # /usr/bin/psql96). They may have been created by the
2192 + # postgresql.eselect module, but they're handled within this ebuild
2193 + # now. It's alright if we momentarily delete /usr/bin/psql as it
2194 + # will be recreated by the eselect module in pkg_ppostinst(). This
2195 + # is only necessary for 9.7 and earlier. 10 and later were never
2196 + # handled in this manner.
2197 + local canonicalise
2198 + if type -p realpath > /dev/null; then
2199 + canonicalise=realpath
2200 + elif type -p readlink > /dev/null; then
2201 + canonicalise='readlink -f'
2202 + else
2203 + # can't die, subshell
2204 + die "No readlink nor realpath found, cannot canonicalise"
2205 + fi
2206 +
2207 + local l
2208 + # First remove any symlinks in /usr/bin that may have been created
2209 + # by the old eselect
2210 + for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
2211 + if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
2212 + rm "${l}" || ewarn "Couldn't remove ${l}"
2213 + fi
2214 + done
2215 +
2216 + # Then move the symlinks created by the ebuild to their proper place.
2217 + for l in "${ED}"/usr/bin/*tmp ; do
2218 + mv "${l}" "${l%tmp}" \
2219 + || ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
2220 + done
2221 +}
2222 +
2223 +pkg_postinst() {
2224 + use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
2225 + postgresql-config update
2226 +
2227 + if use alpha && use server ; then
2228 + ewarn "PostgreSQL 9.5+ no longer has native spinlock support on Alpha platforms."
2229 + ewarn "As a result, performance will be extremely degraded."
2230 + fi
2231 +
2232 + elog "If you need a global psqlrc-file, you can place it in:"
2233 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
2234 +
2235 + if use server ; then
2236 + elog
2237 + elog "Gentoo specific documentation:"
2238 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
2239 + elog
2240 + elog "Official documentation:"
2241 + elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
2242 + elog
2243 + elog "The default location of the Unix-domain socket is:"
2244 + elog " ${EROOT%/}/run/postgresql/"
2245 + elog
2246 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
2247 + elog "so that it contains your preferred locale in:"
2248 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
2249 + elog
2250 + elog "Then, execute the following command to setup the initial database"
2251 + elog "environment:"
2252 + elog " emerge --config =${CATEGORY}/${PF}"
2253 + fi
2254 +}
2255 +
2256 +pkg_prerm() {
2257 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
2258 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
2259 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
2260 +
2261 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
2262 + sleep 10
2263 + eend 0
2264 + fi
2265 +}
2266 +
2267 +pkg_postrm() {
2268 + postgresql-config update
2269 +}
2270 +
2271 +pkg_config() {
2272 + use server || die "USE flag 'server' not enabled. Nothing to configure."
2273 +
2274 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
2275 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
2276 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
2277 + [[ -z "${DATA_DIR}" ]] \
2278 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
2279 +
2280 + # environment.bz2 may not contain the same locale as the current system
2281 + # locale. Unset and source from the current system locale.
2282 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
2283 + unset LANG
2284 + unset LC_CTYPE
2285 + unset LC_NUMERIC
2286 + unset LC_TIME
2287 + unset LC_COLLATE
2288 + unset LC_MONETARY
2289 + unset LC_MESSAGES
2290 + unset LC_ALL
2291 + source "${EROOT%/}/etc/env.d/02locale"
2292 + [ -n "${LANG}" ] && export LANG
2293 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
2294 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
2295 + [ -n "${LC_TIME}" ] && export LC_TIME
2296 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
2297 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
2298 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
2299 + [ -n "${LC_ALL}" ] && export LC_ALL
2300 + fi
2301 +
2302 + einfo "You can modify the paths and options passed to initdb by editing:"
2303 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
2304 + einfo
2305 + einfo "Information on options that can be passed to initdb are found at:"
2306 + einfo " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
2307 + einfo " https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
2308 + einfo
2309 + einfo "PG_INITDB_OPTS is currently set to:"
2310 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
2311 + einfo " (none)"
2312 + else
2313 + einfo " ${PG_INITDB_OPTS}"
2314 + fi
2315 + einfo
2316 + einfo "Configuration files will be installed to:"
2317 + einfo " ${PGDATA}"
2318 + einfo
2319 + einfo "The database cluster will be created in:"
2320 + einfo " ${DATA_DIR}"
2321 + einfo
2322 +
2323 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
2324 + sleep 5
2325 + eend 0
2326 +
2327 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
2328 + eerror "The given directory, '${DATA_DIR}', is not empty."
2329 + eerror "Modify DATA_DIR to point to an empty directory."
2330 + die "${DATA_DIR} is not empty."
2331 + fi
2332 +
2333 + einfo "Creating the data directory ..."
2334 + if [[ ${EUID} == 0 ]] ; then
2335 + mkdir -p "${DATA_DIR}"
2336 + chown -Rf postgres:postgres "${DATA_DIR}"
2337 + chmod 0700 "${DATA_DIR}"
2338 + fi
2339 +
2340 + einfo "Initializing the database ..."
2341 +
2342 + if [[ ${EUID} == 0 ]] ; then
2343 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
2344 + else
2345 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
2346 + fi
2347 +
2348 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
2349 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
2350 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
2351 + fi
2352 +
2353 + # unix_socket_directory has no effect in postgresql.conf as it's
2354 + # overridden in the initscript
2355 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
2356 +
2357 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
2358 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
2359 + # On the off-chance that you might need to work with UTF-8 encoded
2360 + # characters in PL/Perl
2361 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
2362 + EOF
2363 +
2364 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
2365 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
2366 + einfo "by default. You can disable it in the cluster's:"
2367 + einfo " ${PGDATA%/}/postgresql.conf"
2368 + einfo
2369 + einfo "The PostgreSQL server, by default, will log events to:"
2370 + einfo " ${DATA_DIR%/}/postmaster.log"
2371 + einfo
2372 + if use prefix ; then
2373 + einfo "The location of the configuration files have moved to:"
2374 + einfo " ${PGDATA}"
2375 + einfo "To start the server:"
2376 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
2377 + einfo "To stop:"
2378 + einfo " pg_ctl stop -D ${DATA_DIR}"
2379 + einfo
2380 + einfo "Or move the configuration files back:"
2381 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
2382 + else
2383 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
2384 + einfo "instead of 'pg_ctl'."
2385 + fi
2386 +}
2387 +
2388 +src_test() {
2389 + if use server && [[ ${UID} -ne 0 ]] ; then
2390 + emake check
2391 +
2392 + einfo "If you think other tests besides the regression tests are necessary, please"
2393 + einfo "submit a bug including a patch for this ebuild to enable them."
2394 + else
2395 + use server || \
2396 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
2397 + [[ ${UID} -eq 0 ]] || \
2398 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
2399 +
2400 + ewarn 'Skipping.'
2401 + fi
2402 +}
2403
2404 diff --git a/dev-db/postgresql/postgresql-9.6.12.ebuild b/dev-db/postgresql/postgresql-9.6.12.ebuild
2405 new file mode 100644
2406 index 00000000000..f9c788a8f2a
2407 --- /dev/null
2408 +++ b/dev-db/postgresql/postgresql-9.6.12.ebuild
2409 @@ -0,0 +1,486 @@
2410 +# Copyright 1999-2019 Gentoo Authors
2411 +# Distributed under the terms of the GNU General Public License v2
2412 +
2413 +EAPI="6"
2414 +
2415 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
2416 +
2417 +PLOCALES="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN
2418 + zh_TW"
2419 +
2420 +inherit flag-o-matic l10n linux-info multilib pam prefix python-single-r1 \
2421 + systemd user versionator
2422 +
2423 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
2424 +
2425 +SLOT="$(get_version_component_range 1-2)"
2426 +
2427 +MY_PV=${PV/_/}
2428 +S="${WORKDIR}/${PN}-${MY_PV}"
2429 +
2430 +SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
2431 +
2432 +LICENSE="POSTGRESQL GPL-2"
2433 +DESCRIPTION="PostgreSQL RDBMS"
2434 +HOMEPAGE="https://www.postgresql.org/"
2435 +
2436 +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp
2437 + python +readline selinux +server systemd ssl static-libs tcl threads uuid
2438 + xml zlib"
2439 +
2440 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
2441 +
2442 +CDEPEND="
2443 +>=app-eselect/eselect-postgresql-2.0
2444 +sys-apps/less
2445 +virtual/libintl
2446 +kerberos? ( virtual/krb5 )
2447 +ldap? ( net-nds/openldap )
2448 +pam? ( virtual/pam )
2449 +perl? ( >=dev-lang/perl-5.8:= )
2450 +python? ( ${PYTHON_DEPS} )
2451 +readline? ( sys-libs/readline:0= )
2452 +ssl? (
2453 + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= )
2454 + libressl? ( dev-libs/libressl:= )
2455 +)
2456 +server? ( systemd? ( sys-apps/systemd ) )
2457 +tcl? ( >=dev-lang/tcl-8:0= )
2458 +xml? ( dev-libs/libxml2 dev-libs/libxslt )
2459 +zlib? ( sys-libs/zlib )
2460 +"
2461 +
2462 +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no
2463 +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems,
2464 +# the libc includes UUID functions.
2465 +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} )
2466 +BSD_LIBC=( elibc_{Free,Net,Open}BSD )
2467 +
2468 +nest_usedep() {
2469 + local front back
2470 + while [[ ${#} -gt 1 ]]; do
2471 + front+="${1}? ( "
2472 + back+=" )"
2473 + shift
2474 + done
2475 + echo "${front}${1}${back}"
2476 +}
2477 +
2478 +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}"
2479 +CDEPEND+="
2480 +uuid? (
2481 + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )}
2482 + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid)
2483 +)"
2484 +
2485 +DEPEND="${CDEPEND}
2486 +!!<sys-apps/sandbox-2.0
2487 +sys-devel/bison
2488 +sys-devel/flex
2489 +nls? ( sys-devel/gettext )
2490 +xml? ( virtual/pkgconfig )
2491 +"
2492 +
2493 +RDEPEND="${CDEPEND}
2494 +!dev-db/postgresql-docs:${SLOT}
2495 +!dev-db/postgresql-base:${SLOT}
2496 +!dev-db/postgresql-server:${SLOT}
2497 +selinux? ( sec-policy/selinux-postgresql )
2498 +"
2499 +
2500 +pkg_setup() {
2501 + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
2502 +
2503 + enewgroup postgres 70
2504 + enewuser postgres 70 /bin/sh /var/lib/postgresql postgres
2505 +
2506 + use python && python-single-r1_pkg_setup
2507 +}
2508 +
2509 +src_prepare() {
2510 + # Work around PPC{,64} compilation bug where bool is already defined
2511 + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die
2512 +
2513 + # Set proper run directory
2514 + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \
2515 + -i src/include/pg_config_manual.h || die
2516 +
2517 + # Rely on $PATH being in the proper order so that the correct
2518 + # install program is used for modules utilizing PGXS in both
2519 + # hardened and non-hardened environments. (Bug #528786)
2520 + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
2521 +
2522 + use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch"
2523 +
2524 + if use pam ; then
2525 + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
2526 + -i src/backend/libpq/auth.c || \
2527 + die 'PGSQL_PAM_SERVICE rename failed.'
2528 + fi
2529 +
2530 + eapply_user
2531 +}
2532 +
2533 +src_configure() {
2534 + case ${CHOST} in
2535 + *-darwin*|*-solaris*)
2536 + use nls && append-libs intl
2537 + ;;
2538 + esac
2539 +
2540 + export LDFLAGS_SL="${LDFLAGS}"
2541 + export LDFLAGS_EX="${LDFLAGS}"
2542 +
2543 + local PO="${EPREFIX%/}"
2544 +
2545 + local i uuid_config=""
2546 + if use uuid; then
2547 + for i in ${UTIL_LINUX_LIBC[@]}; do
2548 + use ${i} && uuid_config="--with-uuid=e2fs"
2549 + done
2550 + for i in ${BSD_LIBC[@]}; do
2551 + use ${i} && uuid_config="--with-uuid=bsd"
2552 + done
2553 + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
2554 + fi
2555 +
2556 + econf \
2557 + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
2558 + --datadir="${PO}/usr/share/postgresql-${SLOT}" \
2559 + --docdir="${PO}/usr/share/doc/${PF}" \
2560 + --includedir="${PO}/usr/include/postgresql-${SLOT}" \
2561 + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
2562 + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \
2563 + --with-system-tzdata="${PO}/usr/share/zoneinfo" \
2564 + $(use_enable !alpha spinlocks) \
2565 + $(use_enable !pg_legacytimestamp integer-datetimes) \
2566 + $(use_enable threads thread-safety) \
2567 + $(use_with kerberos gssapi) \
2568 + $(use_with ldap) \
2569 + $(use_with pam) \
2570 + $(use_with perl) \
2571 + $(use_with python) \
2572 + $(use_with readline) \
2573 + $(use_with ssl openssl) \
2574 + $(usex server "$(use_with systemd)" '--without-systemd') \
2575 + $(use_with tcl) \
2576 + ${uuid_config} \
2577 + $(use_with xml libxml) \
2578 + $(use_with xml libxslt) \
2579 + $(use_with zlib) \
2580 + $(use_enable nls nls "'$(l10n_get_locales)'")
2581 +}
2582 +
2583 +src_compile() {
2584 + emake
2585 + emake -C contrib
2586 +}
2587 +
2588 +src_install() {
2589 + emake DESTDIR="${D}" install
2590 + emake DESTDIR="${D}" install -C contrib
2591 +
2592 + dodoc README HISTORY doc/{TODO,bug.template}
2593 +
2594 + # man pages are already built, but if we have the target make them,
2595 + # they'll be generated from source before being installed so we
2596 + # manually install man pages.
2597 + # We use ${SLOT} instead of doman for postgresql.eselect
2598 + insinto /usr/share/postgresql-${SLOT}/man/
2599 + doins -r doc/src/sgml/man{1,3,7}
2600 + if ! use server; then
2601 + # Remove man pages for non-existent binaries
2602 + for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do
2603 + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
2604 + done
2605 + fi
2606 + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
2607 +
2608 + # Create slot specific man pages
2609 + local bn f mansec slotted_name
2610 + for mansec in 1 3 7 ; do
2611 + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}"
2612 +
2613 + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir"
2614 + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed"
2615 +
2616 + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do
2617 + bn=$(basename "${f}")
2618 + slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec}
2619 + case ${bn} in
2620 + TABLE.7|WITH.7)
2621 + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name}
2622 + ;;
2623 + *)
2624 + echo ".so ${rel_manpath}/${bn}" > ${slotted_name}
2625 + ;;
2626 + esac
2627 + done
2628 +
2629 + popd > /dev/null
2630 + done
2631 +
2632 + insinto /etc/postgresql-${SLOT}
2633 + newins src/bin/psql/psqlrc.sample psqlrc
2634 +
2635 + use static-libs || find "${ED}" -name '*.a' -delete
2636 +
2637 + local f bn
2638 + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
2639 + -mindepth 1 -maxdepth 1)
2640 + do
2641 + bn=$(basename "${f}")
2642 + # Temporarily tack on tmp to workaround a file collision
2643 + # issue. This is only necessary for 9.7 and earlier. 10 never
2644 + # had this issue.
2645 + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
2646 + "/usr/bin/${bn}${SLOT/.}tmp"
2647 + done
2648 +
2649 + if use doc ; then
2650 + docinto html
2651 + dodoc doc/src/sgml/html/*
2652 +
2653 + docinto sgml
2654 + dodoc doc/src/sgml/*.{sgml,dsl}
2655 + fi
2656 +
2657 + if use server; then
2658 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
2659 + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
2660 +
2661 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
2662 + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
2663 +
2664 + if use systemd; then
2665 + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
2666 + "${FILESDIR}/${PN}.service-9.6-r1" | \
2667 + systemd_newunit - ${PN}-${SLOT}.service
2668 + systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
2669 + fi
2670 +
2671 + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
2672 +
2673 + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
2674 +
2675 + if use prefix ; then
2676 + keepdir /run/postgresql
2677 + fperms 1775 /run/postgresql
2678 + fi
2679 + fi
2680 +}
2681 +
2682 +pkg_preinst() {
2683 + # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g.,
2684 + # /usr/bin/psql96). They may have been created by the
2685 + # postgresql.eselect module, but they're handled within this ebuild
2686 + # now. It's alright if we momentarily delete /usr/bin/psql as it
2687 + # will be recreated by the eselect module in pkg_ppostinst(). This
2688 + # is only necessary for 9.7 and earlier. 10 and later were never
2689 + # handled in this manner.
2690 + local canonicalise
2691 + if type -p realpath > /dev/null; then
2692 + canonicalise=realpath
2693 + elif type -p readlink > /dev/null; then
2694 + canonicalise='readlink -f'
2695 + else
2696 + # can't die, subshell
2697 + die "No readlink nor realpath found, cannot canonicalise"
2698 + fi
2699 +
2700 + local l
2701 + # First remove any symlinks in /usr/bin that may have been created
2702 + # by the old eselect
2703 + for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do
2704 + if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then
2705 + rm "${l}" || ewarn "Couldn't remove ${l}"
2706 + fi
2707 + done
2708 +
2709 + # Then move the symlinks created by the ebuild to their proper place.
2710 + for l in "${ED}"/usr/bin/*tmp ; do
2711 + mv "${l}" "${l%tmp}" \
2712 + || ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})"
2713 + done
2714 +}
2715 +
2716 +pkg_postinst() {
2717 + use server && use systemd && systemd_tmpfiles_create ${PN}-${SLOT}.conf
2718 + postgresql-config update
2719 +
2720 + elog "If you need a global psqlrc-file, you can place it in:"
2721 + elog " ${EROOT%/}/etc/postgresql-${SLOT}/"
2722 +
2723 + if use server ; then
2724 + elog
2725 + elog "Gentoo specific documentation:"
2726 + elog "https://wiki.gentoo.org/wiki/PostgreSQL"
2727 + elog
2728 + elog "Official documentation:"
2729 + elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
2730 + elog
2731 + elog "The default location of the Unix-domain socket is:"
2732 + elog " ${EROOT%/}/run/postgresql/"
2733 + elog
2734 + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
2735 + elog "so that it contains your preferred locale in:"
2736 + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
2737 + elog
2738 + elog "Then, execute the following command to setup the initial database"
2739 + elog "environment:"
2740 + elog " emerge --config =${CATEGORY}/${PF}"
2741 + fi
2742 +}
2743 +
2744 +pkg_prerm() {
2745 + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
2746 + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
2747 + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
2748 +
2749 + ebegin "Resuming removal in 10 seconds (Control-C to cancel)"
2750 + sleep 10
2751 + eend 0
2752 + fi
2753 +}
2754 +
2755 +pkg_postrm() {
2756 + postgresql-config update
2757 +}
2758 +
2759 +pkg_config() {
2760 + use server || die "USE flag 'server' not enabled. Nothing to configure."
2761 +
2762 + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \
2763 + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
2764 + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
2765 + [[ -z "${DATA_DIR}" ]] \
2766 + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
2767 +
2768 + # environment.bz2 may not contain the same locale as the current system
2769 + # locale. Unset and source from the current system locale.
2770 + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
2771 + unset LANG
2772 + unset LC_CTYPE
2773 + unset LC_NUMERIC
2774 + unset LC_TIME
2775 + unset LC_COLLATE
2776 + unset LC_MONETARY
2777 + unset LC_MESSAGES
2778 + unset LC_ALL
2779 + source "${EROOT%/}/etc/env.d/02locale"
2780 + [ -n "${LANG}" ] && export LANG
2781 + [ -n "${LC_CTYPE}" ] && export LC_CTYPE
2782 + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
2783 + [ -n "${LC_TIME}" ] && export LC_TIME
2784 + [ -n "${LC_COLLATE}" ] && export LC_COLLATE
2785 + [ -n "${LC_MONETARY}" ] && export LC_MONETARY
2786 + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
2787 + [ -n "${LC_ALL}" ] && export LC_ALL
2788 + fi
2789 +
2790 + einfo "You can modify the paths and options passed to initdb by editing:"
2791 + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
2792 + einfo
2793 + einfo "Information on options that can be passed to initdb are found at:"
2794 + einfo " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
2795 + einfo " https://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
2796 + einfo
2797 + einfo "PG_INITDB_OPTS is currently set to:"
2798 + if [[ -z "${PG_INITDB_OPTS}" ]] ; then
2799 + einfo " (none)"
2800 + else
2801 + einfo " ${PG_INITDB_OPTS}"
2802 + fi
2803 + einfo
2804 + einfo "Configuration files will be installed to:"
2805 + einfo " ${PGDATA}"
2806 + einfo
2807 + einfo "The database cluster will be created in:"
2808 + einfo " ${DATA_DIR}"
2809 + einfo
2810 +
2811 + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)"
2812 + sleep 5
2813 + eend 0
2814 +
2815 + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
2816 + eerror "The given directory, '${DATA_DIR}', is not empty."
2817 + eerror "Modify DATA_DIR to point to an empty directory."
2818 + die "${DATA_DIR} is not empty."
2819 + fi
2820 +
2821 + einfo "Creating the data directory ..."
2822 + if [[ ${EUID} == 0 ]] ; then
2823 + mkdir -p "${DATA_DIR}"
2824 + chown -Rf postgres:postgres "${DATA_DIR}"
2825 + chmod 0700 "${DATA_DIR}"
2826 + fi
2827 +
2828 + einfo "Initializing the database ..."
2829 +
2830 + if [[ ${EUID} == 0 ]] ; then
2831 + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
2832 + else
2833 + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
2834 + fi
2835 +
2836 + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then
2837 + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}"
2838 + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}"
2839 + fi
2840 +
2841 + # unix_socket_directory has no effect in postgresql.conf as it's
2842 + # overridden in the initscript
2843 + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf
2844 +
2845 + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf
2846 + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522
2847 + # On the off-chance that you might need to work with UTF-8 encoded
2848 + # characters in PL/Perl
2849 + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
2850 + EOF
2851 +
2852 + einfo "The autovacuum function, which was in contrib, has been moved to the main"
2853 + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
2854 + einfo "by default. You can disable it in the cluster's:"
2855 + einfo " ${PGDATA%/}/postgresql.conf"
2856 + einfo
2857 + if ! use systemd; then
2858 + einfo "The PostgreSQL server, by default, will log events to:"
2859 + einfo " ${DATA_DIR%/}/postmaster.log"
2860 + einfo
2861 + fi
2862 + if use prefix ; then
2863 + einfo "The location of the configuration files have moved to:"
2864 + einfo " ${PGDATA}"
2865 + einfo "To start the server:"
2866 + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
2867 + einfo "To stop:"
2868 + einfo " pg_ctl stop -D ${DATA_DIR}"
2869 + einfo
2870 + einfo "Or move the configuration files back:"
2871 + einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
2872 + elif use systemd; then
2873 + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL"
2874 + einfo "instead of 'pg_ctl'."
2875 + else
2876 + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
2877 + einfo "instead of 'pg_ctl'."
2878 + fi
2879 +}
2880 +
2881 +src_test() {
2882 + if use server && [[ ${UID} -ne 0 ]] ; then
2883 + emake check
2884 +
2885 + einfo "If you think other tests besides the regression tests are necessary, please"
2886 + einfo "submit a bug including a patch for this ebuild to enable them."
2887 + else
2888 + use server || \
2889 + ewarn 'Tests cannot be run without the "server" use flag enabled.'
2890 + [[ ${UID} -eq 0 ]] || \
2891 + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
2892 +
2893 + ewarn 'Skipping.'
2894 + fi
2895 +}