diff options
author | Luca Longinotti <chtekk@gentoo.org> | 2006-03-24 23:05:49 +0000 |
---|---|---|
committer | Luca Longinotti <chtekk@gentoo.org> | 2006-03-24 23:05:49 +0000 |
commit | 7d2a2d5e58b933bfbbdf1584839910f8baff53ac (patch) | |
tree | fe8bcba0d64f586bc76d33384aae4e2c1a9042c6 /eclass/depend.php.eclass | |
parent | Respect user-defined LDFLAGS. (diff) | |
download | gentoo-2-7d2a2d5e58b933bfbbdf1584839910f8baff53ac.tar.gz gentoo-2-7d2a2d5e58b933bfbbdf1584839910f8baff53ac.tar.bz2 gentoo-2-7d2a2d5e58b933bfbbdf1584839910f8baff53ac.zip |
Use phpconfutils, fix bug #120088, fix bug #122379.
Diffstat (limited to 'eclass/depend.php.eclass')
-rw-r--r-- | eclass/depend.php.eclass | 353 |
1 files changed, 184 insertions, 169 deletions
diff --git a/eclass/depend.php.eclass b/eclass/depend.php.eclass index 3f1796f7e130..1a8619132229 100644 --- a/eclass/depend.php.eclass +++ b/eclass/depend.php.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.11 2006/01/21 11:48:29 chtekk Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.12 2006/03/24 23:05:47 chtekk Exp $ # # ======================================================================== # @@ -17,34 +17,30 @@ # # ======================================================================== -inherit eutils +inherit eutils phpconfutils # PHP4-only depend functions -need_php4_cli() -{ +need_php4_cli() { DEPEND="${DEPEND} =virtual/php-4*" RDEPEND="${RDEPEND} =virtual/php-4*" - PHP_VERSION=4 + PHP_VERSION="4" } -need_php4_httpd() -{ +need_php4_httpd() { DEPEND="${DEPEND} =virtual/httpd-php-4*" RDEPEND="${RDEPEND} =virtual/httpd-php-4*" - PHP_VERSION=4 + PHP_VERSION="4" } -need_php4() -{ +need_php4() { DEPEND="${DEPEND} =dev-lang/php-4*" RDEPEND="${RDEPEND} =dev-lang/php-4*" - PHP_VERSION=4 + PHP_VERSION="4" PHP_SHARED_CAT="php4" } # common settings go in here -uses_php4() -{ +uses_php4() { # cache this libdir=$(get_libdir) @@ -61,31 +57,27 @@ uses_php4() } # PHP5-only depend functions -need_php5_cli() -{ +need_php5_cli() { DEPEND="${DEPEND} =virtual/php-5*" RDEPEND="${RDEPEND} =virtual/php-5*" - PHP_VERSION=5 + PHP_VERSION="5" } -need_php5_httpd() -{ +need_php5_httpd() { DEPEND="${DEPEND} =virtual/httpd-php-5*" RDEPEND="${RDEPEND} =virtual/httpd-php-5*" - PHP_VERSION=5 + PHP_VERSION="5" } -need_php5() -{ +need_php5() { DEPEND="${DEPEND} =dev-lang/php-5*" RDEPEND="${RDEPEND} =dev-lang/php-5*" - PHP_VERSION=5 + PHP_VERSION="5" PHP_SHARED_CAT="php5" } # common settings go in here -uses_php5() -{ +uses_php5() { # cache this libdir=$(get_libdir) @@ -102,27 +94,23 @@ uses_php5() } # general PHP depend functions -need_php_cli() -{ +need_php_cli() { DEPEND="${DEPEND} virtual/php" RDEPEND="${RDEPEND} virtual/php" } -need_php_httpd() -{ +need_php_httpd() { DEPEND="${DEPEND} virtual/httpd-php" RDEPEND="${RDEPEND} virtual/httpd-php" } -need_php() -{ +need_php() { DEPEND="${DEPEND} dev-lang/php" RDEPEND="${RDEPEND} dev-lang/php" PHP_SHARED_CAT="php" } -need_php_by_category() -{ +need_php_by_category() { case "${CATEGORY}" in dev-php) need_php ;; dev-php4) need_php4 ;; @@ -131,22 +119,44 @@ need_php_by_category() esac } -# call this function from pkg_setup if your PHP extension only works with +# Call this function from your pkg_setup, src_compile and src_install methods +# if you need to know where the PHP binaries are installed and their data + +has_php() { + # If PHP_PKG is already set, then we have remembered our PHP settings + # from last time + if [[ -n ${PHP_PKG} ]] ; then + return + fi + + if [[ -z ${PHP_VERSION} ]] ; then + # Detect which PHP version we have installed + if has_version '=dev-lang/php-5*' ; then + PHP_VERSION="5" + elif has_version '=dev-lang/php-4*' ; then + PHP_VERSION="4" + else + die "Unable to find an installed dev-lang/php package" + fi + fi + + # If we get here, then PHP_VERSION tells us which version of PHP we + # want to use + uses_php${PHP_VERSION} +} + +# Call this function from pkg_setup if your package only works with # specific SAPIs # -# this function will disappear when USE-based deps are supported by -# Portage +# $1 ... a list of PHP SAPI USE flags (cli, cgi, apache, apache2) # -# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2) -# -# returns if any one of the listed SAPIs has been installed -# dies if none of the listed SAPIs has been installed +# Returns if any one of the listed SAPIs have been installed +# Dies if none of the listed SAPIs have been installed -require_php_sapi_from() -{ +require_php_sapi_from() { has_php - local has_sapi=0 + local has_sapi="0" local x einfo "Checking for compatible SAPI(s)" @@ -154,11 +164,11 @@ require_php_sapi_from() for x in $@ ; do if built_with_use =${PHP_PKG} ${x} ; then einfo " Discovered compatible SAPI ${x}" - has_sapi=1 + has_sapi="1" fi done - if [[ ${has_sapi} == 1 ]]; then + if [[ "${has_sapi}" == "1" ]] ; then return fi @@ -168,22 +178,18 @@ require_php_sapi_from() eerror eerror " $@" eerror - die "Re-install ${PHP_PKG}" + die "No compatible PHP SAPIs found" } -# call this function from pkg_setup if your package requires PHP compiled +# Call this function from pkg_setup if your package requires PHP compiled # with specific USE flags # -# this function will disappear when USE-based deps are supported by -# Portage -# # $1 ... a list of USE flags # -# returns if all of the listed USE flags are set -# dies if any of the listed USE flags are not set +# Returns if all of the listed USE flags are enabled +# Dies if any of the listed USE flags are disabled -require_php_with_use() -{ +require_php_with_use() { has_php local missing_use="" @@ -192,7 +198,7 @@ require_php_with_use() einfo "Checking for required PHP feature(s):" for x in $@ ; do - if ! built_with_use =${PHP_PKG} ${x} ; then + if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then einfo " Discovered missing USE flag ${x}" missing_use="${missing_use} ${x}" fi @@ -208,48 +214,56 @@ require_php_with_use() eerror eerror " $@" eerror - die "Re-install ${PHP_PKG}" + die "Missing PHP USE flags found" } -# call this function from your pkg_setup, src_compile & src_install methods -# if you need to know where the PHP binaries are installed and their data +# Call this function from pkg_setup if your package requires PHP compiled +# with any of specified USE flags +# +# $1 ... a list of USE flags +# +# Returns if any of the listed USE flags are enabled +# Dies if all of the listed USE flags are disabled -has_php() -{ - # if PHP_PKG is set, then we have remembered our PHP settings - # from last time +require_php_with_any_use() { + has_php - if [[ -n ${PHP_PKG} ]] ; then - return - fi + local missing_use="" + local x - if [[ -z ${PHP_VERSION} ]] ; then - # detect which PHP version installed - if has_version '=dev-lang/php-5*' ; then - PHP_VERSION=5 - elif has_version '=dev-lang/php-4*' ; then - PHP_VERSION=4 + einfo "Checking for required PHP feature(s):" + + for x in $@ ; do + if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then + einfo " USE flag ${x} is enabled, ok ..." + return else - die "Unable to find an installed dev-lang/php package" + missing_use="${missing_use} ${x}" fi - fi + done - # if we get here, then PHP_VERSION tells us which version of PHP we - # want to use + if [[ -z ${missing_use} ]] ; then + return + fi - uses_php${PHP_VERSION} + eerror + eerror "${PHP_PKG} needs to be re-installed with any of the following" + eerror "USE flags enabled:" + eerror + eerror " $@" + eerror + die "Missing PHP USE flags found" } # ======================================================================== # has_*() functions # -# these functions return 0 if the condition is satisfied, or 1 otherwise +# These functions return 0 if the condition is satisfied, 1 otherwise # ======================================================================== -# check if our PHP was compiled with ZTS (Zend Thread Safety) +# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled -has_zts() -{ +has_zts() { has_php if built_with_use =${PHP_PKG} apache2 threads ; then @@ -259,10 +273,9 @@ has_zts() return 1 } -# check if our PHP was built with Hardened-PHP active +# Check if our PHP was built with Hardened-PHP enabled -has_hardenedphp() -{ +has_hardenedphp() { has_php if built_with_use =${PHP_PKG} hardenedphp ; then @@ -272,21 +285,31 @@ has_hardenedphp() return 1 } +# Check if our PHP was built with debug support enabled + +has_debug() { + has_php + + if built_with_use =${PHP_PKG} debug ; then + return 0 + fi + + return 1 +} + # ======================================================================== # require_*() functions # -# These functions die() if PHP was built without the required USE flag(s) +# These functions die() if PHP was built without the required features # ======================================================================== -# require a PHP built with PDO support for PHP5 +# Require a PHP built with PDO support (PHP5 only) -require_pdo() -{ +require_pdo() { has_php - # do we have php5 installed? - - if [[ ${PHP_VERSION} == 4 ]] ; then + # Do we have PHP5 installed? + if [[ "${PHP_VERSION}" == "4" ]] ; then eerror eerror "This package requires PDO." eerror "PDO is only available for PHP 5." @@ -299,26 +322,22 @@ require_pdo() die "PHP 5 not installed" fi - # was php5 compiled w/ pdo support? - + # Was PHP5 compiled with internal PDO support? if built_with_use =${PHP_PKG} pdo ; then return fi - # ok, maybe PDO was built as an external extension? - - if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then + # Ok, maybe PDO was built as an external extension? + if built_with_use =${PHP_PKG} pdo-external && has_version 'dev-php5/pecl-pdo' ; then return fi - # ok, as last resort, it suffices that pecl-pdo was installed to have PDO support - - if has_version dev-php5/pecl-pdo ; then + # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support + if has_version 'dev-php5/pecl-pdo' ; then return fi - # if we get here, then we have no PDO support - + # If we get here, then we have no PDO support eerror eerror "No PDO extension for PHP found." eerror "Please note that PDO only exists for PHP 5." @@ -329,36 +348,36 @@ require_pdo() eerror "the 'pdo' or the 'pdo-external' USE flags" eerror "turned on." eerror - die "No PDO extension found for PHP 5" + die "No PDO extension for PHP 5 found" } -# determines which installed PHP version has the CLI sapi -# useful for PEAR eclass, or anything which needs to run PHP -# scripts depending on the cli sapi +# Determines which installed PHP version has the CLI SAPI enabled, +# useful for PEAR stuff, or anything which needs to run PHP +# scripts depending on the CLI SAPI -require_php_cli() -{ - # if PHP_PKG is set, then we have remembered our PHP settings +require_php_cli() { + # If PHP_PKG is set, then we have remembered our PHP settings # from last time - if [[ -n ${PHP_PKG} ]] ; then return fi - # detect which PHP version installed + local PHP_PACKAGE_FOUND="" + + # Detect which PHP version we have installed if has_version '=dev-lang/php-4*' ; then - PHP_PACKAGE_FOUND=1 + PHP_PACKAGE_FOUND="1" pkg="`best_version '=dev-lang/php-4*'`" if built_with_use =${pkg} cli ; then - PHP_VERSION=4 + PHP_VERSION="4" fi fi if has_version '=dev-lang/php-5*' ; then - PHP_PACKAGE_FOUND=1 + PHP_PACKAGE_FOUND="1" pkg="`best_version '=dev-lang/php-5*'`" if built_with_use =${pkg} cli ; then - PHP_VERSION=5 + PHP_VERSION="5" fi fi @@ -370,39 +389,38 @@ require_php_cli() die "No PHP CLI installed" fi - # if we get here, then PHP_VERSION tells us which version of PHP we + # If we get here, then PHP_VERSION tells us which version of PHP we # want to use - uses_php${PHP_VERSION} } -# determines which installed PHP version has the CGI sapi +# Determines which installed PHP version has the CGI SAPI enabled, # useful for anything which needs to run PHP scripts -# depending on the cgi sapi +# depending on the CGI SAPI -require_php_cgi() -{ - # if PHP_PKG is set, then we have remembered our PHP settings +require_php_cgi() { + # If PHP_PKG is set, then we have remembered our PHP settings # from last time - if [[ -n ${PHP_PKG} ]] ; then return fi - # detect which PHP version installed + local PHP_PACKAGE_FOUND="" + + # Detect which PHP version we have installed if has_version '=dev-lang/php-4*' ; then - PHP_PACKAGE_FOUND=1 + PHP_PACKAGE_FOUND="1" pkg="`best_version '=dev-lang/php-4*'`" if built_with_use =${pkg} cgi ; then - PHP_VERSION=4 + PHP_VERSION="4" fi fi if has_version '=dev-lang/php-5*' ; then - PHP_PACKAGE_FOUND=1 + PHP_PACKAGE_FOUND="1" pkg="`best_version '=dev-lang/php-5*'`" if built_with_use =${pkg} cgi ; then - PHP_VERSION=5 + PHP_VERSION="5" fi fi @@ -414,63 +432,54 @@ require_php_cgi() die "No PHP CGI installed" fi - # if we get here, then PHP_VERSION tells us which version of PHP we + # If we get here, then PHP_VERSION tells us which version of PHP we # want to use - uses_php${PHP_VERSION} } -# require a PHP built with sqlite support +# Require a PHP built with SQLite support -require_sqlite() -{ +require_sqlite() { has_php - # has our PHP been built with sqlite? - - if built_with_use =${PHP_PKG} sqlite ; then + # Has our PHP been built with SQLite support? + if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then return fi - # do we have pecl-sqlite installed for PHP 4? - - if [[ ${PHP_VERSION} == 4 ]] ; then - if has_version dev-php4/pecl-sqlite ; then + # Do we have pecl-sqlite installed for PHP4? + if [[ "${PHP_VERSION}" == "4" ]] ; then + if has_version 'dev-php4/pecl-sqlite' ; then return fi fi - # if we get here, then we don't have any sqlite support for PHP installed - + # If we get here, then we don't have any SQLite support for PHP installed eerror - eerror "No sqlite extension for PHP found." - eerror "Please install an sqlite extension for PHP," + eerror "No SQLite extension for PHP found." + eerror "Please install an SQLite extension for PHP," eerror "this is done best by simply adding the" eerror "'sqlite' USE flag when emerging dev-lang/php." eerror - die "No sqlite extension for PHP found" + die "No SQLite extension for PHP found" } -# require a PHP built with GD support +# Require a PHP built with GD support -require_gd() -{ +require_gd() { has_php - # do we have the internal GD support installed? - - if built_with_use =${PHP_PKG} gd ; then + # Do we have the internal GD support installed? + if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then return fi - # ok, maybe GD was built using the external support? - - if built_with_use =${PHP_PKG} gd-external ; then + # Ok, maybe GD was built using the external library support? + if built_with_use =${PHP_PKG} gd-external || phpconfutils_built_with_use =${PHP_PKG} gd-external ; then return fi - # if we get here, then we have no GD support - + # If we get here, then we have no GD support eerror eerror "No GD support for PHP found." eerror "Please install the GD support for PHP," @@ -487,12 +496,14 @@ require_gd() # These functions provide miscellaneous checks and functionality. # ======================================================================== -# executes some checks needed when installing a binary PHP extension +# Executes some checks needed when installing a binary PHP extension php_binary_extension() { has_php - # binary extensions do not support the change of PHP + local PUSE_ENABLED="" + + # Binary extensions do not support the change of PHP # API version, so they can't be installed when USE flags # are enabled wich change the PHP API version @@ -503,7 +514,7 @@ php_binary_extension() { eerror "Please reemerge dev-lang/php with the" eerror "'hardenedphp' USE flag turned off." eerror - die "'hardenedphp' USE flag turned on" + PUSE_ENABLED="1" fi if built_with_use =${PHP_PKG} debug ; then @@ -513,34 +524,38 @@ php_binary_extension() { eerror "Please reemerge dev-lang/php with the" eerror "'debug' USE flag turned off." eerror - die "'debug' USE flag turned on" + PUSE_ENABLED="1" + fi + + if [[ -n ${PUSE_ENABLED} ]] ; then + die "'hardenedphp' and/or 'debug' USE flags turned on" fi } -# alternative to dodoc for use in our php eclasses and ebuilds -# stored here because depend.php gets always sourced everywhere -# in the PHP ebuilds and eclasses -# it simply is dodoc with a changed path to the docs -# no support for docinto is given! +# Alternative to dodoc function for use in our PHP eclasses and +# ebuilds. +# Stored here because depend.php gets always sourced everywhere +# in the PHP ebuilds and eclasses. +# It simply is dodoc with a changed path to the docs. +# NOTE: no support for docinto is given! -dodoc-php() -{ -if [ $# -lt 1 ] ; then +dodoc-php() { +if [[ $# -lt 1 ]] ; then echo "$0: at least one argument needed" 1>&2 exit 1 fi phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/" -if [ ! -d "${phpdocdir}" ] ; then +if [[ ! -d "${phpdocdir}" ]] ; then install -d "${phpdocdir}" fi -for x in "$@" ; do - if [ -s "${x}" ] ; then +for x in $@ ; do + if [[ -s "${x}" ]] ; then install -m0644 "${x}" "${phpdocdir}" gzip -f -9 "${phpdocdir}/${x##*/}" - elif [ ! -e "${x}" ] ; then + elif [[ ! -e "${x}" ]] ; then echo "dodoc-php: ${x} does not exist" 1>&2 fi done |