Gentoo Archives: gentoo-commits

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