Line 0
Link Here
|
|
|
1 |
# Copyright 1999-2007 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/dev-lang/php/php-5.2.2-r1.ebuild,v 1.9 2007/05/12 11:26:51 corsair Exp $ |
4 |
|
5 |
CGI_SAPI_USE="discard-path force-cgi-redirect" |
6 |
APACHE2_SAPI_USE="concurrentmodphp threads" |
7 |
IUSE="cli cgi ${CGI_SAPI_USE} ${APACHE2_SAPI_USE} fastbuild" |
8 |
|
9 |
KEYWORDS="alpha amd64 ~arm hppa ia64 ppc ppc64 ~s390 ~sh sparc x86 ~x86-fbsd" |
10 |
|
11 |
# NOTE: Portage doesn't support setting PROVIDE based on the USE flags |
12 |
# that have been enabled, so we have to PROVIDE everything for now |
13 |
# and hope for the best |
14 |
PROVIDE="virtual/php virtual/httpd-php" |
15 |
|
16 |
# php package settings |
17 |
SLOT="5" |
18 |
MY_PHP_PV="${PV}" |
19 |
MY_PHP_P="php-${MY_PHP_PV}" |
20 |
PHP_PACKAGE="1" |
21 |
|
22 |
# php patch settings, general |
23 |
PHP_PATCHSET_REV="1" |
24 |
SUHOSIN_PATCH="suhosin-patch-${MY_PHP_PV}-0.9.6.2.patch.gz" |
25 |
MULTILIB_PATCH="${MY_PHP_PV}/opt/php${MY_PHP_PV}-multilib-search-path.patch" |
26 |
# php patch settings, ebuild specific |
27 |
FASTBUILD_PATCH="${MY_PHP_PV}/opt/php${MY_PHP_PV}-fastbuild.patch" |
28 |
CONCURRENTMODPHP_PATCH="${MY_PHP_PV}/opt/php${MY_PHP_PV}-concurrent_apache_modules.patch" |
29 |
|
30 |
inherit php5_2-sapi apache-module |
31 |
|
32 |
DESCRIPTION="The PHP language runtime engine: CLI, CGI and Apache2 SAPIs." |
33 |
|
34 |
DEPEND="app-admin/php-toolkit" |
35 |
RDEPEND="${DEPEND}" |
36 |
|
37 |
want_apache |
38 |
|
39 |
pkg_setup() { |
40 |
PHPCONFUTILS_AUTO_USE="" |
41 |
|
42 |
# Make sure the user has specified at least one SAPI |
43 |
einfo "Determining SAPI(s) to build" |
44 |
phpconfutils_require_any " Enabled SAPI:" " Disabled SAPI:" cli cgi apache2 |
45 |
|
46 |
# Threaded Apache2 support |
47 |
if use apache2 ; then |
48 |
if [[ "${APACHE_VERSION}" != "0" ]] ; then |
49 |
if ! use threads ; then |
50 |
APACHE2_SAFE_MPMS="itk peruser prefork" |
51 |
else |
52 |
APACHE2_SAFE_MPMS="event leader metuxmpm perchild threadpool worker" |
53 |
fi |
54 |
|
55 |
ewarn |
56 |
ewarn "If this package fails with a fatal error about Apache2 not having" |
57 |
ewarn "been compiled with a compatible MPM, this is normally because you" |
58 |
ewarn "need to toggle the 'threads' USE flag." |
59 |
ewarn |
60 |
ewarn "If 'threads' is off, try switching it on." |
61 |
ewarn "If 'threads' is on, try switching it off." |
62 |
ewarn |
63 |
|
64 |
apache-module_pkg_setup |
65 |
fi |
66 |
fi |
67 |
|
68 |
# Concurrent PHP Apache2 modules support |
69 |
if use apache2 ; then |
70 |
if [[ "${APACHE_VERSION}" != "0" ]] ; then |
71 |
if use concurrentmodphp ; then |
72 |
ewarn |
73 |
ewarn "'concurrentmodphp' makes it possible to load multiple, differently" |
74 |
ewarn "versioned mod_php's into the same Apache instance. This is done with" |
75 |
ewarn "a few linker tricks and workarounds, and is not guaranteed to always" |
76 |
ewarn "work correctly, so use it at your own risk. Especially, do not use" |
77 |
ewarn "this in conjunction with PHP modules (PECL, ...) other than the ones" |
78 |
ewarn "you may find in the Portage tree or the PHP Overlay!" |
79 |
ewarn "This is an experimental feature, so please rebuild PHP" |
80 |
ewarn "without the 'concurrentmodphp' USE flag if you experience" |
81 |
ewarn "any problems, and then reproduce any bugs before filing" |
82 |
ewarn "them in Gentoo's Bugzilla or bugs.php.net." |
83 |
ewarn "If you have conclusive evidence that a bug directly" |
84 |
ewarn "derives from 'concurrentmodphp', please file a bug in" |
85 |
ewarn "Gentoo's Bugzilla only." |
86 |
ewarn |
87 |
ebeep 5 |
88 |
fi |
89 |
fi |
90 |
fi |
91 |
|
92 |
# fastbuild support |
93 |
if use fastbuild ; then |
94 |
ewarn |
95 |
ewarn "'fastbuild' attempts to build all SAPIs in a single pass." |
96 |
ewarn "This is an experimental feature, so please rebuild PHP" |
97 |
ewarn "without the 'fastbuild' USE flag if you experience" |
98 |
ewarn "any problems, and then reproduce any bugs before filing" |
99 |
ewarn "them in Gentoo's Bugzilla or bugs.php.net." |
100 |
ewarn "If you have conclusive evidence that a bug directly" |
101 |
ewarn "derives from 'fastbuild', please file a bug in" |
102 |
ewarn "Gentoo's Bugzilla only." |
103 |
ewarn |
104 |
fi |
105 |
|
106 |
php5_2-sapi_pkg_setup |
107 |
} |
108 |
|
109 |
php_determine_sapis() { |
110 |
# holds the list of sapis that we want to build |
111 |
PHPSAPIS= |
112 |
|
113 |
if use cli || phpconfutils_usecheck cli ; then |
114 |
PHPSAPIS="${PHPSAPIS} cli" |
115 |
fi |
116 |
|
117 |
if use cgi ; then |
118 |
PHPSAPIS="${PHPSAPIS} cgi" |
119 |
fi |
120 |
|
121 |
# note - apache SAPI comes after the simpler cli/cgi sapis |
122 |
if use apache2 ; then |
123 |
if [[ "${APACHE_VERSION}" != "0" ]] ; then |
124 |
PHPSAPIS="${PHPSAPIS} apache${APACHE_VERSION}" |
125 |
fi |
126 |
fi |
127 |
} |
128 |
|
129 |
src_unpack() { |
130 |
if [[ "${PHP_PACKAGE}" == 1 ]] ; then |
131 |
unpack ${A} |
132 |
fi |
133 |
|
134 |
cd "${S}" |
135 |
|
136 |
# Concurrent PHP Apache2 modules support |
137 |
if use apache2 ; then |
138 |
if [[ "${APACHE_VERSION}" != "0" ]] ; then |
139 |
if use concurrentmodphp ; then |
140 |
if [[ -n "${CONCURRENTMODPHP_PATCH}" ]] && [[ -f "${WORKDIR}/${CONCURRENTMODPHP_PATCH}" ]] ; then |
141 |
epatch "${WORKDIR}/${CONCURRENTMODPHP_PATCH}" |
142 |
else |
143 |
ewarn "There is no concurrent mod_php patch available for this PHP release yet!" |
144 |
fi |
145 |
fi |
146 |
fi |
147 |
fi |
148 |
|
149 |
# fastbuild support |
150 |
if use fastbuild ; then |
151 |
if [[ -n "${FASTBUILD_PATCH}" ]] && [[ -f "${WORKDIR}/${FASTBUILD_PATCH}" ]] ; then |
152 |
epatch "${WORKDIR}/${FASTBUILD_PATCH}" |
153 |
else |
154 |
ewarn "There is no fastbuild patch available for this PHP release yet!" |
155 |
fi |
156 |
fi |
157 |
|
158 |
# Now let the eclass do the rest and regenerate the configure |
159 |
php5_2-sapi_src_unpack |
160 |
|
161 |
# Fix Makefile.global:test to consider the CGI SAPI if present |
162 |
if use cgi ; then |
163 |
sed -e "s|test \! -z \"\$(top_builddir)/php-cli\" \&\& test -x \"\$(top_builddir)/php-cli\"|test \! -z \"\$(top_builddir)/php-cli\" \&\& test -x \"\$(top_builddir)/php-cli\" \&\& test \! -z \"\$(top_builddir)/php-cgi\" \&\& test -x \"\$(top_builddir)/php-cgi\"|g" -i Makefile.global |
164 |
sed -e "s|TEST_PHP_EXECUTABLE=\"\$(top_builddir)/php-cli\"|TEST_PHP_EXECUTABLE=\"\$(top_builddir)/php-cli\" TEST_PHP_CGI_EXECUTABLE=\"\$(top_builddir)/php-cgi\"|g" -i Makefile.global |
165 |
fi |
166 |
} |
167 |
|
168 |
src_compile() { |
169 |
if use fastbuild && [[ -n "${FASTBUILD_PATCH}" ]] ; then |
170 |
src_compile_fastbuild |
171 |
else |
172 |
src_compile_normal |
173 |
fi |
174 |
} |
175 |
|
176 |
src_compile_fastbuild() { |
177 |
php_determine_sapis |
178 |
|
179 |
build_cli=0 |
180 |
build_cgi=0 |
181 |
build_apache2=0 |
182 |
my_conf="" |
183 |
|
184 |
for x in ${PHPSAPIS} ; do |
185 |
case ${x} in |
186 |
cli) |
187 |
build_cli=1 |
188 |
;; |
189 |
cgi) |
190 |
build_cgi=1 |
191 |
;; |
192 |
apache2) |
193 |
build_apache2=1 |
194 |
;; |
195 |
esac |
196 |
done |
197 |
|
198 |
if [[ ${build_cli} = 1 ]] ; then |
199 |
my_conf="${my_conf} --enable-cli" |
200 |
else |
201 |
my_conf="${my_conf} --disable-cli" |
202 |
fi |
203 |
|
204 |
if [[ ${build_cgi} = 1 ]] ; then |
205 |
my_conf="${my_conf} --enable-cgi --enable-fastcgi" |
206 |
phpconfutils_extension_enable "discard-path" "discard-path" 0 |
207 |
phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0 |
208 |
else |
209 |
my_conf="${my_conf} --disable-cgi" |
210 |
fi |
211 |
|
212 |
if [[ ${build_apache2} = 1 ]] ; then |
213 |
my_conf="${my_conf} --with-apxs2=/usr/sbin/apxs2" |
214 |
|
215 |
# Threaded Apache2 support |
216 |
if use threads ; then |
217 |
my_conf="${my_conf} --enable-maintainer-zts" |
218 |
ewarn "Enabling ZTS for Apache2 MPM" |
219 |
fi |
220 |
|
221 |
# Concurrent PHP Apache2 modules support |
222 |
if use concurrentmodphp ; then |
223 |
append-ldflags "-Wl,--version-script=${FILESDIR}/php5-ldvs" |
224 |
fi |
225 |
fi |
226 |
|
227 |
# Now we know what we are building, build it |
228 |
php5_2-sapi_src_compile |
229 |
|
230 |
# To keep the separate php.ini files for each SAPI, we change the |
231 |
# build-defs.h and recompile |
232 |
|
233 |
if [[ ${build_cli} = 1 ]] ; then |
234 |
einfo |
235 |
einfo "Building CLI SAPI" |
236 |
einfo |
237 |
|
238 |
sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php/cli-php5"|g;' -i main/build-defs.h |
239 |
sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php/cli-php5/ext-active"|g;' -i main/build-defs.h |
240 |
for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do |
241 |
[[ -f ${x} ]] && rm -f ${x} |
242 |
done |
243 |
make sapi/cli/php || die "Unable to make CLI SAPI" |
244 |
cp sapi/cli/php php-cli || die "Unable to copy CLI SAPI" |
245 |
fi |
246 |
|
247 |
if [[ ${build_cgi} = 1 ]] ; then |
248 |
einfo |
249 |
einfo "Building CGI SAPI" |
250 |
einfo |
251 |
|
252 |
sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php/cgi-php5"|g;' -i main/build-defs.h |
253 |
sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php/cgi-php5/ext-active"|g;' -i main/build-defs.h |
254 |
for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do |
255 |
[[ -f ${x} ]] && rm -f ${x} |
256 |
done |
257 |
make sapi/cgi/php-cgi || die "Unable to make CGI SAPI" |
258 |
cp sapi/cgi/php-cgi php-cgi || die "Unable to copy CGI SAPI" |
259 |
fi |
260 |
|
261 |
if [[ ${build_apache2} = 1 ]] ; then |
262 |
einfo |
263 |
einfo "Building apache${APACHE_VERSION} SAPI" |
264 |
einfo |
265 |
|
266 |
sed -e "s|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH \"/etc/php/apache${APACHE_VERSION}-php5\"|g;" -i main/build-defs.h |
267 |
sed -e "s|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR \"/etc/php/apache${APACHE_VERSION}-php5/ext-active\"|g;" -i main/build-defs.h |
268 |
for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do |
269 |
[[ -f ${x} ]] && rm -f ${x} |
270 |
done |
271 |
make || die "Unable to make apache${APACHE_VERSION} SAPI" |
272 |
fi |
273 |
} |
274 |
|
275 |
src_compile_normal() { |
276 |
php_determine_sapis |
277 |
|
278 |
CLEAN_REQUIRED=0 |
279 |
my_conf="" |
280 |
|
281 |
# Support the Apache2 extras, they must be set globally for all |
282 |
# SAPIs to work correctly, especially for external PHP extensions |
283 |
if use apache2 ; then |
284 |
if [[ "${APACHE_VERSION}" != "0" ]] ; then |
285 |
# Concurrent PHP Apache2 modules support |
286 |
if use concurrentmodphp ; then |
287 |
append-ldflags "-Wl,--version-script=${FILESDIR}/php5-ldvs" |
288 |
fi |
289 |
fi |
290 |
fi |
291 |
|
292 |
for x in ${PHPSAPIS} ; do |
293 |
# Support the Apache2 extras, they must be set globally for all |
294 |
# SAPIs to work correctly, especially for external PHP extensions |
295 |
if use apache2 ; then |
296 |
if [[ "${APACHE_VERSION}" != "0" ]] ; then |
297 |
# Threaded Apache2 support |
298 |
if use threads ; then |
299 |
my_conf="${my_conf} --enable-maintainer-zts" |
300 |
ewarn "Enabling ZTS for Apache2 MPM" |
301 |
fi |
302 |
fi |
303 |
fi |
304 |
|
305 |
if [[ "${CLEAN_REQUIRED}" = 1 ]] ; then |
306 |
make clean |
307 |
fi |
308 |
|
309 |
PHPSAPI="${x}" |
310 |
|
311 |
case ${x} in |
312 |
cli) |
313 |
my_conf="${my_conf} --enable-cli --disable-cgi" |
314 |
php5_2-sapi_src_compile |
315 |
cp sapi/cli/php php-cli || die "Unable to copy CLI SAPI" |
316 |
;; |
317 |
cgi) |
318 |
my_conf="${my_conf} --disable-cli --enable-cgi --enable-fastcgi" |
319 |
phpconfutils_extension_enable "discard-path" "discard-path" 0 |
320 |
phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0 |
321 |
php5_2-sapi_src_compile |
322 |
cp sapi/cgi/php-cgi php-cgi || die "Unable to copy CGI SAPI" |
323 |
;; |
324 |
apache2) |
325 |
my_conf="${my_conf} --disable-cli --with-apxs2=/usr/sbin/apxs2" |
326 |
php5_2-sapi_src_compile |
327 |
;; |
328 |
esac |
329 |
|
330 |
CLEAN_REQUIRED=1 |
331 |
my_conf="" |
332 |
done |
333 |
} |
334 |
|
335 |
src_install() { |
336 |
php_determine_sapis |
337 |
|
338 |
destdir=/usr/$(get_libdir)/php5 |
339 |
|
340 |
# Let the eclass do the common work |
341 |
php5_2-sapi_src_install |
342 |
|
343 |
einfo |
344 |
einfo "Installing SAPI(s) ${PHPSAPIS}" |
345 |
einfo |
346 |
|
347 |
for x in ${PHPSAPIS} ; do |
348 |
|
349 |
PHPSAPI="${x}" |
350 |
|
351 |
case ${x} in |
352 |
cli) |
353 |
einfo "Installing CLI SAPI" |
354 |
into ${destdir} |
355 |
newbin php-cli php || die "Unable to install ${x} sapi" |
356 |
php5_2-sapi_install_ini |
357 |
;; |
358 |
cgi) |
359 |
einfo "Installing CGI SAPI" |
360 |
into ${destdir} |
361 |
dobin php-cgi || die "Unable to install ${x} sapi" |
362 |
php5_2-sapi_install_ini |
363 |
;; |
364 |
apache2) |
365 |
einfo "Installing Apache${APACHE_VERSION} SAPI" |
366 |
make INSTALL_ROOT="${D}" install-sapi || die "Unable to install ${x} SAPI" |
367 |
if use concurrentmodphp ; then |
368 |
einfo "Installing Apache${APACHE_VERSION} config file for PHP5-concurrent (70_mod_php5_concurr.conf)" |
369 |
insinto ${APACHE_MODULES_CONFDIR} |
370 |
newins "${FILESDIR}/70_mod_php5_concurr.conf-apache2" "70_mod_php5_concurr.conf" |
371 |
|
372 |
# Put the ld version script in the right place so it's always accessible |
373 |
insinto "/var/lib/php-pkg/${CATEGORY}/${PN}-${PVR}/" |
374 |
doins "${FILESDIR}/php5-ldvs" |
375 |
|
376 |
# Redefine the extension dir to have the modphp suffix |
377 |
PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`-versioned" |
378 |
else |
379 |
einfo "Installing Apache${APACHE_VERSION} config file for PHP5 (70_mod_php5.conf)" |
380 |
insinto ${APACHE_MODULES_CONFDIR} |
381 |
newins "${FILESDIR}/70_mod_php5.conf-apache2" "70_mod_php5.conf" |
382 |
fi |
383 |
php5_2-sapi_install_ini |
384 |
;; |
385 |
esac |
386 |
done |
387 |
|
388 |
# Install env.d files |
389 |
newenvd "${FILESDIR}/20php5-envd" "20php5" |
390 |
sed -e "s|/lib/|/$(get_libdir)/|g" -i "${D}/etc/env.d/20php5" |
391 |
} |
392 |
|
393 |
pkg_postinst() { |
394 |
# Output some general info to the user |
395 |
if use apache2 ; then |
396 |
APACHE2_MOD_DEFINE="PHP5" |
397 |
if use concurrentmodphp ; then |
398 |
APACHE2_MOD_CONF="70_mod_php5_concurr" |
399 |
else |
400 |
APACHE2_MOD_CONF="70_mod_php5" |
401 |
fi |
402 |
apache-module_pkg_postinst |
403 |
fi |
404 |
|
405 |
# Update Apache2 to use mod_php |
406 |
if use apache2 ; then |
407 |
"${ROOT}/usr/sbin/php-select" -t apache2 php5 > /dev/null 2>&1 |
408 |
exitStatus=$? |
409 |
if [[ ${exitStatus} == 2 ]] ; then |
410 |
php-select apache2 php5 |
411 |
elif [[ ${exitStatus} == 4 ]] ; then |
412 |
ewarn |
413 |
ewarn "Apache2 is configured to load a different version of PHP." |
414 |
ewarn "To make Apache2 use PHP v5, use php-select:" |
415 |
ewarn |
416 |
ewarn " php-select apache2 php5" |
417 |
ewarn |
418 |
fi |
419 |
fi |
420 |
|
421 |
# Create the symlinks for php-cli |
422 |
if use cli || phpconfutils_usecheck cli ; then |
423 |
"${ROOT}/usr/sbin/php-select" -t php php5 > /dev/null 2>&1 |
424 |
exitStatus=$? |
425 |
if [[ ${exitStatus} == 5 ]] ; then |
426 |
php-select php php5 |
427 |
elif [[ ${exitStatus} == 4 ]] ; then |
428 |
ewarn |
429 |
ewarn "/usr/bin/php links to a different version of PHP." |
430 |
ewarn "To make /usr/bin/php point to PHP v5, use php-select:" |
431 |
ewarn |
432 |
ewarn " php-select php php5" |
433 |
ewarn |
434 |
fi |
435 |
fi |
436 |
|
437 |
# Create the symlinks for php-cgi |
438 |
if use cgi ; then |
439 |
"${ROOT}/usr/sbin/php-select" -t php-cgi php5 > /dev/null 2>&1 |
440 |
exitStatus=$? |
441 |
if [[ ${exitStatus} == 5 ]] ; then |
442 |
php-select php-cgi php5 |
443 |
elif [[ ${exitStatus} == 4 ]] ; then |
444 |
ewarn |
445 |
ewarn "/usr/bin/php-cgi links to a different version of PHP." |
446 |
ewarn "To make /usr/bin/php-cgi point to PHP v5, use php-select:" |
447 |
ewarn |
448 |
ewarn " php-select php-cgi php5" |
449 |
ewarn |
450 |
fi |
451 |
fi |
452 |
|
453 |
# Create the symlinks for php-devel |
454 |
"${ROOT}/usr/sbin/php-select" -t php-devel php5 > /dev/null 2>&1 |
455 |
exitStatus=$? |
456 |
if [[ $exitStatus == 5 ]] ; then |
457 |
php-select php-devel php5 |
458 |
elif [[ $exitStatus == 4 ]] ; then |
459 |
ewarn |
460 |
ewarn "/usr/bin/php-config and/or /usr/bin/phpize are linked to a" |
461 |
ewarn "different version of PHP. To make them point to PHP v5, use" |
462 |
ewarn "php-select:" |
463 |
ewarn |
464 |
ewarn " php-select php-devel php5" |
465 |
ewarn |
466 |
fi |
467 |
|
468 |
php5_2-sapi_pkg_postinst |
469 |
} |
470 |
|
471 |
src_test() { |
472 |
einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" |
473 |
if ! emake -j1 test ; then |
474 |
hasq test ${FEATURES} && die "Make test failed. See above for details." |
475 |
hasq test ${FEATURES} || eerror "Make test failed. See above for details." |
476 |
fi |
477 |
} |