/[gentoo-x86]/dev-db/postgresql-server/postgresql-server-8.4.12.ebuild
Gentoo

Contents of /dev-db/postgresql-server/postgresql-server-8.4.12.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Tue Sep 25 16:05:39 2012 UTC (22 months, 3 weeks ago) by titanofold
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +1 -1 lines
FILE REMOVED
Cleaning out insecure versions.

(Portage version: 2.1.11.9/cvs/Linux x86_64)

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/postgresql-server-8.4.12.ebuild,v 1.8 2012/07/28 12:34:49 titanofold Exp $
4
5 EAPI="4"
6 PYTHON_DEPEND="python? 2"
7
8 WANT_AUTOMAKE="none"
9 inherit autotools eutils multilib pam prefix python user versionator
10
11 SLOT="$(get_version_component_range 1-2)"
12
13 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ~ppc ppc64 s390 sh sparc x86 ~x86-fbsd"
14
15 DESCRIPTION="PostgreSQL server"
16 HOMEPAGE="http://www.postgresql.org/"
17 SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2
18 http://dev.gentoo.org/~titanofold/postgresql-patches-8.4-r2.tbz2
19 http://dev.gentoo.org/~titanofold/postgresql-initscript-2.1.tbz2"
20 LICENSE="POSTGRESQL GPL-2"
21
22 S="${WORKDIR}/postgresql-${PV}"
23
24 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"
25 IUSE="doc kernel_linux nls pam perl -pg_legacytimestamp python selinux tcl uuid xml"
26
27 for lingua in ${LINGUAS} ; do
28 IUSE+=" linguas_${lingua}"
29 done
30
31 wanted_languages() {
32 local enable_langs
33
34 for lingua in ${LINGUAS} ; do
35 use linguas_${lingua} && enable_langs+="${lingua} "
36 done
37
38 echo -n ${enable_langs}
39 }
40
41 RDEPEND="~dev-db/postgresql-base-${PV}:${SLOT}[pam?,pg_legacytimestamp=,nls=]
42 perl? ( >=dev-lang/perl-5.8 )
43 selinux? ( sec-policy/selinux-postgresql )
44 tcl? ( >=dev-lang/tcl-8 )
45 uuid? ( dev-libs/ossp-uuid )
46 xml? ( dev-libs/libxml2 dev-libs/libxslt )"
47
48 DEPEND="${RDEPEND}
49 sys-devel/flex
50 xml? ( virtual/pkgconfig )"
51
52 PDEPEND="doc? ( ~dev-db/postgresql-docs-${PV} )"
53
54 # Support /var/run or /run for the socket directory
55 [[ ! -d /run ]] && RUNDIR=/var
56
57 pkg_setup() {
58 enewgroup postgres 70
59 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
60
61 use python && python_set_active_version 2
62 }
63
64 src_prepare() {
65 epatch "${WORKDIR}/autoconf.patch" \
66 "${WORKDIR}/bool.patch" \
67 "${WORKDIR}/darwin.patch" \
68 "${WORKDIR}/ldflags.patch" \
69 "${WORKDIR}/pg_ctl-exit-status.patch" \
70 "${WORKDIR}/server.patch" \
71 "${WORKDIR}/SuperH.patch"
72
73 eprefixify src/include/pg_config_manual.h
74
75 if use test ; then
76 epatch "${WORKDIR}/regress.patch"
77 sed -e "s|@SOCKETDIR@|${T}|g" -i src/test/regress/pg_regress{,_main}.c
78 sed -e "s|/no/such/location|${S}/src/test/regress/tmp_check/no/such/location|g" \
79 -i src/test/regress/{input,output}/tablespace.source
80 else
81 echo "all install:" > "${S}/src/test/regress/GNUmakefile"
82 fi
83
84 sed -e "s|@RUNDIR@|${RUNDIR}|g" \
85 -i src/include/pg_config_manual.h "${WORKDIR}/postgresql.init" || \
86 die "RUNDIR sed failed"
87 sed -e "s|@SLOT@|${SLOT}|g" \
88 -i "${WORKDIR}/postgresql.init" "${WORKDIR}/postgresql.confd" || \
89 die "SLOT sed failed"
90
91 eautoconf
92 }
93
94 src_configure() {
95 # eval is needed to get along with pg_config quotation of space-rich entities.
96 eval econf "$(${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --configure)" \
97 --with-includes="${EPREFIX%/}/usr/include/postgresql-${SLOT}/" \
98 --with-libraries="${EPREFIX%/}/usr/$(get_libdir)/postgresql-${SLOT}/$(get_libdir)" \
99 --with-system-tzdata="${EPREFIX%/}/usr/share/zoneinfo" \
100 $(use_with perl) \
101 $(use_with python) \
102 $(use_with tcl) \
103 $(use_with xml libxml) \
104 $(use_with xml libxslt) \
105 $(use_with uuid ossp-uuid) \
106 "$(has_version ~dev-db/postgresql-base-${PV}[nls] && use_enable nls nls "$(wanted_languages)")"
107 }
108
109 src_compile() {
110 local bd
111 for bd in . contrib $(use xml && echo contrib/xml2) ; do
112 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
113 emake -C $bd -j1 || die "emake in $bd failed"
114 done
115 }
116
117 src_install() {
118 if use perl ; then
119 mv -f "${S}/src/pl/plperl/GNUmakefile" \
120 "${S}/src/pl/plperl/GNUmakefile_orig"
121 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \
122 "${S}/src/pl/plperl/GNUmakefile_orig" \
123 > "${S}/src/pl/plperl/GNUmakefile"
124 fi
125
126 local bd
127 for bd in . contrib $(use xml && echo contrib/xml2) ; do
128 PATH="${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
129 emake install -C $bd -j1 DESTDIR="${D}" \
130 || die "emake install in $bd failed"
131 done
132
133 rm -r "${ED}/usr/share/postgresql-${SLOT}/man/man7/" \
134 "${ED}/usr/share/doc/postgresql-${SLOT}/html"
135 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
136
137 dodoc README HISTORY doc/{README.*,TODO,bug.template}
138
139 dodir /etc/eselect/postgresql/slots/${SLOT}
140 echo "postgres_ebuilds=\"\${postgres_ebuilds} ${PF}\"" \
141 > "${ED}/etc/eselect/postgresql/slots/${SLOT}/server"
142
143 newconfd "${WORKDIR}"/postgresql.confd postgresql-${SLOT} \
144 || die "Inserting conf.d file failed"
145
146 newinitd "${WORKDIR}"/postgresql.init postgresql-${SLOT} \
147 || die "Inserting init.d file failed"
148
149 use pam && pamd_mimic system-auth postgresql auth account session
150
151 if use prefix ; then
152 keepdir ${RUNDIR}/run/postgresql
153 fperms 0770 ${RUNDIR}/run/postgresql
154 fi
155 }
156
157 pkg_postinst() {
158 postgresql-config update
159
160 elog "The time stamp format is 64 bit integers now. If you upgrade from older"
161 elog "databases, this may force you to either do a dump and reload of enable"
162 elog "pg_legacytimestamp until you find time to do so. If the database can't start"
163 elog "please try enabling pg_legacytimestamp and rebuild."
164 elog
165 elog "Gentoo specific documentation:"
166 elog "http://www.gentoo.org/doc/en/postgres-howto.xml"
167 elog
168 elog "Official documentation:"
169 elog "http://www.postgresql.org/docs/${SLOT}/static/index.html"
170 elog
171 elog "The default location of the Unix-domain socket is:"
172 elog " ${EROOT%/}${RUNDIR}/run/postgresql/"
173 elog
174 elog "If you have users and/or services that you would like to utilize the"
175 elog "socket, you must add them to the 'postgres' system group:"
176 elog " usermod -a -G postgres <user>"
177 elog
178 elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
179 elog "so that it contains your preferred locale in:"
180 elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
181 elog
182 elog "Then, execute the following command to setup the initial database"
183 elog "environment:"
184 elog " emerge --config =${CATEGORY}/${PF}"
185 }
186
187 pkg_postrm() {
188 postgresql-config update
189 }
190
191 pkg_config() {
192 [[ -f ${EROOT%/}/etc/conf.d/postgresql-${SLOT} ]] && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
193 [[ -z ${PGDATA} ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/"
194 [[ -z ${DATA_DIR} ]] && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data"
195
196 # environment.bz2 may not contain the same locale as the current system
197 # locale. Unset and source from the current system locale.
198 if [[ -f ${EROOT%/}/etc/env.d/02locale ]] ; then
199 unset LANG
200 unset LC_CTYPE
201 unset LC_NUMERIC
202 unset LC_TIME
203 unset LC_COLLATE
204 unset LC_MONETARY
205 unset LC_MESSAGES
206 unset LC_ALL
207 source "${EROOT%/}/etc/env.d/02locale"
208 [[ -n ${LANG} ]] && export LANG
209 [[ -n ${LC_CTYPE} ]] && export LC_CTYPE
210 [[ -n ${LC_NUMERIC} ]] && export LC_NUMERIC
211 [[ -n ${LC_TIME} ]] && export LC_TIME
212 [[ -n ${LC_COLLATE} ]] && export LC_COLLATE
213 [[ -n ${LC_MONETARY} ]] && export LC_MONETARY
214 [[ -n ${LC_MESSAGES} ]] && export LC_MESSAGES
215 [[ -n ${LC_ALL} ]] && export LC_ALL
216 fi
217
218 einfo "You can modify the paths and options passed to initdb by editing:"
219 einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}"
220 einfo
221 einfo "Information on options that can be passed to initdb are found at:"
222 einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
223 einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
224 einfo
225 einfo "PG_INITDB_OPTS is currently set to:"
226 if [[ -z ${PG_INITDB_OPTS} ]] ; then
227 einfo " (none)"
228 else
229 einfo " ${PG_INITDB_OPTS}"
230 fi
231 einfo
232 einfo "Configuration files will be installed to:"
233 einfo " ${PGDATA}"
234 einfo
235 einfo "The database cluster will be created in:"
236 einfo " ${DATA_DIR}"
237 einfo
238 while [[ $correct != "true" ]] ; do
239 einfo "Are you ready to continue? (y/n)"
240 read answer
241 if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
242 correct="true"
243 elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
244 die "Aborting initialization."
245 else
246 echo "Answer not recognized"
247 fi
248 done
249
250 if [[ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ]] ; then
251 eerror "The given directory, '${DATA_DIR}', is not empty."
252 eerror "Modify DATA_DIR to point to an empty directory."
253 die "${DATA_DIR} is not empty."
254 fi
255
256 [[ -z ${PG_MAX_CONNECTIONS} ]] && PG_MAX_CONNECTIONS=128
257 einfo "Checking system parameters..."
258
259 if ! use kernel_linux ; then
260 einfo "Skipped."
261 einfo " Tests not supported on this OS (yet)"
262 else
263 if [[ -z ${SKIP_SYSTEM_TESTS} ]] ; then
264 einfo "Checking whether your system supports at least ${PG_MAX_CONNECTIONS} connections..."
265
266 local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
267 local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
268 local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
269 local SHMMAX=$(sysctl -n kernel.shmmax)
270
271 local SEMMSL_MIN=17
272 local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
273 local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
274 local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
275
276 for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
277 if [[ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ]] ; then
278 eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
279 eerror "You have now several options:"
280 eerror " - Change the mentioned system parameter"
281 eerror " - Lower the number of max.connections by setting PG_MAX_CONNECTIONS to a"
282 eerror " value lower than ${PG_MAX_CONNECTIONS}"
283 eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test completely"
284 eerror "More information can be found here:"
285 eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
286 die "System test failed."
287 fi
288 done
289 einfo "Passed."
290 else
291 ewarn "SKIP_SYSTEM_TESTS set, so skipping."
292 fi
293 fi
294
295 if [[ ${EUID} == 0 ]] ; then
296 einfo "Creating the data directory ..."
297 mkdir -p "${DATA_DIR}"
298 chown -Rf postgres:postgres "${DATA_DIR}"
299 chmod 0700 "${DATA_DIR}"
300 fi
301
302 einfo "Initializing the database ..."
303 if [[ ${EUID} == 0 ]] ; then
304 su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}"
305 else
306 "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS}
307 fi
308 mv "${DATA_DIR%/}"/*.conf "${PGDATA}"
309
310 einfo "The autovacuum function, which was in contrib, has been moved to the main"
311 einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled by"
312 einfo "default. You can disable it in the cluster's:"
313 einfo " ${PGDATA%/}/postgresql.conf"
314 einfo
315 einfo "The PostgreSQL server, by default, will log events to:"
316 einfo " ${DATA_DIR%/}/postmaster.log"
317 einfo
318 if use prefix ; then
319 einfo "The location of the configuration files have moved to:"
320 einfo " ${PGDATA}"
321 einfo
322 einfo "To start the server:"
323 einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'"
324 einfo
325 einfo "To stop:"
326 einfo " pg_ctl stop -D ${DATA_DIR}"
327 einfo
328 einfo "Or move the configuration files back:"
329 einfo " mv ${PGDATA}*.conf ${DATA_DIR}"
330 else
331 einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
332 einfo "instead of 'pg_ctl'."
333 fi
334 }
335
336 src_test() {
337 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
338
339 if [[ ${UID} != 0 ]] ; then
340 emake check || die "Make check failed. See above for details."
341
342 einfo "If you think other tests besides the regression tests are necessary, please"
343 einfo "submit a bug including a patch for this ebuild to enable them."
344 else
345 ewarn "Tests cannot be run as root. Skipping."
346 ewarn "HINT: FEATURES=\"userpriv\""
347 fi
348 }

  ViewVC Help
Powered by ViewVC 1.1.20