Mercurial > hg > portage
comparison dev-db/postgresql/postgresql-8.3.1.ebuild @ 0:7985ba427c7d
initial import from svn
author | holger@wizards.de |
---|---|
date | Sat, 22 Mar 2008 03:58:33 +0100 |
parents | |
children | 6e30efce1771 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7985ba427c7d |
---|---|
1 # Copyright 1999-2008 Gentoo Foundation | |
2 # Distributed under the terms of the GNU General Public License v2 | |
3 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql/postgresql-8.2.6.ebuild,v 1.1 2008/01/13 01:44:21 mjolnir Exp $ | |
4 | |
5 inherit eutils flag-o-matic multilib toolchain-funcs versionator | |
6 | |
7 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd" | |
8 | |
9 MY_PV="${PV/_rc/RC}" | |
10 DESCRIPTION="Sophisticated and powerful Object-Relational DBMS." | |
11 HOMEPAGE="http://www.postgresql.org/" | |
12 SRC_URI="mirror://postgresql/source/v${MY_PV}/${PN}-${MY_PV}.tar.bz2" | |
13 LICENSE="POSTGRESQL" | |
14 SLOT="0" | |
15 IUSE="doc kerberos kernel_linux nls pam perl pg-intdatetime python readline selinux ssl tcl test xml zlib" | |
16 RESTRICT="nomirror" | |
17 S="${WORKDIR}/${PN}-${MY_PV}" | |
18 | |
19 RDEPEND="~dev-db/libpq-${PV} | |
20 >=sys-libs/ncurses-5.2 | |
21 kerberos? ( virtual/krb5 ) | |
22 pam? ( virtual/pam ) | |
23 perl? ( >=dev-lang/perl-5.6.1-r2 ) | |
24 python? ( >=dev-lang/python-2.2 dev-python/egenix-mx-base ) | |
25 readline? ( >=sys-libs/readline-4.1 ) | |
26 selinux? ( sec-policy/selinux-postgresql ) | |
27 ssl? ( >=dev-libs/openssl-0.9.6-r1 ) | |
28 tcl? ( >=dev-lang/tcl-8 ) | |
29 xml? ( dev-libs/libxml2 dev-libs/libxslt ) | |
30 zlib? ( >=sys-libs/zlib-1.1.3 )" | |
31 DEPEND="${RDEPEND} | |
32 sys-devel/autoconf | |
33 >=sys-devel/bison-1.875 | |
34 nls? ( sys-devel/gettext ) | |
35 xml? ( dev-util/pkgconfig )" | |
36 | |
37 PG_DIR="/var/lib/postgresql" | |
38 [[ -z "${PG_MAX_CONNECTIONS}" ]] && PG_MAX_CONNECTIONS="512" | |
39 | |
40 pkg_setup() { | |
41 if [[ -f "${PG_DIR}/data/PG_VERSION" ]] ; then | |
42 if [[ $(cat "${PG_DIR}/data/PG_VERSION") != $(get_version_component_range 1-2) ]] ; then | |
43 eerror "PostgreSQL ${PV} cannot upgrade your existing databases, you must" | |
44 eerror "use pg_dump to export your existing databases to a file, and then" | |
45 eerror "pg_restore to import them when you have upgraded completely." | |
46 eerror "You must remove your entire database directory to continue." | |
47 eerror "(database directory = ${PG_DIR})." | |
48 die "Remove your database directory to continue" | |
49 fi | |
50 fi | |
51 enewgroup postgres 70 | |
52 enewuser postgres 70 /bin/bash /var/lib postgres | |
53 } | |
54 | |
55 src_unpack() { | |
56 unpack ${A} | |
57 cd "${S}" | |
58 | |
59 epatch "${FILESDIR}/${PN}-${PV}-gentoo.patch" | |
60 epatch "${FILESDIR}/${PN}-${PV}-sh.patch" | |
61 | |
62 # Prepare package for future tests | |
63 if use test ; then | |
64 # Fix sandbox violation; note that we're stripping redundant slashes | |
65 # from ${S}, because otherwise the test would fail. | |
66 sed -e "s|/no/such/location|${S/\/\//\/}/src/test/regress/tmp_check/no/such/location|g" -i src/test/regress/{input,output}/tablespace.source | |
67 | |
68 # We need to run the tests as a non-root user, portage seems the most fitting here, | |
69 # so if userpriv is enabled, we use it directly. If userpriv is disabled, we need to | |
70 # su - to a valid user, portage again, so we patch the test-scripts to do that. | |
71 mkdir -p "${S}/src/test/regress/tmp_check" | |
72 chown portage "${S}/src/test/regress/tmp_check" | |
73 einfo "Tests will be run as user portage." | |
74 if ! hasq userpriv ${FEATURES} ; then | |
75 mkdir -p "${S}/src/test/regress/results" | |
76 chown portage "${S}/src/test/regress/results" | |
77 epatch "${FILESDIR}/${PN}-${PV}-regress_su.patch" | |
78 fi | |
79 fi | |
80 } | |
81 | |
82 src_compile() { | |
83 filter-flags -ffast-math -feliminate-dwarf2-dups | |
84 | |
85 econf --prefix=/usr \ | |
86 --includedir=/usr/include/postgresql/pgsql \ | |
87 --sysconfdir=/etc/postgresql \ | |
88 --mandir=/usr/share/man \ | |
89 --host=${CHOST} \ | |
90 --with-docdir=/usr/share/doc/${PF} \ | |
91 --libdir=/usr/$(get_libdir) \ | |
92 --enable-depend \ | |
93 $(use_with kerberos krb5) \ | |
94 $(use_enable nls ) \ | |
95 $(use_with pam) \ | |
96 $(use_with perl) \ | |
97 $(use_enable pg-intdatetime integer-datetimes ) \ | |
98 $(use_with python) \ | |
99 $(use_with readline) \ | |
100 $(use_with ssl openssl) \ | |
101 $(use_with tcl) \ | |
102 $(use_with zlib) \ | |
103 || die "configure failed" | |
104 | |
105 emake -j1 LD="$(tc-getLD) $(get_abi_LDFLAGS)" || die "main emake failed" | |
106 | |
107 cd "${S}/contrib" | |
108 emake -j1 LD="$(tc-getLD) $(get_abi_LDFLAGS)" || die "contrib emake failed" | |
109 | |
110 if use xml ; then | |
111 cd "${S}/contrib/xml2" | |
112 emake -j1 LD="$(tc-getLD) $(get_abi_LDFLAGS)" || die "contrib/xml2 emake failed" | |
113 fi | |
114 } | |
115 | |
116 src_install() { | |
117 if use perl ; then | |
118 mv -f "${S}/src/pl/plperl/GNUmakefile" "${S}/src/pl/plperl/GNUmakefile_orig" | |
119 sed -e "s:\$(DESTDIR)\$(plperl_installdir):\$(plperl_installdir):" \ | |
120 "${S}/src/pl/plperl/GNUmakefile_orig" > "${S}/src/pl/plperl/GNUmakefile" | |
121 fi | |
122 | |
123 cd "${S}" | |
124 emake -j1 DESTDIR="${D}" LIBDIR="${D}/usr/$(get_libdir)" install || die "main emake install failed" | |
125 | |
126 cd "${S}/contrib" | |
127 emake -j1 DESTDIR="${D}" LIBDIR="${D}/usr/$(get_libdir)" install || die "contrib emake install failed" | |
128 | |
129 if use xml ; then | |
130 cd "${S}/contrib/xml2" | |
131 emake -j1 DESTDIR="${D}" LIBDIR="${D}/usr/$(get_libdir)" install || die "contrib/xml2 emake install failed" | |
132 fi | |
133 | |
134 cd "${S}" | |
135 dodoc README HISTORY | |
136 | |
137 cd "${S}/doc" | |
138 dodoc FAQ* README.* TODO bug.template | |
139 | |
140 if use doc ; then | |
141 cd "${S}/doc" | |
142 docinto FAQ_html | |
143 dodoc src/FAQ/* | |
144 docinto sgml | |
145 dodoc src/sgml/*.{sgml,dsl} | |
146 docinto sgml/ref | |
147 dodoc src/sgml/ref/*.sgml | |
148 docinto TODO.detail | |
149 dodoc TODO.detail/* | |
150 fi | |
151 | |
152 newinitd "${FILESDIR}/postgresql.init-${PV%[._]*}" postgresql || die "Inserting init.d-file failed" | |
153 newconfd "${FILESDIR}/postgresql.conf-${PV%[._]*}" postgresql || die "Inserting conf.d-file failed" | |
154 } | |
155 | |
156 pkg_postinst() { | |
157 elog "Execute the following command to setup the initial database environment:" | |
158 elog | |
159 elog "emerge --config =${PF}" | |
160 elog | |
161 elog "The autovacuum function, which was in contrib, has been moved to the main" | |
162 elog "PostgreSQL functions starting with 8.1." | |
163 elog "You can enable it in ${ROOT}/etc/postgresql/postgresql.conf." | |
164 elog | |
165 elog "If you need a global psqlrc-file, you can place it in '${ROOT}/etc/postgresql/'." | |
166 } | |
167 | |
168 pkg_config() { | |
169 einfo "Creating the data directory ..." | |
170 mkdir -p "${PG_DIR}/data" | |
171 chown -Rf postgres:postgres "${PG_DIR}" | |
172 chmod 0700 "${PG_DIR}/data" | |
173 | |
174 einfo "Initializing the database ..." | |
175 if [[ -f "${PG_DIR}/data/PG_VERSION" ]] ; then | |
176 eerror "PostgreSQL ${PV} cannot upgrade your existing databases." | |
177 eerror "You must remove your entire database directory to continue." | |
178 eerror "(database directory = ${PG_DIR})." | |
179 die "Remove your database directory to continue" | |
180 else | |
181 if use kernel_linux ; then | |
182 local SEM=`sysctl -n kernel.sem | cut -f-3` | |
183 local SEMMNI=`sysctl -n kernel.sem | cut -f4` | |
184 local SEMMNI_MIN=`expr \( ${PG_MAX_CONNECTIONS} + 15 \) / 16` | |
185 local SHMMAX=`sysctl -n kernel.shmmax` | |
186 local SHMMAX_MIN=`expr 500000 + 30600 \* ${PG_MAX_CONNECTIONS}` | |
187 | |
188 if [ ${SEMMNI} -lt ${SEMMNI_MIN} ] ; then | |
189 eerror "The current value of SEMMNI is too low" | |
190 eerror "for PostgreSQL to run ${PG_MAX_CONNECTIONS} connections!" | |
191 eerror "Temporary setting this value to ${SEMMNI_MIN} while creating the initial database." | |
192 echo ${SEM} ${SEMMNI_MIN} > /proc/sys/kernel/sem | |
193 fi | |
194 | |
195 su postgres -c "/usr/bin/initdb --pgdata ${PG_DIR}/data" | |
196 | |
197 if [ ! `sysctl -n kernel.sem | cut -f4` -eq ${SEMMNI} ] ; then | |
198 echo ${SEM} ${SEMMNI} > /proc/sys/kernel/sem | |
199 ewarn "Restoring the SEMMNI value to the previous value." | |
200 ewarn "Please edit the last value of kernel.sem in /etc/sysctl.conf" | |
201 ewarn "and set it to at least ${SEMMNI_MIN}:" | |
202 ewarn | |
203 ewarn " kernel.sem = ${SEM} ${SEMMNI_MIN}" | |
204 ewarn | |
205 fi | |
206 | |
207 if [ ${SHMMAX} -lt ${SHMMAX_MIN} ] ; then | |
208 eerror "The current value of SHMMAX is too low for postgresql to run." | |
209 eerror "Please edit /etc/sysctl.conf and set this value to at least ${SHMMAX_MIN}:" | |
210 eerror | |
211 eerror " kernel.shmmax = ${SHMMAX_MIN}" | |
212 eerror | |
213 fi | |
214 else | |
215 su postgres -c "/usr/bin/initdb --pgdata ${PG_DIR}/data" | |
216 fi | |
217 | |
218 einfo | |
219 einfo "You can use the '${ROOT}/etc/init.d/postgresql' script to run PostgreSQL instead of 'pg_ctl'." | |
220 einfo | |
221 fi | |
222 } | |
223 | |
224 src_test() { | |
225 cd "${S}" | |
226 | |
227 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}" | |
228 if ! emake -j1 check ; then | |
229 hasq test ${FEATURES} && die "Make check failed. See above for details." | |
230 hasq test ${FEATURES} || eerror "Make check failed. See above for details." | |
231 fi | |
232 | |
233 einfo "Yes, there are other tests which could be run." | |
234 einfo "... and no, we don't plan to add/support them." | |
235 einfo "For now, the main regressions tests will suffice." | |
236 einfo "If you think other tests are necessary, please submit a" | |
237 einfo "bug including a patch for this ebuild to enable them." | |
238 } |