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