comparison dev-db/postgresql-server/postgresql-server-9.0.2.ebuild @ 269:c982d5c6f5eb

bump postgres to 9.0.2
author holger
date Tue, 28 Dec 2010 21:29:38 +0100
parents
children
comparison
equal deleted inserted replaced
268:871206936ec2 269:c982d5c6f5eb
1 # Copyright 1999-2010 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-9.0.1.ebuild,v 1.1 2010/10/06 14:58:10 patrick Exp $
4
5 EAPI="2"
6 PYTHON_DEPEND="python? 2"
7
8 # weird test failures.
9 RESTRICT="test"
10
11 WANT_AUTOMAKE="none"
12 inherit autotools eutils multilib python versionator
13
14 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sh ~sparc ~x86 ~x86-fbsd"
15
16 DESCRIPTION="PostgreSQL server"
17 HOMEPAGE="http://www.postgresql.org/"
18
19 MY_PV=${PV/_/}
20 SRC_URI="mirror://postgresql/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
21 S=${WORKDIR}/postgresql-${MY_PV}
22
23 LICENSE="POSTGRESQL"
24 SLOT="$(get_version_component_range 1-2)"
25 LINGUAS="af cs de es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr zh_CN zh_TW"
26 IUSE="doc kernel_linux nls perl pg_legacytimestamp python selinux tcl uuid xml"
27
28 for lingua in ${LINGUAS}; do
29 IUSE+=" linguas_${lingua}"
30 done
31
32 wanted_languages() {
33 local enable_langs
34
35 for lingua in ${LINGUAS} ; do
36 use linguas_${lingua} && enable_langs+="${lingua} "
37 done
38
39 echo -n ${enable_langs}
40 }
41
42 RDEPEND="~dev-db/postgresql-base-${PV}:${SLOT}[pg_legacytimestamp=,nls=]
43 perl? ( >=dev-lang/perl-5.6.1-r2 )
44 python? ( dev-python/egenix-mx-base )
45 selinux? ( sec-policy/selinux-postgresql )
46 tcl? ( >=dev-lang/tcl-8 )
47 uuid? ( dev-libs/ossp-uuid )
48 xml? ( dev-libs/libxml2 dev-libs/libxslt )"
49 DEPEND="${RDEPEND}
50 sys-devel/flex
51 xml? ( dev-util/pkgconfig )"
52 PDEPEND="doc? ( ~dev-db/postgresql-docs-${PV} )"
53
54 pkg_setup() {
55 enewgroup postgres 70
56 enewuser postgres 70 /bin/bash /var/lib/postgresql postgres
57
58 if use python; then
59 python_set_active_version 2
60 fi
61 }
62
63 src_prepare() {
64 epatch "${FILESDIR}/postgresql-${SLOT}-common.3.patch" \
65 "${FILESDIR}/postgresql-${SLOT}-server.3.patch"
66
67 if use test; then
68 sed -e "s|/no/such/location|${S}/src/test/regress/tmp_check/no/such/location|g" -i src/test/regress/{input,output}/tablespace.source
69 else
70 echo "all install:" > "${S}/src/test/regress/GNUmakefile"
71 fi
72
73 eautoconf
74 }
75
76 src_configure() {
77 # eval is needed to get along with pg_config quotation of space-rich entities.
78 eval econf "$(/usr/$(get_libdir)/postgresql-${SLOT}/bin/pg_config --configure)" \
79 --disable-thread-safety \
80 $(use_with perl) \
81 $(use_with python) \
82 $(use_with tcl) \
83 $(use_with xml libxml) \
84 $(use_with xml libxslt) \
85 $(use_with uuid ossp-uuid) \
86 --with-system-tzdata="/usr/share/zoneinfo" \
87 --with-includes="/usr/include/postgresql-${SLOT}/" \
88 --with-libraries="/usr/$(get_libdir)/postgresql-${SLOT}/$(get_libdir)" \
89 "$(use_enable nls nls "$(wanted_languages)")"
90 }
91
92 src_compile() {
93 local bd
94 for bd in . contrib $(use xml && echo contrib/xml2); do
95 PATH="/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
96 emake -C $bd -j1 || die "emake in $bd failed"
97 done
98 }
99
100 src_install() {
101 if use perl ; then
102 mv -f "${S}/src/pl/plperl/GNUmakefile" "${S}/src/pl/plperl/GNUmakefile_orig"
103 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \
104 "${S}/src/pl/plperl/GNUmakefile_orig" > "${S}/src/pl/plperl/GNUmakefile"
105 fi
106
107 for bd in . contrib $(use xml && echo contrib/xml2) ; do
108 PATH="/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
109 emake install -C $bd -j1 DESTDIR="${D}" || die "emake install in $bd failed"
110 done
111
112 rm -rf "${D}/usr/share/postgresql-${SLOT}/man/man7/" "${D}/usr/share/doc/postgresql-${SLOT}/html"
113 rm "${D}"/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
114
115 dodoc README HISTORY doc/{README.*,TODO,bug.template}
116
117 dodir /etc/eselect/postgresql/slots/${SLOT}
118 cat > "${D}/etc/eselect/postgresql/slots/${SLOT}/service" <<-__EOF__
119 postgres_ebuilds="\${postgres_ebuilds} ${PF}"
120 postgres_service="postgresql-${SLOT}"
121 __EOF__
122
123 newinitd "${FILESDIR}/postgresql.init-${SLOT}-r1" postgresql-${SLOT} || die "Inserting init.d-file failed"
124 newconfd "${FILESDIR}/postgresql.conf-${SLOT}-r1" postgresql-${SLOT} || die "Inserting conf.d-file failed"
125
126 keepdir /var/run/postgresql
127 fperms 0770 /var/run/postgresql
128 fowners postgres:postgres /var/run/postgresql
129 }
130
131 pkg_postinst() {
132 eselect postgresql update
133 [[ "$(eselect postgresql show)" = "(none)" ]] && eselect postgresql set ${SLOT}
134 [[ "$(eselect postgresql show-service)" = "(none)" ]] && eselect postgresql set-service ${SLOT}
135
136 ewarn "Please note that the standard location of the socket has changed from /tmp to"
137 ewarn "/var/run/postgresql and you have to be in the 'postgres' group to access the"
138 ewarn "socket. This can break applications which have the standard location"
139 ewarn "hard-coded. If such an application links against the libpq, please reemerge"
140 ewarn "it. If that doesn't help or the application accesses the socket without using"
141 ewarn "libpq, please file a bug-report."
142 ewarn
143 ewarn "You can set PGOPTS='-k /tmp' in /etc/conf.d/postgresql-${SLOT} to restore the"
144 ewarn "original location."
145 ewarn
146
147 elog "Before initializing the database, you may want to edit PG_INITDB_OPTS so that it"
148 elog "contains your preferred locale and character encoding in:"
149 elog
150 elog " /etc/conf.d/postgresql-${SLOT}"
151 elog
152 elog "Then, execute the following command to setup the initial database environment:"
153 elog
154 elog " emerge --config =${CATEGORY}/${PF}"
155 elog
156 elog "The autovacuum function, which was in contrib, has been moved to the main"
157 elog "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled by"
158 elog "default. You can disable it in the cluster's postgresql.conf."
159 elog
160 elog "The timestamp 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 or 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 }
165
166 pkg_postrm() {
167 eselect postgresql update
168 }
169
170 pkg_config() {
171 [[ -f /etc/conf.d/postgresql-${SLOT} ]] && source /etc/conf.d/postgresql-${SLOT}
172 [[ -z "${PGDATA}" ]] && PGDATA="/var/lib/postgresql/${SLOT}/data"
173
174 # environment.bz2 may not contain the same locale as the current system
175 # locale. Unset and source from the current system locale.
176 if [ -f /etc/env.d/02locale ]; then
177 unset LANG
178 unset LC_CTYPE
179 unset LC_NUMERIC
180 unset LC_TIME
181 unset LC_COLLATE
182 unset LC_MONETARY
183 unset LC_MESSAGES
184 unset LC_ALL
185 source /etc/env.d/02locale
186 [ -n "${LANG}" ] && export LANG
187 [ -n "${LC_CTYPE}" ] && export LC_CTYPE
188 [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC
189 [ -n "${LC_TIME}" ] && export LC_TIME
190 [ -n "${LC_COLLATE}" ] && export LC_COLLATE
191 [ -n "${LC_MONETARY}" ] && export LC_MONETARY
192 [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES
193 [ -n "${LC_ALL}" ] && export LC_ALL
194 fi
195
196 einfo "You can pass options to initdb by setting the PG_INITDB_OPTS variable."
197 einfo "More information can be found here:"
198 einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
199 einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html"
200 einfo "Simply add the options you would have added to initdb to the PG_INITDB_OPTS"
201 einfo "variable."
202 einfo
203 einfo "You can change the directory where the database cluster is being created by"
204 einfo "setting the PGDATA variable."
205 einfo
206 einfo "PG_INITDB_OPTS is currently set to:"
207 einfo " \"${PG_INITDB_OPTS}\""
208 einfo "and the database cluster will be created in:"
209 einfo " \"${PGDATA}\""
210 einfo "Are you ready to continue? (Y/n)"
211 read answer
212 [ -z $answer ] && answer=Y
213 [ "$answer" == "Y" ] || [ "$answer" == "y" ] || die "aborted"
214
215 if [[ -f "${PGDATA}/PG_VERSION" ]] ; then
216 eerror "The given directory \"${PGDATA}\" already contains a database cluster."
217 die "cluster already exists"
218 fi
219
220 [ -z "${PG_MAX_CONNECTIONS}" ] && PG_MAX_CONNECTIONS="128"
221 einfo "Checking system parameters..."
222
223 if ! use kernel_linux ; then
224 SKIP_SYSTEM_TESTS=yes
225 einfo " Tests not supported on this OS (yet)"
226 fi
227
228 if [ -z ${SKIP_SYSTEM_TESTS} ] ; then
229 einfo "Checking whether your system supports at least ${PG_MAX_CONNECTIONS} connections..."
230
231 local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
232 local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
233 local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
234 local SHMMAX=$(sysctl -n kernel.shmmax)
235
236 local SEMMSL_MIN=17
237 local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
238 local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
239 local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
240
241 for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
242 if [ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ] ; then
243 eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
244 eerror "You have now several options:"
245 eerror " - Change the mentioned system parameter"
246 eerror " - Lower the number of max.connections by setting PG_MAX_CONNECTIONS to a value lower than ${PG_MAX_CONNECTIONS}"
247 eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test completely"
248 eerror "More information can be found here:"
249 eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
250 die "System test failed."
251 fi
252 done
253 einfo "Passed."
254 else
255 einfo "Skipped."
256 fi
257
258 einfo "Creating the data directory ..."
259 mkdir -p "${PGDATA}"
260 chown -Rf postgres:postgres "${PGDATA}"
261 chmod 0700 "${PGDATA}"
262
263 einfo "Initializing the database ..."
264
265 su postgres -c "/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb --pgdata \"${PGDATA}\" ${PG_INITDB_OPTS}"
266
267 einfo
268 einfo "You can use the '${ROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL"
269 einfo "instead of 'pg_ctl'."
270 einfo
271 }
272
273 src_test() {
274 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
275 PATH="/usr/$(get_libdir)/postgresql-${SLOT}/bin:${PATH}" \
276 emake -j1 check || die "Make check failed. See above for details."
277
278 einfo "Yes, there are other tests which could be run."
279 einfo "... and no, we don't plan to add/support them."
280 einfo "For now, the main regressions tests will suffice. If you think other tests are"
281 einfo "necessary, please submit a bug including a patch for this ebuild to enable them."
282 }