| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2005 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.5 2005/09/25 12:30:26 swegener Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.6 2005/10/31 14:08:42 chtekk Exp $ |
| 4 | # |
4 | # |
| 5 | # ======================================================================== |
5 | # ======================================================================== |
| 6 | # |
6 | # |
| 7 | # depend.php.eclass |
7 | # depend.php.eclass |
| 8 | # functions to allow ebuilds to depend on php4 and/or php5 |
8 | # functions to allow ebuilds to depend on php4 and/or php5 |
| … | |
… | |
| 131 | # |
131 | # |
| 132 | # this function will disappear when USE-based deps are supported by |
132 | # this function will disappear when USE-based deps are supported by |
| 133 | # Portage |
133 | # Portage |
| 134 | # |
134 | # |
| 135 | # $1 ... a list of SAPI USE flags (eg cli, cgi, apache2) |
135 | # $1 ... a list of SAPI USE flags (eg cli, cgi, apache2) |
| 136 | # |
136 | # |
| 137 | # returns if any one of the listed SAPIs has been installed |
137 | # returns if any one of the listed SAPIs has been installed |
| 138 | # dies if none of the listed SAPIs has been installed |
138 | # dies if none of the listed SAPIs has been installed |
| 139 | |
139 | |
| 140 | require_php_sapi_from() |
140 | require_php_sapi_from() |
| 141 | { |
141 | { |
| … | |
… | |
| 171 | # |
171 | # |
| 172 | # this function will disappear when USE-based deps are supported by |
172 | # this function will disappear when USE-based deps are supported by |
| 173 | # Portage |
173 | # Portage |
| 174 | # |
174 | # |
| 175 | # $1 ... a list of USE flags |
175 | # $1 ... a list of USE flags |
| 176 | # |
176 | # |
| 177 | # returns if all of the listed USE flags are set |
177 | # returns if all of the listed USE flags are set |
| 178 | # dies if any of the listed USE flags are not set |
178 | # dies if any of the listed USE flags are not set |
| 179 | |
179 | |
| 180 | require_php_with_use() |
180 | require_php_with_use() |
| 181 | { |
181 | { |
| … | |
… | |
| 218 | return |
218 | return |
| 219 | fi |
219 | fi |
| 220 | |
220 | |
| 221 | if [[ -z ${PHP_VERSION} ]]; then |
221 | if [[ -z ${PHP_VERSION} ]]; then |
| 222 | # detect which PHP version installed |
222 | # detect which PHP version installed |
|
|
223 | if has_version '=dev-lang/php-4*' ; then |
|
|
224 | PHP_VERSION=4 |
| 223 | if has_version '=dev-lang/php-5*' ; then |
225 | elif has_version '=dev-lang/php-5*' ; then |
| 224 | PHP_VERSION=5 |
226 | PHP_VERSION=5 |
| 225 | elif has_version '=dev-lang/php-4*' ; then |
|
|
| 226 | PHP_VERSION=4 |
|
|
| 227 | else |
227 | else |
| 228 | die "Unable to find an installed dev-lang/php package" |
228 | die "Unable to find an installed dev-lang/php package" |
| 229 | fi |
229 | fi |
| 230 | fi |
230 | fi |
| 231 | |
231 | |
| … | |
… | |
| 335 | if [[ -n ${PHP_PKG} ]]; then |
335 | if [[ -n ${PHP_PKG} ]]; then |
| 336 | return |
336 | return |
| 337 | fi |
337 | fi |
| 338 | |
338 | |
| 339 | # detect which PHP version installed |
339 | # detect which PHP version installed |
|
|
340 | if has_version '=dev-lang/php-4*' ; then |
|
|
341 | pkg="`best_version '=dev-lang/php-4*'`" |
|
|
342 | if built_with_use =${pkg} cli ; then |
|
|
343 | PHP_VERSION=4 |
|
|
344 | fi |
| 340 | if has_version '=dev-lang/php-5*' ; then |
345 | elif has_version '=dev-lang/php-5*' ; then |
| 341 | pkg="`best_version '=dev-lang/php-5*'`" |
346 | pkg="`best_version '=dev-lang/php-5*'`" |
| 342 | if built_with_use =${pkg} cli ; then |
347 | if built_with_use =${pkg} cli ; then |
| 343 | PHP_VERSION=5 |
348 | PHP_VERSION=5 |
| 344 | fi |
349 | fi |
| 345 | elif has_version '=dev-lang/php-4*' ; then |
|
|
| 346 | pkg="`best_version '=dev-lang/php-4*'`" |
|
|
| 347 | if built_with_use =${pkg} cli ; then |
|
|
| 348 | PHP_VERSION=4 |
|
|
| 349 | fi |
|
|
| 350 | else |
350 | else |
| 351 | die "Unable to find an installed dev-lang/php package" |
351 | die "Unable to find an installed dev-lang/php package" |
| 352 | fi |
352 | fi |
| 353 | |
353 | |
| 354 | if [[ -z ${PHP_VERSION} ]]; then |
354 | if [[ -z ${PHP_VERSION} ]]; then |
| … | |
… | |
| 373 | if [[ -n ${PHP_PKG} ]]; then |
373 | if [[ -n ${PHP_PKG} ]]; then |
| 374 | return |
374 | return |
| 375 | fi |
375 | fi |
| 376 | |
376 | |
| 377 | # detect which PHP version installed |
377 | # detect which PHP version installed |
|
|
378 | if has_version '=dev-lang/php-4*' ; then |
|
|
379 | pkg="`best_version '=dev-lang/php-4*'`" |
|
|
380 | if built_with_use =${pkg} cgi ; then |
|
|
381 | PHP_VERSION=4 |
|
|
382 | fi |
| 378 | if has_version '=dev-lang/php-5*' ; then |
383 | elif has_version '=dev-lang/php-5*' ; then |
| 379 | pkg="`best_version '=dev-lang/php-5*'`" |
384 | pkg="`best_version '=dev-lang/php-5*'`" |
| 380 | if built_with_use =${pkg} cgi ; then |
385 | if built_with_use =${pkg} cgi ; then |
| 381 | PHP_VERSION=5 |
386 | PHP_VERSION=5 |
| 382 | fi |
|
|
| 383 | elif has_version '=dev-lang/php-4*' ; then |
|
|
| 384 | pkg="`best_version '=dev-lang/php-4*'`" |
|
|
| 385 | if built_with_use =${pkg} cgi ; then |
|
|
| 386 | PHP_VERSION=4 |
|
|
| 387 | fi |
387 | fi |
| 388 | else |
388 | else |
| 389 | die "Unable to find an installed dev-lang/php package" |
389 | die "Unable to find an installed dev-lang/php package" |
| 390 | fi |
390 | fi |
| 391 | |
391 | |
| … | |
… | |
| 427 | eerror "this is done best by simply adding the" |
427 | eerror "this is done best by simply adding the" |
| 428 | eerror "'sqlite' USE flag when emerging dev-lang/php." |
428 | eerror "'sqlite' USE flag when emerging dev-lang/php." |
| 429 | eerror |
429 | eerror |
| 430 | die "No sqlite extension for PHP found" |
430 | die "No sqlite extension for PHP found" |
| 431 | } |
431 | } |
|
|
432 | |
|
|
433 | # require a PHP built with GD support |
| 432 | |
434 | |
| 433 | require_gd() |
435 | require_gd() |
| 434 | { |
436 | { |
| 435 | has_php |
437 | has_php |
| 436 | |
438 | |
| … | |
… | |
| 455 | eerror "the 'gd' or the 'gd-external' USE flags" |
457 | eerror "the 'gd' or the 'gd-external' USE flags" |
| 456 | eerror "turned on." |
458 | eerror "turned on." |
| 457 | eerror |
459 | eerror |
| 458 | die "No GD support found for PHP" |
460 | die "No GD support found for PHP" |
| 459 | } |
461 | } |
|
|
462 | |
|
|
463 | # ======================================================================== |
|
|
464 | # Misc functions |
|
|
465 | # |
|
|
466 | # These functions provide miscellaneous checks and functionality. |
|
|
467 | # ======================================================================== |
|
|
468 | |
|
|
469 | # executes some checks needed when installing a binary PHP extension |
|
|
470 | |
|
|
471 | php_binary_extension() { |
|
|
472 | has_php |
|
|
473 | |
|
|
474 | # binary extensions do not support the change of PHP |
|
|
475 | # API version, so they can't be installed when USE flags |
|
|
476 | # are enabled wich change the PHP API version |
|
|
477 | |
|
|
478 | if built_with_use =${PHP_PKG} hardenedphp ; then |
|
|
479 | eerror |
|
|
480 | eerror "You cannot install binary PHP extensions" |
|
|
481 | eerror "when the 'hardenedphp' USE flag is enabled!" |
|
|
482 | eerror "Please reemerge dev-lang/php with the" |
|
|
483 | eerror "'hardenedphp' USE flag turned off." |
|
|
484 | eerror |
|
|
485 | die "'hardenedphp' USE flag turned on" |
|
|
486 | fi |
|
|
487 | |
|
|
488 | if built_with_use =${PHP_PKG} debug ; then |
|
|
489 | eerror |
|
|
490 | eerror "You cannot install binary PHP extensions" |
|
|
491 | eerror "when the 'debug' USE flag is enabled!" |
|
|
492 | eerror "Please reemerge dev-lang/php with the" |
|
|
493 | eerror "'debug' USE flag turned off." |
|
|
494 | eerror |
|
|
495 | die "'debug' USE flag turned on" |
|
|
496 | fi |
|
|
497 | } |
|
|
498 | |
|
|
499 | # alternative to dodoc for use in our php eclasses and ebuilds |
|
|
500 | # stored here because depend.php gets always sourced everywhere |
|
|
501 | # in the PHP ebuilds and eclasses |
|
|
502 | # it simply is dodoc with a changed path to the docs |
|
|
503 | # no support for docinto is given! |
|
|
504 | |
|
|
505 | dodoc-php() |
|
|
506 | { |
|
|
507 | if [ $# -lt 1 ] ; then |
|
|
508 | echo "$0: at least one argument needed" 1>&2 |
|
|
509 | exit 1 |
|
|
510 | fi |
|
|
511 | |
|
|
512 | phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/" |
|
|
513 | |
|
|
514 | if [ ! -d "${phpdocdir}" ] ; then |
|
|
515 | install -d "${phpdocdir}" |
|
|
516 | fi |
|
|
517 | |
|
|
518 | for x in "$@" ; do |
|
|
519 | if [ -s "${x}" ] ; then |
|
|
520 | install -m0644 "${x}" "${phpdocdir}" |
|
|
521 | gzip -f -9 "${phpdocdir}/${x##*/}" |
|
|
522 | elif [ ! -e "${x}" ] ; then |
|
|
523 | echo "dodoc-php: ${x} does not exist" 1>&2 |
|
|
524 | fi |
|
|
525 | done |
|
|
526 | } |