Gentoo Archives: gentoo-commits

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