| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2007 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.21 2007/09/01 15:58:17 jokey Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.25 2008/02/26 16:26:08 armin76 Exp $ |
| 4 | |
4 | |
| 5 | # Author: Stuart Herbert <stuart@gentoo.org> |
5 | # Author: Stuart Herbert <stuart@gentoo.org> |
| 6 | # Author: Luca Longinotti <chtekk@gentoo.org> |
6 | # Author: Luca Longinotti <chtekk@gentoo.org> |
| 7 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
7 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
| 8 | |
8 | |
| 9 | # @ECLASS: depend.php.eclass |
9 | # @ECLASS: depend.php.eclass |
| 10 | # @MAINTAINER: |
10 | # @MAINTAINER: |
| 11 | # Gentoo PHP team <php-bugs@gentoo.org> |
11 | # Gentoo PHP team <php-bugs@gentoo.org> |
| 12 | # @BLURB: Functions to allow ebuilds to depend on php[45] and check for specific features. |
12 | # @BLURB: Functions to allow ebuilds to depend on php[45] and check for specific features. |
| 13 | # @DESCRIPTION: |
13 | # @DESCRIPTION: |
| 14 | # This eclass provides functions that allow ebuilds to depend on php[45] and check |
14 | # This eclass provides functions that allow ebuilds to depend on php[45] and check |
| 15 | # for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install |
15 | # for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install |
| 16 | # documentation for PHP packages to php-specific location. |
16 | # documentation for PHP packages to php-specific location. |
| 17 | |
17 | |
| 18 | |
18 | |
| 19 | inherit eutils phpconfutils |
19 | inherit eutils phpconfutils |
| … | |
… | |
| 58 | |
58 | |
| 59 | PHPIZE="/usr/${libdir}/php4/bin/phpize" |
59 | PHPIZE="/usr/${libdir}/php4/bin/phpize" |
| 60 | PHPCONFIG="/usr/${libdir}/php4/bin/php-config" |
60 | PHPCONFIG="/usr/${libdir}/php4/bin/php-config" |
| 61 | PHPCLI="/usr/${libdir}/php4/bin/php" |
61 | PHPCLI="/usr/${libdir}/php4/bin/php" |
| 62 | PHPCGI="/usr/${libdir}/php4/bin/php-cgi" |
62 | PHPCGI="/usr/${libdir}/php4/bin/php-cgi" |
| 63 | PHP_PKG="`best_version =dev-lang/php-4*`" |
63 | PHP_PKG="$(best_version =dev-lang/php-4*)" |
| 64 | PHPPREFIX="/usr/${libdir}/php4" |
64 | PHPPREFIX="/usr/${libdir}/php4" |
| 65 | EXT_DIR="`${PHPCONFIG} --extension-dir 2>/dev/null`" |
65 | EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
| 66 | |
66 | |
| 67 | einfo |
67 | einfo |
| 68 | einfo "Using ${PHP_PKG}" |
68 | einfo "Using ${PHP_PKG}" |
| 69 | einfo |
69 | einfo |
| 70 | } |
70 | } |
| … | |
… | |
| 109 | |
109 | |
| 110 | PHPIZE="/usr/${libdir}/php5/bin/phpize" |
110 | PHPIZE="/usr/${libdir}/php5/bin/phpize" |
| 111 | PHPCONFIG="/usr/${libdir}/php5/bin/php-config" |
111 | PHPCONFIG="/usr/${libdir}/php5/bin/php-config" |
| 112 | PHPCLI="/usr/${libdir}/php5/bin/php" |
112 | PHPCLI="/usr/${libdir}/php5/bin/php" |
| 113 | PHPCGI="/usr/${libdir}/php5/bin/php-cgi" |
113 | PHPCGI="/usr/${libdir}/php5/bin/php-cgi" |
| 114 | PHP_PKG="`best_version =dev-lang/php-5*`" |
114 | PHP_PKG="$(best_version =dev-lang/php-5*)" |
| 115 | PHPPREFIX="/usr/${libdir}/php5" |
115 | PHPPREFIX="/usr/${libdir}/php5" |
| 116 | EXT_DIR="`${PHPCONFIG} --extension-dir 2>/dev/null`" |
116 | EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
| 117 | |
117 | |
| 118 | einfo |
118 | einfo |
| 119 | einfo "Using ${PHP_PKG}" |
119 | einfo "Using ${PHP_PKG}" |
| 120 | einfo |
120 | einfo |
| 121 | } |
121 | } |
| … | |
… | |
| 166 | |
166 | |
| 167 | |
167 | |
| 168 | # @FUNCTION: has_php |
168 | # @FUNCTION: has_php |
| 169 | # @DESCRIPTION: |
169 | # @DESCRIPTION: |
| 170 | # Call this function from your pkg_setup, src_compile, src_install etc. if you |
170 | # Call this function from your pkg_setup, src_compile, src_install etc. if you |
| 171 | # need to know which PHP version is being used and where the PHP binaries/data |
171 | # need to know which PHP version is being used and where the PHP binaries/data |
| 172 | # are installed. |
172 | # are installed. |
| 173 | has_php() { |
173 | has_php() { |
| 174 | # If PHP_PKG is already set, then we have remembered our PHP settings |
|
|
| 175 | # from last time |
|
|
| 176 | if [[ -n ${PHP_PKG} ]] ; then |
|
|
| 177 | return |
|
|
| 178 | fi |
|
|
| 179 | |
|
|
| 180 | if [[ -z ${PHP_VERSION} ]] ; then |
|
|
| 181 | # Detect which PHP version we have installed |
174 | # Detect which PHP version we have installed |
| 182 | if has_version '=dev-lang/php-5*' ; then |
175 | if has_version '=dev-lang/php-5*' ; then |
| 183 | PHP_VERSION="5" |
176 | PHP_VERSION="5" |
| 184 | elif has_version '=dev-lang/php-4*' ; then |
177 | elif has_version '=dev-lang/php-4*' ; then |
| 185 | PHP_VERSION="4" |
178 | PHP_VERSION="4" |
| 186 | else |
179 | else |
| 187 | die "Unable to find an installed dev-lang/php package" |
180 | die "Unable to find an installed dev-lang/php package" |
| 188 | fi |
|
|
| 189 | fi |
181 | fi |
| 190 | |
182 | |
| 191 | # If we get here, then PHP_VERSION tells us which version of PHP we |
183 | # If we get here, then PHP_VERSION tells us which version of PHP we |
| 192 | # want to use |
184 | # want to use |
| 193 | uses_php${PHP_VERSION} |
185 | uses_php${PHP_VERSION} |
| … | |
… | |
| 203 | # of them is available. |
195 | # of them is available. |
| 204 | # |
196 | # |
| 205 | # Unfortunately, if you want to be really sure that the required SAPI is |
197 | # Unfortunately, if you want to be really sure that the required SAPI is |
| 206 | # provided by PHP, you will have to use this function or similar ones (like |
198 | # provided by PHP, you will have to use this function or similar ones (like |
| 207 | # require_php_cli or require_php_cgi) in pkg_setup until we are able to |
199 | # require_php_cli or require_php_cgi) in pkg_setup until we are able to |
| 208 | # depend on USE flags being enabled. The above described need_php[45]_cli |
200 | # depend on USE flags being enabled. The above described need_php[45]_cli |
| 209 | # and need_php[45]_httpd functions cannot guarantee these requirements. |
201 | # and need_php[45]_httpd functions cannot guarantee these requirements. |
| 210 | # See Bug 2272 for details. |
202 | # See Bug 2272 for details. |
| 211 | require_php_sapi_from() { |
203 | require_php_sapi_from() { |
| 212 | has_php |
204 | has_php |
| 213 | |
205 | |
| … | |
… | |
| 245 | |
237 | |
| 246 | # @VARIABLE: PHPCHECKNODIE |
238 | # @VARIABLE: PHPCHECKNODIE |
| 247 | # @DESCRIPTION: |
239 | # @DESCRIPTION: |
| 248 | # You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple |
240 | # You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple |
| 249 | # require_php_with_(any)_use checks without making the ebuild die on every failure. |
241 | # require_php_with_(any)_use checks without making the ebuild die on every failure. |
| 250 | # This is useful in cases when certain PHP features are only required if specific |
242 | # This is useful in cases when certain PHP features are only required if specific |
| 251 | # USE flag(s) are enabled for that ebuild. |
243 | # USE flag(s) are enabled for that ebuild. |
| 252 | # @CODE |
244 | # @CODE |
| 253 | # Example: |
245 | # Example: |
| 254 | # |
246 | # |
| 255 | # local flags="pcre session snmp sockets wddx" |
247 | # local flags="pcre session snmp sockets wddx" |
| … | |
… | |
| 395 | # ======================================================================== |
387 | # ======================================================================== |
| 396 | |
388 | |
| 397 | # @FUNCTION: require_pdo |
389 | # @FUNCTION: require_pdo |
| 398 | # @DESCRIPTION: |
390 | # @DESCRIPTION: |
| 399 | # Require a PHP built with PDO support (PHP5 only). |
391 | # Require a PHP built with PDO support (PHP5 only). |
|
|
392 | # This function is now redundant and DEPRECATED since |
|
|
393 | # pdo-external use flag and pecl-pdo-* ebuilds were removed. |
|
|
394 | # You should use require_php_with_use pdo instead now. |
| 400 | # @RETURN: die if feature is missing |
395 | # @RETURN: die if feature is missing |
| 401 | require_pdo() { |
396 | require_pdo() { |
| 402 | has_php |
397 | has_php |
| 403 | |
398 | |
| 404 | # Do we have PHP5 installed? |
399 | # Do we have PHP5 installed? |
| 405 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
400 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
| 406 | eerror |
401 | eerror |
| 407 | eerror "This package requires PDO." |
402 | eerror "This package requires PDO." |
| 408 | eerror "PDO is only available for PHP 5." |
403 | eerror "PDO is only available for PHP 5." |
| 409 | eerror "You must install >=dev-lang/php-5.1 with" |
404 | eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"." |
| 410 | eerror "either the 'pdo' or the 'pdo-external'" |
|
|
| 411 | eerror "USE flags turned on." |
405 | eerror "pdo USE flags turned on." |
| 412 | eerror |
406 | eerror |
| 413 | die "PHP 5 not installed" |
407 | die "PHP 5 not installed" |
| 414 | fi |
408 | fi |
| 415 | |
409 | |
| 416 | # Was PHP5 compiled with internal PDO support? |
410 | # Was PHP5 compiled with internal PDO support? |
| 417 | if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then |
411 | if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then |
| 418 | return |
412 | return |
| 419 | fi |
413 | else |
| 420 | |
|
|
| 421 | # Ok, maybe PDO was built as an external extension? |
|
|
| 422 | if ( built_with_use =${PHP_PKG} pdo-external || phpconfutils_built_with_use =${PHP_PKG} pdo-external ) && has_version 'dev-php5/pecl-pdo' ; then |
|
|
| 423 | return |
|
|
| 424 | fi |
|
|
| 425 | |
|
|
| 426 | # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support |
|
|
| 427 | if has_version 'dev-php5/pecl-pdo' ; then |
|
|
| 428 | return |
|
|
| 429 | fi |
|
|
| 430 | |
|
|
| 431 | # If we get here, then we don't have PDO support |
|
|
| 432 | eerror |
414 | eerror |
| 433 | eerror "No PDO extension for PHP found." |
415 | eerror "No PDO extension for PHP found." |
| 434 | eerror "Please note that PDO only exists for PHP 5." |
416 | eerror "Please note that PDO only exists for PHP 5." |
| 435 | eerror "Please install a PDO extension for PHP 5," |
417 | eerror "Please install a PDO extension for PHP 5." |
| 436 | eerror "you must install >=dev-lang/php-5.1 with" |
418 | eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"." |
| 437 | eerror "either the 'pdo' or the 'pdo-external'" |
|
|
| 438 | eerror "USE flags turned on." |
|
|
| 439 | eerror |
419 | eerror |
| 440 | die "No PDO extension for PHP 5 found" |
420 | die "No PDO extension for PHP 5 found" |
|
|
421 | fi |
| 441 | } |
422 | } |
| 442 | |
423 | |
| 443 | # @FUNCTION: require_php_cli |
424 | # @FUNCTION: require_php_cli |
| 444 | # @DESCRIPTION: |
425 | # @DESCRIPTION: |
| 445 | # Determines which installed PHP version has the CLI SAPI enabled. |
426 | # Determines which installed PHP version has the CLI SAPI enabled. |
| … | |
… | |
| 456 | local PHP_PACKAGE_FOUND="" |
437 | local PHP_PACKAGE_FOUND="" |
| 457 | |
438 | |
| 458 | # Detect which PHP version we have installed |
439 | # Detect which PHP version we have installed |
| 459 | if has_version '=dev-lang/php-4*' ; then |
440 | if has_version '=dev-lang/php-4*' ; then |
| 460 | PHP_PACKAGE_FOUND="1" |
441 | PHP_PACKAGE_FOUND="1" |
| 461 | pkg="`best_version '=dev-lang/php-4*'`" |
442 | pkg="$(best_version '=dev-lang/php-4*')" |
| 462 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
443 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
| 463 | PHP_VERSION="4" |
444 | PHP_VERSION="4" |
| 464 | fi |
445 | fi |
| 465 | fi |
446 | fi |
| 466 | |
447 | |
| 467 | if has_version '=dev-lang/php-5*' ; then |
448 | if has_version '=dev-lang/php-5*' ; then |
| 468 | PHP_PACKAGE_FOUND="1" |
449 | PHP_PACKAGE_FOUND="1" |
| 469 | pkg="`best_version '=dev-lang/php-5*'`" |
450 | pkg="$(best_version '=dev-lang/php-5*')" |
| 470 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
451 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
| 471 | PHP_VERSION="5" |
452 | PHP_VERSION="5" |
| 472 | fi |
453 | fi |
| 473 | fi |
454 | fi |
| 474 | |
455 | |
| … | |
… | |
| 500 | local PHP_PACKAGE_FOUND="" |
481 | local PHP_PACKAGE_FOUND="" |
| 501 | |
482 | |
| 502 | # Detect which PHP version we have installed |
483 | # Detect which PHP version we have installed |
| 503 | if has_version '=dev-lang/php-4*' ; then |
484 | if has_version '=dev-lang/php-4*' ; then |
| 504 | PHP_PACKAGE_FOUND="1" |
485 | PHP_PACKAGE_FOUND="1" |
| 505 | pkg="`best_version '=dev-lang/php-4*'`" |
486 | pkg="$(best_version '=dev-lang/php-4*')" |
| 506 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
487 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
| 507 | PHP_VERSION="4" |
488 | PHP_VERSION="4" |
| 508 | fi |
489 | fi |
| 509 | fi |
490 | fi |
| 510 | |
491 | |
| 511 | if has_version '=dev-lang/php-5*' ; then |
492 | if has_version '=dev-lang/php-5*' ; then |
| 512 | PHP_PACKAGE_FOUND="1" |
493 | PHP_PACKAGE_FOUND="1" |
| 513 | pkg="`best_version '=dev-lang/php-5*'`" |
494 | pkg="$(best_version '=dev-lang/php-5*')" |
| 514 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
495 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
| 515 | PHP_VERSION="5" |
496 | PHP_VERSION="5" |
| 516 | fi |
497 | fi |
| 517 | fi |
498 | fi |
| 518 | |
499 | |
| … | |
… | |
| 632 | |
613 | |
| 633 | # @FUNCTION: dodoc-php |
614 | # @FUNCTION: dodoc-php |
| 634 | # @USAGE: <list of docs> |
615 | # @USAGE: <list of docs> |
| 635 | # @DESCRIPTION: |
616 | # @DESCRIPTION: |
| 636 | # Alternative to dodoc function for use in our PHP eclasses and ebuilds. |
617 | # Alternative to dodoc function for use in our PHP eclasses and ebuilds. |
| 637 | # Stored here because depend.php gets always sourced everywhere in the PHP |
618 | # Stored here because depend.php gets always sourced everywhere in the PHP |
| 638 | # ebuilds and eclasses. It simply is dodoc with a changed path to the docs. |
619 | # ebuilds and eclasses. It simply is dodoc with a changed path to the docs. |
| 639 | # NOTE: No support for docinto is provided! |
620 | # NOTE: No support for docinto is provided! |
| 640 | dodoc-php() { |
621 | dodoc-php() { |
| 641 | if [[ $# -lt 1 ]] ; then |
622 | if [[ $# -lt 1 ]] ; then |
| 642 | echo "$0: at least one argument needed" 1>&2 |
623 | echo "$0: at least one argument needed" 1>&2 |
| 643 | exit 1 |
624 | exit 1 |
| 644 | fi |
625 | fi |
| 645 | |
626 | |
| 646 | phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/" |
627 | phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/" |
| 647 | |
|
|
| 648 | if [[ ! -d "${phpdocdir}" ]] ; then |
|
|
| 649 | install -d "${phpdocdir}" |
|
|
| 650 | fi |
|
|
| 651 | |
628 | |
| 652 | for x in $@ ; do |
629 | for x in $@ ; do |
| 653 | if [[ -s "${x}" ]] ; then |
630 | if [[ -s "${x}" ]] ; then |
| 654 | install -m0644 "${x}" "${phpdocdir}" |
631 | insinto "${phpdocdir}" |
|
|
632 | doins "${x}" |
| 655 | gzip -f -9 "${phpdocdir}/${x##*/}" |
633 | gzip -f -9 "${D}/${phpdocdir}/${x##*/}" |
| 656 | elif [[ ! -e "${x}" ]] ; then |
634 | elif [[ ! -e "${x}" ]] ; then |
| 657 | echo "dodoc-php: ${x} does not exist" 1>&2 |
635 | echo "dodoc-php: ${x} does not exist" 1>&2 |
| 658 | fi |
636 | fi |
| 659 | done |
637 | done |
| 660 | } |
638 | } |
|
|
639 | |
|
|
640 | # @FUNCTION: dohtml-php |
|
|
641 | # @USAGE: <list of html docs> |
|
|
642 | # @DESCRIPTION: |
|
|
643 | # Alternative to dohtml function for use in our PHP eclasses and ebuilds. |
|
|
644 | # Stored here because depend.php gets always sourced everywhere in the PHP |
|
|
645 | # ebuilds and eclasses. It simply is dohtml with a changed path to the docs. |
|
|
646 | # NOTE: No support for [-a|-A|-p|-x] options is provided! |
|
|
647 | dohtml-php() { |
|
|
648 | if [[ $# -lt 1 ]] ; then |
|
|
649 | echo "$0: at least one argument needed" 1>&2 |
|
|
650 | exit 1 |
|
|
651 | fi |
|
|
652 | |
|
|
653 | phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html" |
|
|
654 | |
|
|
655 | for x in $@ ; do |
|
|
656 | if [[ -s "${x}" ]] ; then |
|
|
657 | insinto "${phphtmldir}" |
|
|
658 | doins "${x}" |
|
|
659 | elif [[ ! -e "${x}" ]] ; then |
|
|
660 | echo "dohtml-php: ${x} does not exist" 1>&2 |
|
|
661 | fi |
|
|
662 | done |
|
|
663 | } |