Gentoo Archives: gentoo-commits

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