Gentoo Archives: gentoo-commits

From: "Aaron Swenson (titanofold)" <titanofold@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-db/postgresql-server: postgresql-server-8.4.8-r2.ebuild ChangeLog postgresql-server-8.3.15-r2.ebuild postgresql-server-9.1_beta3-r1.ebuild postgresql-server-9.0.4-r2.ebuild postgresql-server-8.2.21-r2.ebuild
Date: Tue, 02 Aug 2011 02:14:01
Message-Id: 20110802021349.93DDB20051@flycatcher.gentoo.org
1 titanofold 11/08/02 02:13:49
2
3 Modified: ChangeLog
4 Added: postgresql-server-8.4.8-r2.ebuild
5 postgresql-server-8.3.15-r2.ebuild
6 postgresql-server-9.1_beta3-r1.ebuild
7 postgresql-server-9.0.4-r2.ebuild
8 postgresql-server-8.2.21-r2.ebuild
9 Log:
10 Fixes bug 368177 and hopefully bug 341729
11
12 (Portage version: 2.1.10.3/cvs/Linux i686)
13
14 Revision Changes Path
15 1.134 dev-db/postgresql-server/ChangeLog
16
17 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/ChangeLog?rev=1.134&view=markup
18 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/ChangeLog?rev=1.134&content-type=text/plain
19 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/ChangeLog?r1=1.133&r2=1.134
20
21 Index: ChangeLog
22 ===================================================================
23 RCS file: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/ChangeLog,v
24 retrieving revision 1.133
25 retrieving revision 1.134
26 diff -u -r1.133 -r1.134
27 --- ChangeLog 23 Jul 2011 17:01:47 -0000 1.133
28 +++ ChangeLog 2 Aug 2011 02:13:49 -0000 1.134
29 @@ -1,6 +1,18 @@
30 # ChangeLog for dev-db/postgresql-server
31 # Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
32 -# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/ChangeLog,v 1.133 2011/07/23 17:01:47 titanofold Exp $
33 +# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/ChangeLog,v 1.134 2011/08/02 02:13:49 titanofold Exp $
34 +
35 +*postgresql-server-9.1_beta3-r1 (02 Aug 2011)
36 +*postgresql-server-9.0.4-r2 (02 Aug 2011)
37 +*postgresql-server-8.4.8-r2 (02 Aug 2011)
38 +*postgresql-server-8.3.15-r2 (02 Aug 2011)
39 +*postgresql-server-8.2.21-r2 (02 Aug 2011)
40 +
41 + 02 Aug 2011; Aaron W. Swenson <titanofold@g.o>
42 + +postgresql-server-8.2.21-r2.ebuild, +postgresql-server-8.3.15-r2.ebuild,
43 + +postgresql-server-8.4.8-r2.ebuild, +postgresql-server-9.0.4-r2.ebuild,
44 + +postgresql-server-9.1_beta3-r1.ebuild:
45 + Fixes bug 368177 and hopefully bug 341729
46
47 23 Jul 2011; Aaron W. Swenson <titanofold@g.o>
48 -postgresql-server-8.2.21.ebuild, -postgresql-server-8.3.15.ebuild,
49
50
51
52 1.1 dev-db/postgresql-server/postgresql-server-8.4.8-r2.ebuild
53
54 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.4.8-r2.ebuild?rev=1.1&view=markup
55 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.4.8-r2.ebuild?rev=1.1&content-type=text/plain
56
57 Index: postgresql-server-8.4.8-r2.ebuild
58 ===================================================================
59 # Copyright 1999-2011 Gentoo Foundation
60 # Distributed under the terms of the GNU General Public License v2
61 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.4.8-r2.ebuild,v 1.1 2011/08/02 02:13:49 titanofold Exp $
62
63 EAPI="3"
64 PYTHON_DEPEND="python? 2"
65
66 WANT_AUTOMAKE="none"
67 inherit autotools eutils multilib pam prefix python versionator
68
69 SLOT="$(get_version_component_range 1-2)"
70
71 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
72
73 DESCRIPTION="PostgreSQL server"
74 HOMEPAGE="http://www.postgresql.org/"
75 SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2
76 http://dev.gentoo.org/~titanofold/postgresql-patches-${SLOT}-r1.tbz2
77 http://dev.gentoo.org/~titanofold/postgresql-initscript-1.2.tbz2"
78 LICENSE="POSTGRESQL"
79
80 S="${WORKDIR}/postgresql-${PV}"
81
82 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN zh_TW"
83 IUSE="doc kernel_linux nls pam perl -pg_legacytimestamp python selinux tcl uuid xml"
84
85 for lingua in ${LINGUAS} ; do
86 IUSE+=" linguas_${lingua}"
87 done
88
89 wanted_languages() {
90 local enable_langs
91
92 for lingua in ${LINGUAS} ; do
93 use linguas_${lingua} && enable_langs+="${lingua} "
94 done
95
96 echo -n ${enable_langs}
97 }
98
99 RDEPEND="~dev-db/postgresql-base-${PV}:${SLOT}[pam?,pg_legacytimestamp=,nls=]
100 perl? ( >=dev-lang/perl-5.8 )
101 selinux? ( sec-policy/selinux-postgresql )
102 tcl? ( >=dev-lang/tcl-8 )
103 uuid? ( dev-libs/ossp-uuid )
104 xml? ( dev-libs/libxml2 dev-libs/libxslt )"
105
106 DEPEND="${RDEPEND}
107 sys-devel/flex
108 xml? ( dev-util/pkgconfig )"
109
110 PDEPEND="doc? ( ~dev-db/postgresql-docs-${PV} )"
111
112 pkg_setup() {
113 enewgroup postgres 70
114 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
115
116 use python && python_set_active_version 2
117 }
118
119 src_prepare() {
120 epatch "${WORKDIR}/autoconf.patch" "${WORKDIR}/bool.patch" \
121 "${WORKDIR}/darwin.patch" "${WORKDIR}/ldflags.patch" \
122 "${WORKDIR}/pg_ctl-exit-status.patch" "${WORKDIR}/server.patch" \
123 "${WORKDIR}/SuperH.patch"
124
125 eprefixify src/include/pg_config_manual.h
126
127 if use test ; then
128 epatch "${WORKDIR}/regress.patch"
129 sed -e "s|@SOCKETDIR@|${T}|g" -i src/test/regress/pg_regress{,_main}.c
130 sed -e "s|/no/such/location|${S}/src/test/regress/tmp_check/no/such/location|g" \
131 -i src/test/regress/{input,output}/tablespace.source
132 else
133 echo "all install:" > "${S}/src/test/regress/GNUmakefile"
134 fi
135
136 eautoconf
137 }
138
139 src_configure() {
140 # eval is needed to get along with pg_config quotation of space-rich entities.
141 eval econf "$(${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --configure)" \
142 --with-includes="${EPREFIX%/}/usr/include/postgresql-${SLOT}/" \
143 --with-libraries="${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/$(get_libdir)" \
144 --with-system-tzdata="${EPREFIX%/}/usr/share/zoneinfo" \
145 $(use_with perl) \
146 $(use_with python) \
147 $(use_with tcl) \
148 $(use_with xml libxml) \
149 $(use_with xml libxslt) \
150 $(use_with uuid ossp-uuid) \
151 "$(has_version ~dev-db/postgresql-base-${PV}[nls] && use_enable nls nls "$(wanted_languages)")"
152 }
153
154 src_compile() {
155 local bd
156 for bd in . contrib $(use xml && echo contrib/xml2) ; do
157 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
158 emake -C $bd -j1 || die "emake in $bd failed"
159 done
160 }
161
162 src_install() {
163 if use perl ; then
164 mv -f "${S}/src/pl/plperl/GNUmakefile" "${S}/src/pl/plperl/GNUmakefile_orig"
165 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \
166 "${S}/src/pl/plperl/GNUmakefile_orig" > "${S}/src/pl/plperl/GNUmakefile"
167 fi
168
169 local bd
170 for bd in . contrib $(use xml && echo contrib/xml2) ; do
171 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
172 emake install -C $bd -j1 DESTDIR="${D}" || die "emake install in $bd failed"
173 done
174
175 rm -r "${ED}/usr/share/postgresql-${SLOT}/man/man7/" "${ED}/usr/share/doc/postgresql-${SLOT}/html"
176 rm "${ED}"/usr/share/postgresql-${SLOT}/man/man1/{clusterdb,create{db,lang,user},drop{db,lang,user},ecpg,pg_{config,dump,dumpall,restore},psql,reindexdb,vacuumdb}.1
177
178 dodoc README HISTORY doc/{README.*,TODO,bug.template}
179
180 dodir /etc/eselect/postgresql/slots/${SLOT}
181 echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" \
182 > "${ED}/etc/eselect/postgresql/slots/${SLOT}/server"
183
184 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}"/postgresql.confd
185 newconfd "${WORKDIR}"/postgresql.confd postgresql-${SLOT} || die "Inserting conf.d file failed"
186 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}"/postgresql.init
187 newinitd "${WORKDIR}"/postgresql.init postgresql-${SLOT} || die "Inserting init.d file failed"
188
189 use pam && pamd_mimic system-auth postgresql auth account session
190
191 keepdir /var/run/postgresql
192 fperms 0770 /var/run/postgresql
193 use prefix || fowners postgres:postgres /var/run/postgresql
194 }
195
196 pkg_postinst() {
197 postgresql-config update
198
199 elog "The time stamp format is 64 bit integers now. If you upgrade from older"
200 elog "databases, this may force you to either do a dump and reload of enable"
201 elog "pg_legacytimestamp until you find time to do so. If the database can't start"
202 elog "please try enabling pg_legacytimestamp and rebuild."
203 elog
204 elog "The Unix-domain socket is located in:"
205 elog " ${EROOT%/}/var/run/postgresql/"
206 elog
207 elog "If you have users and/or services that you would like to utilize the socket,"
208 elog "you must add them to the 'postgres' system group:"
209 elog " usermod -a -G postgres <user>"
210 elog
211 elog "Before initializing the database, you may want to edit PG_INITDB_OPTS so that"
212 elog "it contains your preferred locale and character encoding in:"
213 elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
214 elog
215 elog "Then, execute the following command to setup the initial database"
216 elog "environment:"
217 elog " emerge --config =${CATEGORY}/${PF}"
218 }
219
220 pkg_postrm() {
221 postgresql-config update
222 }
223
224 pkg_config() {
225 [[ -f ${EROOT%/}/etc/conf.d/postgresql-${SLOT} ]] && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
226 [[ -z ${PGDATA} ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
227 [[ -z ${DATA_DIR} ]] && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
228
229 # environment.bz2 may not contain the same locale as the current system
230 # locale. Unset and source from the current system locale.
231 if [[ -f ${EROOT%/}/etc/env.d/02locale ]] ; then
232 unset LANG
233 unset LC_CTYPE
234 unset LC_NUMERIC
235 unset LC_TIME
236 unset LC_COLLATE
237 unset LC_MONETARY
238 unset LC_MESSAGES
239 unset LC_ALL
240 source "${EROOT%/}/etc/env.d/02locale"
241 [[ -n ${LANG} ]] && export LANG
242 [[ -n ${LC_CTYPE} ]] && export LC_CTYPE
243 [[ -n ${LC_NUMERIC} ]] && export LC_NUMERIC
244 [[ -n ${LC_TIME} ]] && export LC_TIME
245 [[ -n ${LC_COLLATE} ]] && export LC_COLLATE
246 [[ -n ${LC_MONETARY} ]] && export LC_MONETARY
247 [[ -n ${LC_MESSAGES} ]] && export LC_MESSAGES
248 [[ -n ${LC_ALL} ]] && export LC_ALL
249 fi
250
251 einfo "You can modify the paths and options passed to initdb by editing:"
252 einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
253 einfo
254 einfo "Information on options that can be passed to initdb are found at:"
255 einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
256 einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
257 einfo
258 einfo "PG_INITDB_OPTS is currently set to:"
259 if [[ -z ${PG_INITDB_OPTS} ]] ; then
260 einfo " (none)"
261 else
262 einfo " ${PG_INITDB_OPTS}"
263 fi
264 einfo
265 einfo "Configuration files will be installed to:"
266 einfo " ${PGDATA}"
267 einfo
268 einfo "The database cluster will be created in:"
269 einfo " ${DATA_DIR}"
270 einfo
271 while [[ $correct != "true" ]] ; do
272 einfo "Are you ready to continue? (y/n)"
273 read answer
274 if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
275 correct="true"
276 elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
277 die "Aborting initialization."
278 else
279 echo "Answer not recognized"
280 fi
281 done
282
283 if [[ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ]] ; then
284 eerror "The given directory, '${DATA_DIR}', is not empty."
285 eerror "Modify DATA_DIR to point to an empty directory."
286 die "${DATA_DIR} is not empty."
287 fi
288
289 [[ -z ${PG_MAX_CONNECTIONS} ]] && PG_MAX_CONNECTIONS=128
290 einfo "Checking system parameters..."
291
292 if ! use kernel_linux ; then
293 einfo "Skipped."
294 einfo " Tests not supported on this OS (yet)"
295 else
296 if [[ -z ${SKIP_SYSTEM_TESTS} ]] ; then
297 einfo "Checking whether your system supports at least ${PG_MAX_CONNECTIONS} connections..."
298
299 local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
300 local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
301 local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
302 local SHMMAX=$(sysctl -n kernel.shmmax)
303
304 local SEMMSL_MIN=17
305 local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
306 local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
307 local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
308
309 for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
310 if [[ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ]] ; then
311 eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
312 eerror "You have now several options:"
313 eerror " - Change the mentioned system parameter"
314 eerror " - Lower the number of max.connections by setting PG_MAX_CONNECTIONS to a"
315 eerror " value lower than ${PG_MAX_CONNECTIONS}"
316 eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test completely"
317 eerror "More information can be found here:"
318 eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
319 die "System test failed."
320 fi
321 done
322 einfo "Passed."
323 else
324 ewarn "SKIP_SYSTEM_TESTS set, so skipping."
325 fi
326 fi
327
328 if [[ ${EUID} == 0 ]] ; then
329 einfo "Creating the data directory ..."
330 mkdir -p "${DATA_DIR}"
331 chown -Rf postgres:postgres "${DATA_DIR}"
332 chmod 0700 "${DATA_DIR}"
333 fi
334
335 einfo "Initializing the database ..."
336 if [[ ${EUID} == 0 ]] ; then
337 su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
338 else
339 "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
340 fi
341 mv "${DATA_DIR%/}"/*.conf "${PGDATA}"
342
343 einfo "The autovacuum function, which was in contrib, has been moved to the main"
344 einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled by"
345 einfo "default. You can disable it in the cluster's:"
346 einfo " ${PGDATA%/}/postgresql.conf"
347 einfo
348 einfo "The PostgreSQL server, by default, will log events to:"
349 einfo " ${DATA_DIR%/}/postmaster.log"
350 einfo
351 if use prefix ; then
352 einfo "The location of the configuration files have moved to:"
353 einfo " ${PGDATA}"
354 einfo
355 einfo "To start the server:"
356 einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
357 einfo
358 einfo "To stop:"
359 einfo " pg_ctl stop -D ${DATA_DIR}"
360 einfo
361 einfo "Or move the configuration files back:"
362 einfo " mv ${PGDATA}*.conf ${DATA_DIR}"
363 else
364 einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
365 einfo "instead of 'pg_ctl'."
366 fi
367 }
368
369 src_test() {
370 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
371
372 if [[ ${UID} != 0 ]] ; then
373 emake check || die "Make check failed. See above for details."
374
375 einfo "If you think other tests besides the regression tests are necessary, please"
376 einfo "submit a bug including a patch for this ebuild to enable them."
377 else
378 ewarn "Tests cannot be run as root. Skipping."
379 ewarn "HINT: FEATURES=\"userpriv\""
380 fi
381 }
382
383
384
385 1.1 dev-db/postgresql-server/postgresql-server-8.3.15-r2.ebuild
386
387 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.3.15-r2.ebuild?rev=1.1&view=markup
388 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.3.15-r2.ebuild?rev=1.1&content-type=text/plain
389
390 Index: postgresql-server-8.3.15-r2.ebuild
391 ===================================================================
392 # Copyright 1999-2011 Gentoo Foundation
393 # Distributed under the terms of the GNU General Public License v2
394 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.3.15-r2.ebuild,v 1.1 2011/08/02 02:13:49 titanofold Exp $
395
396 EAPI="4"
397
398 WANT_AUTOMAKE="none"
399 inherit autotools eutils multilib pam prefix versionator
400
401 SLOT="$(get_version_component_range 1-2)"
402
403 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
404
405 DESCRIPTION="PostgreSQL server"
406 HOMEPAGE="http://www.postgresql.org/"
407 SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2
408 http://dev.gentoo.org/~titanofold/postgresql-patches-${SLOT}-r1.tbz2
409 http://dev.gentoo.org/~titanofold/postgresql-initscript-1.2.tbz2"
410 LICENSE="POSTGRESQL"
411
412 S="${WORKDIR}/postgresql-${PV}"
413
414 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN zh_TW"
415 IUSE="doc kernel_linux nls pam perl python selinux tcl uuid xml"
416
417 for lingua in ${LINGUAS} ; do
418 IUSE+=" linguas_${lingua}"
419 done
420
421 wanted_languages() {
422 local enable_langs
423
424 for lingua in ${LINGUAS} ; do
425 use linguas_${lingua} && enable_langs+="${lingua} "
426 done
427
428 echo -n ${enable_langs}
429 }
430
431 RDEPEND="~dev-db/postgresql-base-${PV}:${SLOT}[pam?,nls=]
432 perl? ( >=dev-lang/perl-5.8 )
433 selinux? ( sec-policy/selinux-postgresql )
434 tcl? ( >=dev-lang/tcl-8 )
435 uuid? ( dev-libs/ossp-uuid )
436 xml? ( dev-libs/libxml2 dev-libs/libxslt )"
437
438 DEPEND="${RDEPEND}
439 sys-devel/flex
440 xml? ( dev-util/pkgconfig )"
441
442 PDEPEND="doc? ( ~dev-db/postgresql-docs-${PV} )"
443
444 pkg_setup() {
445 enewgroup postgres 70
446 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
447 }
448
449 src_prepare() {
450 epatch "${WORKDIR}/autoconf.patch" "${WORKDIR}/bool.patch" \
451 "${WORKDIR}/darwin.patch" "${WORKDIR}/pg_ctl-exit-status.patch" \
452 "${WORKDIR}/server.patch" "${WORKDIR}/SuperH.patch"
453
454 eprefixify src/include/pg_config_manual.h
455
456 if use test ; then
457 epatch "${WORKDIR}/regress.patch"
458 sed -e "s|@SOCKETDIR@|${T}|g" -i src/test/regress/pg_regress{,_main}.c
459 sed -e "s|/no/such/location|${S}/src/test/regress/tmp_check/no/such/location|g" \
460 -i src/test/regress/{input,output}/tablespace.source
461 else
462 echo "all install:" > "${S}/src/test/regress/GNUmakefile"
463 fi
464
465 eautoconf
466 }
467
468 src_configure() {
469 # eval is needed to get along with pg_config quotation of space-rich entities.
470 eval econf "$(${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --configure)" \
471 --with-includes="${EPREFIX%/}/usr/include/postgresql-${SLOT}/" \
472 --with-system-tzdata="${EPREFIX%/}/usr/share/zoneinfo" \
473 $(use_with perl) \
474 $(use_with python) \
475 $(use_with tcl) \
476 $(use_with xml libxml) \
477 $(use_with xml libxslt) \
478 $(use_with uuid ossp-uuid) \
479 "$(has_version ~dev-db/postgresql-base-${PV}[nls] && use_enable nls nls "$(wanted_languages)")"
480 }
481
482 src_compile() {
483 local bd
484 for bd in . contrib $(use xml && echo contrib/xml2); do
485 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
486 emake -C $bd -j1 \
487 PGXS=$(${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --pgxs) \
488 PGXS_IN_SERVER=1 PGXS_WITH_SERVER="${S}/src/backend/postgres" \
489 NO_PGXS=0 USE_PGXS=1 docdir=${EROOT%/}/usr/share/doc/${PF}
490 done
491 }
492
493 src_install() {
494 if use perl ; then
495 mv -f "${S}/src/pl/plperl/GNUmakefile" "${S}/src/pl/plperl/GNUmakefile_orig"
496 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \
497 "${S}/src/pl/plperl/GNUmakefile_orig" > "${S}/src/pl/plperl/GNUmakefile"
498 fi
499
500 local bd
501 for bd in . contrib $(use xml && echo contrib/xml2) ; do
502 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
503 emake install -C $bd -j1 DESTDIR="${D}" \
504 PGXS_IN_SERVER=1 PGXS_WITH_SERVER="${S}/src/backend/postgres" \
505 PGXS=$(${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --pgxs) \
506 NO_PGXS=0 USE_PGXS=1 docdir=${EROOT%/}/usr/share/doc/${PF}
507 done
508
509 rm -r "${ED}/usr/share/postgresql-${SLOT}/man/man7/" "${ED}/usr/share/doc/${PF}/html"
510 rm "${ED}"/usr/share/postgresql-${SLOT}/man/man1/{clusterdb,create{db,lang,user},drop{db,lang,user},ecpg,pg_{config,dump,dumpall,restore},psql,reindexdb,vacuumdb}.1
511 docompress /usr/share/postgresql-${SLOT}/man/man1
512
513 dodoc README HISTORY doc/{README.*,TODO,bug.template}
514
515 dodir /etc/eselect/postgresql/slots/${SLOT}
516 echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" \
517 > "${ED}/etc/eselect/postgresql/slots/${SLOT}/server"
518
519 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}"/postgresql.confd
520 newconfd "${WORKDIR}/postgresql.confd" postgresql-${SLOT}
521 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}"/postgresql.init
522 newinitd "${WORKDIR}/postgresql.init" postgresql-${SLOT}
523
524 use pam && pamd_mimic system-auth postgresql auth account session
525
526 keepdir /var/run/postgresql
527 fperms 0770 /var/run/postgresql
528 use prefix || fowners postgres:postgres /var/run/postgresql
529 }
530
531 pkg_postinst() {
532 postgresql-config update
533
534 elog "The Unix-domain socket is located in:"
535 elog " ${EROOT%/}/var/run/postgresql/"
536 elog
537 elog "If you have users and/or services that you would like to utilize the socket,"
538 elog "you must add them to the 'postgres' system group:"
539 elog " usermod -a -G postgres <user>"
540 elog
541 elog "Before initializing the database, you may want to edit PG_INITDB_OPTS so that"
542 elog "it contains your preferred locale in:"
543 elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
544 elog
545 elog "Execute the following command to setup the initial database"
546 elog "environment:"
547 elog " emerge --config =${CATEGORY}/${PF}"
548 }
549
550 pkg_postrm() {
551 postgresql-config update
552 }
553
554 pkg_config() {
555 [[ -f ${EROOT%/}/etc/conf.d/postgresql-${SLOT} ]] && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
556 [[ -z ${PGDATA} ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
557 [[ -z ${DATA_DIR} ]] && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
558
559 # environment.bz2 may not contain the same locale as the current system
560 # locale. Unset and source from the current system locale.
561 if [[ -f ${EROOT%/}/etc/env.d/02locale ]] ; then
562 unset LANG
563 unset LC_CTYPE
564 unset LC_NUMERIC
565 unset LC_TIME
566 unset LC_COLLATE
567 unset LC_MONETARY
568 unset LC_MESSAGES
569 unset LC_ALL
570 source ${EROOT%/}/etc/env.d/02locale
571 [[ -n ${LANG} ]] && export LANG
572 [[ -n ${LC_CTYPE} ]] && export LC_CTYPE
573 [[ -n ${LC_NUMERIC} ]] && export LC_NUMERIC
574 [[ -n ${LC_TIME} ]] && export LC_TIME
575 [[ -n ${LC_COLLATE} ]] && export LC_COLLATE
576 [[ -n ${LC_MONETARY} ]] && export LC_MONETARY
577 [[ -n ${LC_MESSAGES} ]] && export LC_MESSAGES
578 [[ -n ${LC_ALL} ]] && export LC_ALL
579 fi
580
581 einfo "You can modify the paths and options passed to initdb by editing:"
582 einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
583 einfo
584 einfo "Information on options that can be passed to initdb are found at:"
585 einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
586 einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
587 einfo
588 einfo "PG_INITDB_OPTS is currently set to:"
589 if [[ -z ${PG_INITDB_OPTS} ]] ; then
590 einfo " (none)"
591 else
592 einfo " ${PG_INITDB_OPTS}"
593 fi
594 einfo
595 einfo "Configuration files will be installed to:"
596 einfo " ${PGDATA}"
597 einfo
598 einfo "The database cluster will be created in:"
599 einfo " ${DATA_DIR}"
600 einfo
601 while [[ $correct != "true" ]] ; do
602 einfo "Are you ready to continue? (y/n)"
603 read answer
604 if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
605 correct="true"
606 elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
607 die "Aborting initialization."
608 else
609 echo "Answer not recognized."
610 fi
611 done
612
613 if [[ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ]] ; then
614 eerror "The given directory, '${DATA_DIR}', is not empty."
615 eerror "Modify DATA_DIR to point to an empty directory."
616 die "${DATA_DIR} is not empty."
617 fi
618
619 [[ -z ${PG_MAX_CONNECTIONS} ]] && PG_MAX_CONNECTIONS=128
620 einfo "Checking system parameters..."
621
622 if ! use kernel_linux ; then
623 einfo "Skipped."
624 einfo "Tests not supported on this OS (yet)."
625 else
626 if [[ -z ${SKIP_SYSTEM_TESTS} ]] ; then
627 einfo "Checking whether your system supports at least ${PG_MAX_CONNECTIONS} connections..."
628
629 local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
630 local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
631 local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
632 local SHMMAX=$(sysctl -n kernel.shmmax)
633
634 local SEMMSL_MIN=17
635 local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
636 local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
637 local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
638
639 for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
640 if [[ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ]] ; then
641 eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
642 eerror "You have now several options:"
643 eerror " - Change the mentioned system parameter"
644 eerror " - Lower the number of max connections by setting PG_MAX_CONNECTIONS to a"
645 eerror " value lower than ${PG_MAX_CONNECTIONS}"
646 eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test completely"
647 eerror "More information can be found here:"
648 eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
649 die "System test failed."
650 fi
651 done
652 einfo "Passed."
653 else
654 ewarn "SKIP_SYSTEM_TESTS is set, so skipping."
655 fi
656 fi
657
658 if [[ ${EUID} == 0 ]] ; then
659 einfo "Creating the data directory ..."
660 mkdir -p "${DATA_DIR}"
661 chown -Rf postgres:postgres "${DATA_DIR}"
662 chmod 0700 "${DATA_DIR}"
663 fi
664
665 einfo "Initializing the database ..."
666 if [[ ${EUID} == 0 ]] ; then
667 su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
668 else
669 "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
670 fi
671 mv "${DATA_DIR%/}"/*.conf "${PGDATA}"
672
673 einfo "The autovacuum function, which was in contrib, has been moved to the main"
674 einfo "PostgreSQL functions starting with 8.1. You can enable it in the clusters"
675 einfo "postgresql.conf."
676 einfo
677 if use prefix ; then
678 einfo "The location of the configuration files have moved to:"
679 einfo " ${PGDATA}"
680 einfo
681 einfo "To start the server:"
682 einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
683 einfo
684 einfo "To stop:"
685 einfo " pg_ctl stop -D ${DATA_DIR}"
686 einfo
687 einfo "Or move the configuration files back:"
688 einfo " mv ${PGDATA}*.conf ${DATA_DIR}"
689 else
690 einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
691 einfo "instead of 'pg_ctl'."
692 fi
693 }
694
695 src_test() {
696 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
697
698 if [[ ${UID} != 0 ]] ; then
699 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/:${PATH}" \
700 emake check \
701 PGXS=$(${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --pgxs) \
702 NO_PGXS=0 USE_PGXS=1 SLOT=${SLOT}
703
704 einfo "If you think other tests besides the regression tests are necessary, please"
705 einfo "submit a bug including a patch for this ebuild to enable them."
706 else
707 ewarn "Tests cannot be run as root. Skipping."
708 ewarn "HINT: FEATURES=\"userpriv\""
709 fi
710 }
711
712
713
714 1.1 dev-db/postgresql-server/postgresql-server-9.1_beta3-r1.ebuild
715
716 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-9.1_beta3-r1.ebuild?rev=1.1&view=markup
717 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-9.1_beta3-r1.ebuild?rev=1.1&content-type=text/plain
718
719 Index: postgresql-server-9.1_beta3-r1.ebuild
720 ===================================================================
721 # Copyright 1999-2011 Gentoo Foundation
722 # Distributed under the terms of the GNU General Public License v2
723 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/postgresql-server-9.1_beta3-r1.ebuild,v 1.1 2011/08/02 02:13:49 titanofold Exp $
724
725 EAPI="3"
726 PYTHON_DEPEND="python? 2"
727
728 WANT_AUTOMAKE="none"
729 inherit autotools eutils flag-o-matic multilib pam prefix python versionator
730
731 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~ppc-macos ~x86-solaris"
732
733 # Upstream doesn't have an underscore in the file name
734 MY_PV=${PV/_/}
735
736 DESCRIPTION="PostgreSQL server"
737 HOMEPAGE="http://www.postgresql.org/"
738 SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2
739 http://dev.gentoo.org/~titanofold/postgresql-patches-${MY_PV}-r1.tbz2
740 http://dev.gentoo.org/~titanofold/postgresql-initscript-1.2.tbz2"
741 LICENSE="POSTGRESQL"
742
743 S="${WORKDIR}/postgresql-${MY_PV}"
744 SLOT="$(get_version_component_range 1-2)"
745
746 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN zh_TW"
747 IUSE="doc kernel_linux nls pam perl -pg_legacytimestamp python selinux tcl uuid xml"
748
749 for lingua in ${LINGUAS}; do
750 IUSE+=" linguas_${lingua}"
751 done
752
753 wanted_languages() {
754 local enable_langs
755
756 for lingua in ${LINGUAS} ; do
757 use linguas_${lingua} && enable_langs+="${lingua} "
758 done
759
760 echo -n ${enable_langs}
761 }
762
763 RDEPEND="~dev-db/postgresql-base-${PV}:${SLOT}[pam?,pg_legacytimestamp=,nls=]
764 perl? ( >=dev-lang/perl-5.8 )
765 selinux? ( sec-policy/selinux-postgresql )
766 tcl? ( >=dev-lang/tcl-8 )
767 uuid? ( dev-libs/ossp-uuid )
768 xml? ( dev-libs/libxml2 dev-libs/libxslt )"
769 DEPEND="${RDEPEND}
770 sys-devel/flex
771 xml? ( dev-util/pkgconfig )"
772 PDEPEND="doc? ( ~dev-db/postgresql-docs-${PV} )"
773
774 pkg_setup() {
775 enewgroup postgres 70
776 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
777
778 use python && python_set_active_version 2
779 }
780
781 src_prepare() {
782 epatch "${WORKDIR}/autoconf.patch" "${WORKDIR}/bool.patch" \
783 "${WORKDIR}/pg_ctl-exit-status.patch" "${WORKDIR}/server.patch"
784
785 eprefixify src/include/pg_config_manual.h
786
787 if use test ; then
788 epatch "${WORKDIR}/regress.patch"
789 sed -e "s|@SOCKETDIR@|${T}|g" -i src/test/regress/pg_regress{,_main}.c
790 sed -e "s|/no/such/location|${S}/src/test/regress/tmp_check/no/such/location|g" -i src/test/regress/{input,output}/tablespace.source
791 else
792 echo "all install:" > "${S}/src/test/regress/GNUmakefile"
793 fi
794
795 eautoconf
796 }
797
798 src_configure() {
799 case ${CHOST} in
800 *-darwin*|*-solaris*)
801 use nls && append-libs intl
802 ;;
803 esac
804
805 local PO="${EPREFIX%/}"
806
807 # eval is needed to get along with pg_config quotation of space-rich entities.
808 eval econf "$(${PO}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --configure)" \
809 $(use_with perl) \
810 $(use_with python) \
811 $(use_with tcl) \
812 $(use_with xml libxml) \
813 $(use_with xml libxslt) \
814 $(use_with uuid ossp-uuid) \
815 --with-system-tzdata="${PO}/usr/share/zoneinfo" \
816 --with-includes="${PO}/usr/include/postgresql-${SLOT}/" \
817 --with-libraries="${PO}/usr/$(get_libdir)/postgresql-${SLOT}/$(get_libdir)" \
818 "$(use_enable nls nls "$(wanted_languages)")"
819 }
820
821 src_compile() {
822 local bd
823 for bd in . contrib $(use xml && echo contrib/xml2); do
824 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
825 emake -C $bd || die "emake in $bd failed"
826 done
827 }
828
829 src_install() {
830 if use perl ; then
831 mv -f "${S}/src/pl/plperl/GNUmakefile" "${S}/src/pl/plperl/GNUmakefile_orig"
832 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \
833 "${S}/src/pl/plperl/GNUmakefile_orig" > "${S}/src/pl/plperl/GNUmakefile"
834 fi
835
836 local bd
837 for bd in . contrib $(use xml && echo contrib/xml2) ; do
838 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
839 emake install -C $bd DESTDIR="${D}" || die "emake install in $bd failed"
840 done
841
842 dodoc README HISTORY doc/{README.*,TODO,bug.template}
843
844 dodir /etc/eselect/postgresql/slots/${SLOT}
845 echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" > \
846 "${ED}/etc/eselect/postgresql/slots/${SLOT}/server"
847
848 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}"/postgresql.confd
849 newconfd "${WORKDIR}/postgresql.confd" postgresql-${SLOT} || die "Inserting conf failed"
850 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}"/postgresql.init
851 newinitd "${WORKDIR}/postgresql.init" postgresql-${SLOT} || die "Inserting conf failed"
852
853 use pam && pamd_mimic system-auth postgresql auth account session
854
855 keepdir /var/run/postgresql
856 fperms 0770 /var/run/postgresql
857 use prefix || fowners postgres:postgres /var/run/postgresql
858 }
859
860 pkg_postinst() {
861 postgresql-config update
862
863 elog "The Unix-domain socket is located in:"
864 elog " ${EROOT%/}/var/run/postgresql/"
865 elog
866 elog "If you have users and/or services that you would like to utilize the socket,"
867 elog "you must add them to the 'postgres' system group:"
868 elog " usermod -a -G postgres <user>"
869 elog
870 elog "Before initializing the database, you may want to edit PG_INITDB_OPTS so that"
871 elog "it contains your preferred locale in:"
872 elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
873 elog
874 elog "Then, execute the following command to setup the initial database"
875 elog "environment:"
876 elog " emerge --config =${CATEGORY}/${PF}"
877 }
878
879 pkg_postrm() {
880 postgresql-config update
881 }
882
883 pkg_config() {
884 [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
885 [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
886 [[ -z "${DATA_DIR}" ]] && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
887
888 # environment.bz2 may not contain the same locale as the current system
889 # locale. Unset and source from the current system locale.
890 if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then
891 unset LANG
892 unset LC_CTYPE
893 unset LC_NUMERIC
894 unset LC_TIME
895 unset LC_COLLATE
896 unset LC_MONETARY
897 unset LC_MESSAGES
898 unset LC_ALL
899 source "${EROOT%/}/etc/env.d/02locale"
900 [ -n "${LANG}" ] && export LANG
901 [ -n "${LC_CTYPE}" ] && export LC_CTYPE
902 [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
903 [ -n "${LC_TIME}" ] && export LC_TIME
904 [ -n "${LC_COLLATE}" ] && export LC_COLLATE
905 [ -n "${LC_MONETARY}" ] && export LC_MONETARY
906 [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
907 [ -n "${LC_ALL}" ] && export LC_ALL
908 fi
909
910 einfo "You can modify the paths and options passed to initdb by editing:"
911 einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
912 einfo
913 einfo "Information on options that can be passed to initdb are found at:"
914 einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
915 einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
916 einfo
917 einfo "PG_INITDB_OPTS is currently set to:"
918 if [[ -z "${PG_INITDB_OPTS}" ]] ; then
919 einfo " (none)"
920 else
921 einfo " ${PG_INITDB_OPTS}"
922 fi
923 einfo
924 einfo "Configuration files will be installed to:"
925 einfo " ${PGDATA}"
926 einfo
927 einfo "The database cluster will be created in:"
928 einfo " ${DATA_DIR}"
929 einfo
930 while [ "$correct" != "true" ] ; do
931 einfo "Are you ready to continue? (y/n)"
932 read answer
933 if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
934 correct="true"
935 elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
936 die "Aborting initialization."
937 else
938 echo "Answer not recognized"
939 fi
940 done
941
942 if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
943 eerror "The given directory, '${DATA_DIR}', is not empty."
944 eerror "Modify DATA_DIR to point to an empty directory."
945 die "${DATA_DIR} is not empty."
946 fi
947
948 [ -z "${PG_MAX_CONNECTIONS}" ] && PG_MAX_CONNECTIONS="128"
949 einfo "Checking system parameters..."
950
951 if ! use kernel_linux ; then
952 einfo "Skipped."
953 einfo " Tests not supported on this OS (yet)"
954 else
955 if [ -z ${SKIP_SYSTEM_TESTS} ] ; then
956 einfo "Checking whether your system supports at least ${PG_MAX_CONNECTIONS} connections..."
957
958 local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
959 local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
960 local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
961 local SHMMAX=$(sysctl -n kernel.shmmax)
962
963 local SEMMSL_MIN=17
964 local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
965 local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
966 local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
967
968 for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
969 if [ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ] ; then
970 eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
971 eerror "You have now several options:"
972 eerror " - Change the mentioned system parameter"
973 eerror " - Lower the number of max.connections by setting PG_MAX_CONNECTIONS to a"
974 eerror " value lower than ${PG_MAX_CONNECTIONS}"
975 eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test completely"
976 eerror "More information can be found here:"
977 eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
978 die "System test failed."
979 fi
980 done
981 einfo "Passed."
982 else
983 ewarn "SKIP_SYSTEM_TESTS set, so skipping."
984 fi
985 fi
986
987 einfo "Creating the data directory ..."
988 if [[ ${EUID} == 0 ]] ; then
989 mkdir -p "${DATA_DIR}"
990 chown -Rf postgres:postgres "${DATA_DIR}"
991 chmod 0700 "${DATA_DIR}"
992 fi
993
994 einfo "Initializing the database ..."
995
996 if [[ ${EUID} == 0 ]] ; then
997 su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
998 else
999 "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
1000 fi
1001
1002 mv "${DATA_DIR%/}"/*.conf "${PGDATA}"
1003
1004 einfo "The autovacuum function, which was in contrib, has been moved to the main"
1005 einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
1006 einfo "by default. You can disable it in the cluster's:"
1007 einfo " ${PGDATA%/}/postgresql.conf"
1008 einfo
1009 einfo "The PostgreSQL server, by default, will log events to:"
1010 einfo " ${DATA_DIR%/}/postmaster.log"
1011 einfo
1012 if use prefix ; then
1013 einfo "The location of the configuration files have moved to:"
1014 einfo " ${PGDATA}"
1015 einfo "To start the server:"
1016 einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
1017 einfo "To stop:"
1018 einfo " pg_ctl stop -D ${DATA_DIR}"
1019 einfo
1020 einfo "Or move the configuration files back:"
1021 einfo "mv ${PGDATA}*.conf ${DATA_DIR}"
1022 else
1023 einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
1024 einfo "instead of 'pg_ctl'."
1025 fi
1026 }
1027
1028 src_test() {
1029 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
1030
1031 if [ ${UID} -ne 0 ] ; then
1032 emake -j1 check || die "Make check failed. See above for details."
1033
1034 einfo "If you think other tests besides the regression tests are necessary, please"
1035 einfo "submit a bug including a patch for this ebuild to enable them."
1036 else
1037 ewarn "Tests cannot be run as root. Skipping."
1038 ewarn "HINT: FEATURES=\"userpriv\""
1039 fi
1040 }
1041
1042
1043
1044 1.1 dev-db/postgresql-server/postgresql-server-9.0.4-r2.ebuild
1045
1046 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-9.0.4-r2.ebuild?rev=1.1&view=markup
1047 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-9.0.4-r2.ebuild?rev=1.1&content-type=text/plain
1048
1049 Index: postgresql-server-9.0.4-r2.ebuild
1050 ===================================================================
1051 # Copyright 1999-2011 Gentoo Foundation
1052 # Distributed under the terms of the GNU General Public License v2
1053 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/postgresql-server-9.0.4-r2.ebuild,v 1.1 2011/08/02 02:13:49 titanofold Exp $
1054
1055 EAPI="3"
1056 PYTHON_DEPEND="python? 2"
1057
1058 WANT_AUTOMAKE="none"
1059 inherit autotools eutils multilib pam prefix python versionator
1060
1061 SLOT="$(get_version_component_range 1-2)"
1062
1063 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~ppc-macos ~x86-solaris"
1064
1065 DESCRIPTION="PostgreSQL server"
1066 HOMEPAGE="http://www.postgresql.org/"
1067 SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2
1068 http://dev.gentoo.org/~titanofold/postgresql-patches-${SLOT}-r2.tbz2
1069 http://dev.gentoo.org/~titanofold/postgresql-initscript-1.2.tbz2"
1070 LICENSE="POSTGRESQL"
1071
1072 S="${WORKDIR}/postgresql-${PV}"
1073
1074 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN zh_TW"
1075 IUSE="doc kernel_linux nls pam perl -pg_legacytimestamp python selinux tcl uuid xml"
1076
1077 for lingua in ${LINGUAS}; do
1078 IUSE+=" linguas_${lingua}"
1079 done
1080
1081 wanted_languages() {
1082 local enable_langs
1083
1084 for lingua in ${LINGUAS} ; do
1085 use linguas_${lingua} && enable_langs+="${lingua} "
1086 done
1087
1088 echo -n ${enable_langs}
1089 }
1090
1091 RDEPEND="~dev-db/postgresql-base-${PV}:${SLOT}[pam?,pg_legacytimestamp=,nls=]
1092 perl? ( >=dev-lang/perl-5.8 )
1093 selinux? ( sec-policy/selinux-postgresql )
1094 tcl? ( >=dev-lang/tcl-8 )
1095 uuid? ( dev-libs/ossp-uuid )
1096 xml? ( dev-libs/libxml2 dev-libs/libxslt )"
1097
1098 DEPEND="${RDEPEND}
1099 sys-devel/flex
1100 xml? ( dev-util/pkgconfig )"
1101
1102 PDEPEND="doc? ( ~dev-db/postgresql-docs-${PV} )"
1103
1104 pkg_setup() {
1105 enewgroup postgres 70
1106 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
1107
1108 use python && python_set_active_version 2
1109 }
1110
1111 src_prepare() {
1112 epatch "${WORKDIR}/autoconf.patch" "${FILESDIR}/bool.patch" \
1113 "${FILESDIR}/pg_ctl-exit-status.patch" "${WORKDIR}/server.patch"
1114
1115 eprefixify src/include/pg_config_manual.h
1116
1117 if use test ; then
1118 epatch "${WORKDIR}/regress.patch"
1119 sed -e "s|@SOCKETDIR@|${T}|g" -i src/test/regress/pg_regress{,_main}.c
1120 sed -e "s|/no/such/location|${S}/src/test/regress/tmp_check/no/such/location|g" \
1121 -i src/test/regress/{input,output}/tablespace.source
1122 else
1123 echo "all install:" > "${S}/src/test/regress/GNUmakefile"
1124 fi
1125
1126 eautoconf
1127 }
1128
1129 src_configure() {
1130 # eval is needed to get along with pg_config quotation of space-rich entities.
1131 eval econf "$(${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --configure)" \
1132 --with-includes="${EPREFIX%/}/usr/include/postgresql-${SLOT}/" \
1133 --with-libraries="${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/$(get_libdir)" \
1134 --with-system-tzdata="${EPREFIX%/}/usr/share/zoneinfo" \
1135 $(use_with perl) \
1136 $(use_with python) \
1137 $(use_with tcl) \
1138 $(use_with xml libxml) \
1139 $(use_with xml libxslt) \
1140 $(use_with uuid ossp-uuid) \
1141 "$(use_enable nls nls "$(wanted_languages)")"
1142 }
1143
1144 src_compile() {
1145 local bd
1146 for bd in . contrib $(use xml && echo contrib/xml2); do
1147 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
1148 emake -C $bd -j1 || die "emake in $bd failed"
1149 done
1150 }
1151
1152 src_install() {
1153 if use perl ; then
1154 mv -f "${S}/src/pl/plperl/GNUmakefile" "${S}/src/pl/plperl/GNUmakefile_orig"
1155 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \
1156 "${S}/src/pl/plperl/GNUmakefile_orig" > "${S}/src/pl/plperl/GNUmakefile"
1157 fi
1158
1159 local bd
1160 for bd in . contrib $(use xml && echo contrib/xml2) ; do
1161 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
1162 emake install -C $bd -j1 DESTDIR="${D}" || die "emake install in $bd failed"
1163 done
1164
1165 dodir /usr/share/postgresql-${SLOT}/man/man1/
1166 cp "${S}"/doc/src/sgml/man1/{initdb,pg_controldata,pg_ctl,pg_resetxlog,post{gres,master}}.1 \
1167 "${ED}"/usr/share/postgresql-${SLOT}/man/man1/ || die
1168
1169 dodoc README HISTORY doc/{README.*,TODO,bug.template}
1170
1171 dodir /etc/eselect/postgresql/slots/${SLOT}
1172 echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" \
1173 > "${ED}/etc/eselect/postgresql/slots/${SLOT}/server"
1174
1175 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}/postgresql.confd"
1176 newconfd "${WORKDIR}/postgresql.confd" postgresql-${SLOT} || die "Inserting conf.d file failed"
1177 sed -e "s/@SLOT@/${SLOT}/g" -i "${WORKDIR}/postgresql.init"
1178 newinitd "${WORKDIR}/postgresql.init" postgresql-${SLOT} || die "Inserting init.d file failed"
1179
1180 use pam && pamd_mimic system-auth postgresql auth account session
1181
1182 keepdir /var/run/postgresql
1183 fperms 0770 /var/run/postgresql
1184 use prefix || fowners postgres:postgres /var/run/postgresql
1185 }
1186
1187 pkg_postinst() {
1188 postgresql-config update
1189
1190 elog "The time stamp format is 64 bit integers now. If you upgrade from older"
1191 elog "databases, this may force you to either do a dump and reload or enable"
1192 elog "pg_legacytimestamp until you find time to do so. If the database cannot start"
1193 elog "please try enabling pg_legacytimestamp and rebuild."
1194 elog
1195 elog "The Unix-domain socket is located in:"
1196 elog " ${EROOT%/}/var/run/postgresql/"
1197 elog
1198 elog "If you have users and/or services that you would like to utilize the socket,"
1199 elog "you must add them to the 'postgres' system group:"
1200 elog " usermod -a -G postgres <user>"
1201 elog
1202 elog "Before initializing the database, you may want to edit PG_INITDB_OPTS so that"
1203 elog "it contains your preferred locale in:"
1204 elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1205 elog
1206 elog "Then, execute the following command to setup the initial database"
1207 elog "environment:"
1208 elog " emerge --config =${CATEGORY}/${PF}"
1209 }
1210
1211 pkg_postrm() {
1212 postgresql-config update
1213 }
1214
1215 pkg_config() {
1216 [[ -f ${EROOT%/}/etc/conf.d/postgresql-${SLOT} ]] && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1217 [[ -z ${PGDATA} ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
1218 [[ -z ${DATA_DIR} ]] && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
1219
1220 # environment.bz2 may not contain the same locale as the current system
1221 # locale. Unset and source from the current system locale.
1222 if [[ -f ${EROOT%/}/etc/env.d/02locale ]] ; then
1223 unset LANG
1224 unset LC_CTYPE
1225 unset LC_NUMERIC
1226 unset LC_TIME
1227 unset LC_COLLATE
1228 unset LC_MONETARY
1229 unset LC_MESSAGES
1230 unset LC_ALL
1231 source "${EROOT%/}/etc/env.d/02locale"
1232 [[ -n ${LANG} ]] && export LANG
1233 [[ -n ${LC_CTYPE} ]] && export LC_CTYPE
1234 [[ -n ${LC_NUMERIC} ]] && export LC_NUMERIC
1235 [[ -n ${LC_TIME} ]] && export LC_TIME
1236 [[ -n ${LC_COLLATE} ]] && export LC_COLLATE
1237 [[ -n ${LC_MONETARY} ]] && export LC_MONETARY
1238 [[ -n ${LC_MESSAGES} ]] && export LC_MESSAGES
1239 [[ -n ${LC_ALL} ]] && export LC_ALL
1240 fi
1241
1242 einfo "You can modify the paths and options passed to initdb by editing:"
1243 einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1244 einfo
1245 einfo "Information on options that can be passed to initdb are found at:"
1246 einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
1247 einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
1248 einfo
1249 einfo "PG_INITDB_OPTS is currently set to:"
1250 if [[ -z "${PG_INITDB_OPTS}" ]] ; then
1251 einfo " (none)"
1252 else
1253 einfo " ${PG_INITDB_OPTS}"
1254 fi
1255 einfo
1256 einfo "Configuration files will be installed to:"
1257 einfo " ${PGDATA}"
1258 einfo
1259 einfo "The database cluster will be created in:"
1260 einfo " ${DATA_DIR}"
1261 einfo
1262 while [[ $correct != "true" ]] ; do
1263 einfo "Are you ready to continue? (y/n)"
1264 read answer
1265 if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
1266 correct="true"
1267 elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
1268 die "Aborting initialization."
1269 else
1270 echo "Answer not recognized"
1271 fi
1272 done
1273
1274 if [[ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ]] ; then
1275 eerror "The given directory, '${DATA_DIR}', is not empty."
1276 eerror "Modify DATA_DIR to point to an empty directory."
1277 die "${DATA_DIR} is not empty."
1278 fi
1279
1280 [[ -z ${PG_MAX_CONNECTIONS} ]] && PG_MAX_CONNECTIONS=128
1281 einfo "Checking system parameters..."
1282
1283 if ! use kernel_linux ; then
1284 einfo "Skipped."
1285 einfo " Tests not supported on this OS (yet)"
1286 else
1287 if [[ -z ${SKIP_SYSTEM_TESTS} ]] ; then
1288 einfo "Checking whether your system supports at least ${PG_MAX_CONNECTIONS} connections..."
1289
1290 local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
1291 local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
1292 local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
1293 local SHMMAX=$(sysctl -n kernel.shmmax)
1294
1295 local SEMMSL_MIN=17
1296 local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
1297 local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
1298 local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
1299
1300 for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
1301 if [[ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ]] ; then
1302 eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
1303 eerror "You have now several options:"
1304 eerror " - Change the mentioned system parameter"
1305 eerror " - Lower the number of max connections by setting PG_MAX_CONNECTIONS to a"
1306 eerror " value lower than ${PG_MAX_CONNECTIONS}"
1307 eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test completely"
1308 eerror "More information can be found here:"
1309 eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
1310 die "System test failed."
1311 fi
1312 done
1313 einfo "Passed."
1314 else
1315 ewarn "SKIP_SYSTEM_TESTS set, so skipping."
1316 fi
1317 fi
1318
1319 if [[ ${EUID} == 0 ]] ; then
1320 einfo "Creating the data directory ..."
1321 mkdir -p "${DATA_DIR}"
1322 chown -Rf postgres:postgres "${DATA_DIR}"
1323 chmod 0700 "${DATA_DIR}"
1324 fi
1325
1326 einfo "Initializing the database ..."
1327
1328 if [[ ${EUID} == 0 ]] ; then
1329 su postgres \
1330 -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D '${DATA_DIR}' -L '${EROOT%/}/usr/share/postgresql-${SLOT}/' ${PG_INITDB_OPTS}"
1331 else
1332 "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb \
1333 -U postgres -D "${DATA_DIR}" \
1334 -L "${EROOT%/}/usr/share/postgresql-${SLOT}/" ${PG_INITDB_OPTS}
1335 fi
1336
1337 mv "${DATA_DIR%/}"/*.conf "${PGDATA}"
1338
1339 einfo "The autovacuum function, which was in contrib, has been moved to the main"
1340 einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled"
1341 einfo "by default. You can disable it in the cluster's:"
1342 einfo " ${PGDATA%/}/postgresql.conf"
1343 einfo
1344 einfo "The PostgreSQL server, by default, will log events to:"
1345 einfo " ${DATA_DIR%/}/postmaster.log"
1346 einfo
1347 if use prefix ; then
1348 einfo "The location of the configuration files have moved to:"
1349 einfo " ${PGDATA}"
1350 einfo
1351 einfo "To start the server:"
1352 einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
1353 einfo
1354 einfo "To stop:"
1355 einfo " pg_ctl stop -D ${DATA_DIR}"
1356 einfo
1357 einfo "Or move the configuration files back:"
1358 einfo " mv ${PGDATA}*.conf ${DATA_DIR}"
1359 else
1360 einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
1361 einfo "instead of 'pg_ctl'."
1362 fi
1363 }
1364
1365 src_test() {
1366 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
1367
1368 if [[ ${UID} != 0 ]] ; then
1369 emake check || die "Make check failed. See above for details."
1370
1371 einfo "If you think other tests besides the regression tests are necessary, please"
1372 einfo "submit a bug including a patch for this ebuild to enable them."
1373 else
1374 ewarn "Tests cannot be run as root. Skipping."
1375 ewarn "HINT: FEATURES=\"userpriv\""
1376 fi
1377 }
1378
1379
1380
1381 1.1 dev-db/postgresql-server/postgresql-server-8.2.21-r2.ebuild
1382
1383 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.2.21-r2.ebuild?rev=1.1&view=markup
1384 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.2.21-r2.ebuild?rev=1.1&content-type=text/plain
1385
1386 Index: postgresql-server-8.2.21-r2.ebuild
1387 ===================================================================
1388 # Copyright 1999-2011 Gentoo Foundation
1389 # Distributed under the terms of the GNU General Public License v2
1390 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.2.21-r2.ebuild,v 1.1 2011/08/02 02:13:49 titanofold Exp $
1391
1392 EAPI="4"
1393
1394 WANT_AUTOMAKE="none"
1395 inherit autotools eutils multilib pam prefix versionator
1396
1397 SLOT="$(get_version_component_range 1-2)"
1398
1399 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~s390 ~sh ~sparc ~x86"
1400
1401 DESCRIPTION="PostgreSQL server"
1402 HOMEPAGE="http://www.postgresql.org/"
1403 SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2
1404 http://dev.gentoo.org/~titanofold/postgresql-patches-${SLOT}-r1.tbz2
1405 http://dev.gentoo.org/~titanofold/postgresql-initscript-1.0.1.tbz2"
1406 LICENSE="POSTGRESQL"
1407
1408 S="${WORKDIR}/postgresql-${PV}"
1409
1410 LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN zh_TW"
1411 IUSE="doc kernel_linux nls pam perl python selinux tcl xml"
1412
1413 for lingua in ${LINGUAS} ; do
1414 IUSE+=" linguas_${lingua}"
1415 done
1416
1417 wanted_languages() {
1418 local enable_langs
1419
1420 for lingua in ${LINGUAS} ; do
1421 use linguas_${lingua} && enable_langs+="${lingua} "
1422 done
1423
1424 echo -n ${enable_langs}
1425 }
1426
1427 RDEPEND="~dev-db/postgresql-base-${PV}:${SLOT}[pam?,nls=]
1428 perl? ( >=dev-lang/perl-5.8 )
1429 selinux? ( sec-policy/selinux-postgresql )
1430 tcl? ( >=dev-lang/tcl-8 )
1431 xml? ( dev-libs/libxml2 dev-libs/libxslt )"
1432
1433 DEPEND="${RDEPEND}
1434 sys-devel/flex
1435 xml? ( dev-util/pkgconfig )"
1436
1437 PDEPEND="doc? ( ~dev-db/postgresql-docs-${PV} )"
1438
1439 pkg_setup() {
1440 enewgroup postgres 70
1441 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
1442 }
1443
1444 src_prepare() {
1445 epatch "${WORKDIR}/autoconf.patch" "${WORKDIR}/bool.patch" \
1446 "${WORKDIR}/darwin.patch" "${WORKDIR}/pg_ctl-exit-status.patch" \
1447 "${WORKDIR}/server.patch" "${WORKDIR}/SuperH.patch"
1448
1449 eprefixify src/include/pg_config_manual.h
1450
1451 if use test ; then
1452 epatch "${WORKDIR}/regress.patch"
1453 sed -e "s|@SOCKETDIR@|${T}|g" -i src/test/regress/pg_regress.c
1454 sed -e "s|/no/such/location|${S}/src/test/regress/tmp_check/no/such/location|g" \
1455 -i src/test/regress/{input,output}/tablespace.source
1456 else
1457 echo "all install:" > "${S}/src/test/regress/GNUmakefile"
1458 fi
1459
1460 eautoconf
1461 }
1462
1463 src_configure() {
1464 # eval is needed to get along with pg_config quotation of space-rich entities.
1465 eval econf "$(${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --configure)" \
1466 --with-includes="${EPREFIX%/}/usr/include/postgresql-${SLOT}/" \
1467 $(use_with perl) \
1468 $(use_with python) \
1469 $(use_with tcl) \
1470 "$(has_version ~dev-db/postgresql-base-${PV}[nls] && use_enable nls nls "$(wanted_languages)")"
1471 }
1472
1473 src_compile() {
1474 local bd
1475 for bd in . contrib $(use xml && echo contrib/xml2); do
1476 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
1477 emake -C $bd -j1 \
1478 PGXS=$(${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --pgxs) \
1479 PGXS_IN_SERVER=1 PGXS_WITH_SERVER="${S}/src/backend/postgres" \
1480 NO_PGXS=0 USE_PGXS=1 docdir=${EROOT%/}/usr/share/doc/${PF}
1481 done
1482 }
1483
1484 src_install() {
1485 if use perl ; then
1486 mv -f "${S}/src/pl/plperl/GNUmakefile" "${S}/src/pl/plperl/GNUmakefile_orig"
1487 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \
1488 "${S}/src/pl/plperl/GNUmakefile_orig" > "${S}/src/pl/plperl/GNUmakefile"
1489 fi
1490
1491 local bd
1492 for bd in . contrib $(use xml && echo contrib/xml2) ; do
1493 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
1494 emake install -C $bd -j1 DESTDIR="${D}" \
1495 PGXS_IN_SERVER=1 PGXS_WITH_SERVER="${S}/src/backend/postgres" \
1496 PGXS=$(${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --pgxs) \
1497 NO_PGXS=0 USE_PGXS=1 docdir=${EROOT%/}/usr/share/doc/${PF}
1498 done
1499
1500 rm -r "${ED}/usr/share/postgresql-${SLOT}/man/man7/" "${ED}/usr/share/doc/${PF}/html"
1501 rm "${ED}"/usr/share/postgresql-${SLOT}/man/man1/{clusterdb,create{db,lang,user},drop{db,lang,user},ecpg,pg_{config,dump,dumpall,restore},psql,reindexdb,vacuumdb}.1
1502 docompress /usr/share/postgresql-${SLOT}/man/man1
1503
1504 dodoc README HISTORY doc/{README.*,TODO,bug.template}
1505
1506 dodir /etc/eselect/postgresql/slots/${SLOT}
1507 echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" \
1508 > "${ED}/etc/eselect/postgresql/slots/${SLOT}/server"
1509
1510 newconfd "${WORKDIR}/postgresql.confd" postgresql-${SLOT}
1511 newinitd "${WORKDIR}/postgresql.init" postgresql-${SLOT}
1512
1513 use pam && pamd_mimic system-auth postgresql auth account session
1514
1515 keepdir /var/run/postgresql
1516 fperms 0770 /var/run/postgresql
1517 use prefix || fowners postgres:postgres /var/run/postgresql
1518 }
1519
1520 pkg_postinst() {
1521 postgresql-config update
1522
1523 elog "The Unix-domain socket is located in:"
1524 elog " ${EROOT%/}/var/run/postgresql/"
1525 elog
1526 elog "If you have users and/or services that you would like to utilize the socket,"
1527 elog "you must add them to the 'postgres' system group:"
1528 elog " usermod -a -G postgres <user>"
1529 elog
1530 elog "Before initializing the database, you may want to edit PG_INITDB_OPTS so that"
1531 elog "it contains your preferred locale in:"
1532 elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1533 elog
1534 elog "Then, execute the following command to setup the initial database"
1535 elog "environment:"
1536 elog " emerge --config =${CATEGORY}/${PF}"
1537 }
1538
1539 pkg_postrm() {
1540 postgresql-config update
1541 }
1542
1543 pkg_config() {
1544 [[ -f ${EROOT%/}/etc/conf.d/postgresql-${SLOT} ]] && source ${EROOT%/}/etc/conf.d/postgresql-${SLOT}
1545 [[ -z ${PGDATA} ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
1546 [[ -z ${DATA_DIR} ]] && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
1547
1548 # environment.bz2 may not contain the same locale as the current system
1549 # locale. Unset and source from the current system locale.
1550 if [[ -f ${EROOT%/}/etc/env.d/02locale ]] ; then
1551 unset LANG
1552 unset LC_CTYPE
1553 unset LC_NUMERIC
1554 unset LC_TIME
1555 unset LC_COLLATE
1556 unset LC_MONETARY
1557 unset LC_MESSAGES
1558 unset LC_ALL
1559 source ${EROOT%/}/etc/env.d/02locale
1560 [[ -n ${LANG} ]] && export LANG
1561 [[ -n ${LC_CTYPE} ]] && export LC_CTYPE
1562 [[ -n ${LC_NUMERIC} ]] && export LC_NUMERIC
1563 [[ -n ${LC_TIME} ]] && export LC_TIME
1564 [[ -n ${LC_COLLATE} ]] && export LC_COLLATE
1565 [[ -n ${LC_MONETARY} ]] && export LC_MONETARY
1566 [[ -n ${LC_MESSAGES} ]] && export LC_MESSAGES
1567 [[ -n ${LC_ALL} ]] && export LC_ALL
1568 fi
1569
1570 einfo "You can modify the paths and options passed to initdb by editing:"
1571 einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
1572 einfo
1573 einfo "Information on options that can be passed to initdb are found at:"
1574 einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
1575 einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
1576 einfo
1577 einfo "PG_INITDB_OPTS is currently set to:"
1578 if [[ -z "${PG_INITDB_OPTS}" ]] ; then
1579 einfo " (none)"
1580 else
1581 einfo " ${PG_INITDB_OPTS}"
1582 fi
1583 einfo
1584 einfo "Configuration files will be installed to:"
1585 einfo " ${PGDATA}"
1586 einfo
1587 einfo "The database cluster will be created in:"
1588 einfo " ${DATA_DIR}"
1589 einfo
1590 while [[ $correct != "true" ]] ; do
1591 einfo "Are you ready to continue? (y/n)"
1592 read answer
1593 if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
1594 correct="true"
1595 elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
1596 die "Aborting initialization."
1597 else
1598 echo "Answer not recognized"
1599 fi
1600 done
1601
1602 if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
1603 eerror "The given directory, '${DATA_DIR}', is not empty."
1604 eerror "Modify DATA_DIR to point to an empty directory."
1605 die "${DATA_DIR} is not empty."
1606 fi
1607
1608 [[ -z ${PG_MAX_CONNECTIONS} ]] && PG_MAX_CONNECTIONS=128
1609 einfo "Checking system parameters..."
1610
1611 if ! use kernel_linux ; then
1612 einfo "Skipped."
1613 einfo "Tests not supported on this OS (yet)"
1614 else
1615 if [[ -z ${SKIP_SYSTEM_TESTS} ]] ; then
1616 einfo "Checking whether your system supports at least ${PG_MAX_CONNECTIONS} connections..."
1617
1618 local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
1619 local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
1620 local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
1621 local SHMMAX=$(sysctl -n kernel.shmmax)
1622
1623 local SEMMSL_MIN=17
1624 local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
1625 local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
1626 local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
1627
1628 for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
1629 if [[ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ]] ; then
1630 eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
1631 eerror "You have now several options:"
1632 eerror " - Change the mentioned system parameter"
1633 eerror " - Lower the number of max.connections by setting PG_MAX_CONNECTIONS to a"
1634 eerror " value lower than ${PG_MAX_CONNECTIONS}"
1635 eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test completely"
1636 eerror "More information can be found here:"
1637 eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
1638 die "System test failed."
1639 fi
1640 done
1641 einfo "Passed."
1642 else
1643 ewarn "SKIP_SYSTEM_TESTS set, so skipping."
1644 fi
1645 fi
1646
1647 if [[ ${EUID} == 0 ]] ; then
1648 einfo "Creating the data directory ..."
1649 mkdir -p "${DATA_DIR}"
1650 chown -Rf postgres:postgres "${DATA_DIR}"
1651 chmod 0700 "${DATA_DIR}"
1652 fi
1653
1654 einfo "Initializing the database ..."
1655 if [[ ${EUID} == 0 ]] ; then
1656 su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
1657 else
1658 "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
1659 fi
1660 mv "${DATA_DIR%/}"/*.conf "${PGDATA}"
1661
1662 einfo "The autovacuum function, which was in contrib, has been moved to the main"
1663 einfo "PostgreSQL functions starting with 8.1."
1664 einfo "You can enable it in the cluster's:"
1665 einfo " ${PGDATA%/}/postgresql.conf"
1666 einfo
1667 einfo "The PostgreSQL server, by default, will log events to:"
1668 einfo " ${DATA_DIR%/}/postmaster.log"
1669 einfo
1670 if use prefix ; then
1671 einfo "The location of the configuration files have moved to:"
1672 einfo " ${PGDATA}"
1673 einfo
1674 einfo "To start the server:"
1675 einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
1676 einfo
1677 einfo "To stop:"
1678 einfo " pg_ctl stop -D ${DATA_DIR}"
1679 einfo
1680 einfo "Or move the configuration files back:"
1681 einfo " mv ${PGDATA}*.conf ${DATA_DIR}"
1682 else
1683 einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
1684 einfo "instead of 'pg_ctl'."
1685 fi
1686 }
1687
1688 src_test() {
1689 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
1690
1691 if [[ ${UID} != 0 ]] ; then
1692 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/:${PATH}" \
1693 emake check \
1694 PGXS=$("${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --pgxs) \
1695 NO_PGXS=0 USE_PGXS=1 SLOT="${SLOT}"
1696
1697 einfo "If you think other tests besides the regression tests are necessary, please"
1698 einfo "submit a bug including a patch for this ebuild to enable them."
1699 else
1700 ewarn "Tests cannot be run as root. Skipping."
1701 ewarn "HINT: FEATURES=\"userpriv\""
1702 fi
1703 }