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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Sun Jun 17 20:06:27 2012 UTC (2 years, 2 months ago) by maekke
Branch: MAIN
Changes since 1.5: +2 -2 lines
arm stable, bug #419727

(Portage version: 2.1.10.65/cvs/Linux i686)

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

  ViewVC Help
Powered by ViewVC 1.1.20