/[gentoo-x86]/eclass/depend.php.eclass
Gentoo

Diff of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.22 Revision 1.28
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.22 2007/12/24 12:29:36 armin76 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.28 2010/10/12 19:34:49 olemarkus 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 php5 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 php5 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
19inherit eutils phpconfutils 19inherit eutils phpconfutils
20
21# PHP4-only depend functions
22
23# @FUNCTION: need_php4_cli
24# @DESCRIPTION:
25# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP4
26# with cli SAPI.
27need_php4_cli() {
28 DEPEND="${DEPEND} =virtual/php-4*"
29 RDEPEND="${RDEPEND} =virtual/php-4*"
30 PHP_VERSION="4"
31}
32
33# @FUNCTION: need_php4_httpd
34# @DESCRIPTION:
35# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP4
36# with either cgi or apache2 SAPI.
37need_php4_httpd() {
38 DEPEND="${DEPEND} =virtual/httpd-php-4*"
39 RDEPEND="${RDEPEND} =virtual/httpd-php-4*"
40 PHP_VERSION="4"
41}
42
43# @FUNCTION: need_php4
44# @DESCRIPTION:
45# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP4
46# (with any SAPI).
47need_php4() {
48 DEPEND="${DEPEND} =dev-lang/php-4*"
49 RDEPEND="${RDEPEND} =dev-lang/php-4*"
50 PHP_VERSION="4"
51 PHP_SHARED_CAT="php4"
52}
53
54# common settings go in here
55uses_php4() {
56 # cache this
57 libdir=$(get_libdir)
58
59 PHPIZE="/usr/${libdir}/php4/bin/phpize"
60 PHPCONFIG="/usr/${libdir}/php4/bin/php-config"
61 PHPCLI="/usr/${libdir}/php4/bin/php"
62 PHPCGI="/usr/${libdir}/php4/bin/php-cgi"
63 PHP_PKG="$(best_version =dev-lang/php-4*)"
64 PHPPREFIX="/usr/${libdir}/php4"
65 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
66
67 einfo
68 einfo "Using ${PHP_PKG}"
69 einfo
70}
71 20
72# PHP5-only depend functions 21# PHP5-only depend functions
73 22
74# @FUNCTION: need_php5_cli 23# @FUNCTION: need_php5_cli
75# @DESCRIPTION: 24# @DESCRIPTION:
151} 100}
152 101
153# @FUNCTION: need_php_by_category 102# @FUNCTION: need_php_by_category
154# @DESCRIPTION: 103# @DESCRIPTION:
155# Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version 104# Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version
156# determined by ${CATEGORY} - any PHP version, PHP4 or PHP5 for dev-php, dev-php4 and 105# determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or
157# dev-php5, respectively. 106# dev-php5, respectively.
158need_php_by_category() { 107need_php_by_category() {
159 case "${CATEGORY}" in 108 case "${CATEGORY}" in
160 dev-php) need_php ;; 109 dev-php) need_php ;;
161 dev-php4) need_php4 ;;
162 dev-php5) need_php5 ;; 110 dev-php5) need_php5 ;;
163 *) die "Version of PHP required by packages in category ${CATEGORY} unknown" 111 *) die "Version of PHP required by packages in category ${CATEGORY} unknown"
164 esac 112 esac
165} 113}
166 114
167 115
168# @FUNCTION: has_php 116# @FUNCTION: has_php
169# @DESCRIPTION: 117# @DESCRIPTION:
170# Call this function from your pkg_setup, src_compile, src_install etc. if you 118# 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 119# need to know which PHP version is being used and where the PHP binaries/data
172# are installed. 120# are installed.
173has_php() { 121has_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 122 # Detect which PHP version we have installed
182 if has_version '=dev-lang/php-5*' ; then 123 if has_version '=dev-lang/php-5*' ; then
183 PHP_VERSION="5" 124 PHP_VERSION="5"
184 elif has_version '=dev-lang/php-4*' ; then
185 PHP_VERSION="4"
186 else 125 else
187 die "Unable to find an installed dev-lang/php package" 126 die "Unable to find an installed dev-lang/php package"
188 fi
189 fi 127 fi
190 128
191 # If we get here, then PHP_VERSION tells us which version of PHP we 129 # If we get here, then PHP_VERSION tells us which version of PHP we
192 # want to use 130 # want to use
193 uses_php${PHP_VERSION} 131 uses_php${PHP_VERSION}
203# of them is available. 141# of them is available.
204# 142#
205# Unfortunately, if you want to be really sure that the required SAPI is 143# 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 144# 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 145# 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 146# depend on USE flags being enabled. The above described need_php[45]_cli
209# and need_php[45]_httpd functions cannot guarantee these requirements. 147# and need_php[45]_httpd functions cannot guarantee these requirements.
210# See Bug 2272 for details. 148# See Bug 2272 for details.
211require_php_sapi_from() { 149require_php_sapi_from() {
212 has_php 150 has_php
213 151
245 183
246# @VARIABLE: PHPCHECKNODIE 184# @VARIABLE: PHPCHECKNODIE
247# @DESCRIPTION: 185# @DESCRIPTION:
248# You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple 186# 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. 187# 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 188# This is useful in cases when certain PHP features are only required if specific
251# USE flag(s) are enabled for that ebuild. 189# USE flag(s) are enabled for that ebuild.
252# @CODE 190# @CODE
253# Example: 191# Example:
254# 192#
255# local flags="pcre session snmp sockets wddx" 193# local flags="pcre session snmp sockets wddx"
267 local x 205 local x
268 206
269 einfo "Checking for required PHP feature(s) ..." 207 einfo "Checking for required PHP feature(s) ..."
270 208
271 for x in $@ ; do 209 for x in $@ ; do
210 case $x in
211 pcre|spl|reflection|mhash)
212 eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
213 eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break"
214 eqawarn "if you check the USE flags against PHP 5.3 ebuilds."
215 eqawarn "Please use USE dependencies from EAPI 2 instead"
216 ;;
217 esac
218
272 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then 219 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
273 einfo " Discovered missing USE flag: ${x}" 220 einfo " Discovered missing USE flag: ${x}"
274 missing_use="${missing_use} ${x}" 221 missing_use="${missing_use} ${x}"
275 fi 222 fi
276 done 223 done
401# pdo-external use flag and pecl-pdo-* ebuilds were removed. 348# pdo-external use flag and pecl-pdo-* ebuilds were removed.
402# You should use require_php_with_use pdo instead now. 349# You should use require_php_with_use pdo instead now.
403# @RETURN: die if feature is missing 350# @RETURN: die if feature is missing
404require_pdo() { 351require_pdo() {
405 has_php 352 has_php
406
407 # Do we have PHP5 installed?
408 if [[ "${PHP_VERSION}" == "4" ]] ; then
409 eerror
410 eerror "This package requires PDO."
411 eerror "PDO is only available for PHP 5."
412 eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"."
413 eerror "pdo USE flags turned on."
414 eerror
415 die "PHP 5 not installed"
416 fi
417 353
418 # Was PHP5 compiled with internal PDO support? 354 # Was PHP5 compiled with internal PDO support?
419 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then 355 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then
420 return 356 return
421 else 357 else
442 return 378 return
443 fi 379 fi
444 380
445 local PHP_PACKAGE_FOUND="" 381 local PHP_PACKAGE_FOUND=""
446 382
447 # Detect which PHP version we have installed
448 if has_version '=dev-lang/php-4*' ; then
449 PHP_PACKAGE_FOUND="1"
450 pkg="$(best_version '=dev-lang/php-4*')"
451 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
452 PHP_VERSION="4"
453 fi
454 fi
455
456 if has_version '=dev-lang/php-5*' ; then 383 if has_version '=dev-lang/php-5*' ; then
457 PHP_PACKAGE_FOUND="1" 384 PHP_PACKAGE_FOUND="1"
458 pkg="$(best_version '=dev-lang/php-5*')" 385 pkg="$(best_version '=dev-lang/php-5*')"
459 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then 386 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
460 PHP_VERSION="5" 387 PHP_VERSION="5"
486 return 413 return
487 fi 414 fi
488 415
489 local PHP_PACKAGE_FOUND="" 416 local PHP_PACKAGE_FOUND=""
490 417
491 # Detect which PHP version we have installed
492 if has_version '=dev-lang/php-4*' ; then
493 PHP_PACKAGE_FOUND="1"
494 pkg="$(best_version '=dev-lang/php-4*')"
495 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
496 PHP_VERSION="4"
497 fi
498 fi
499
500 if has_version '=dev-lang/php-5*' ; then 418 if has_version '=dev-lang/php-5*' ; then
501 PHP_PACKAGE_FOUND="1" 419 PHP_PACKAGE_FOUND="1"
502 pkg="$(best_version '=dev-lang/php-5*')" 420 pkg="$(best_version '=dev-lang/php-5*')"
503 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then 421 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
504 PHP_VERSION="5" 422 PHP_VERSION="5"
528 # Has our PHP been built with SQLite support? 446 # Has our PHP been built with SQLite support?
529 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then 447 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then
530 return 448 return
531 fi 449 fi
532 450
533 # Do we have pecl-sqlite installed for PHP4?
534 if [[ "${PHP_VERSION}" == "4" ]] ; then
535 if has_version 'dev-php4/pecl-sqlite' ; then
536 return
537 fi
538 fi
539
540 # If we get here, then we don't have any SQLite support for PHP installed 451 # If we get here, then we don't have any SQLite support for PHP installed
541 eerror 452 eerror
542 eerror "No SQLite extension for PHP found." 453 eerror "No SQLite extension for PHP found."
543 eerror "Please install an SQLite extension for PHP," 454 eerror "Please install an SQLite extension for PHP,"
544 eerror "this is done best by simply adding the" 455 eerror "this is done best by simply adding the"
621 532
622# @FUNCTION: dodoc-php 533# @FUNCTION: dodoc-php
623# @USAGE: <list of docs> 534# @USAGE: <list of docs>
624# @DESCRIPTION: 535# @DESCRIPTION:
625# Alternative to dodoc function for use in our PHP eclasses and ebuilds. 536# Alternative to dodoc function for use in our PHP eclasses and ebuilds.
626# Stored here because depend.php gets always sourced everywhere in the PHP 537# Stored here because depend.php gets always sourced everywhere in the PHP
627# ebuilds and eclasses. It simply is dodoc with a changed path to the docs. 538# ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
628# NOTE: No support for docinto is provided! 539# NOTE: No support for docinto is provided!
629dodoc-php() { 540dodoc-php() {
630if [[ $# -lt 1 ]] ; then 541if [[ $# -lt 1 ]] ; then
631 echo "$0: at least one argument needed" 1>&2 542 echo "$0: at least one argument needed" 1>&2
632 exit 1 543 exit 1
633fi 544fi
634 545
635phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/" 546phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
636
637if [[ ! -d "${phpdocdir}" ]] ; then
638 install -d "${phpdocdir}"
639fi
640 547
641for x in $@ ; do 548for x in $@ ; do
642 if [[ -s "${x}" ]] ; then 549 if [[ -s "${x}" ]] ; then
643 install -m0644 "${x}" "${phpdocdir}" 550 insinto "${phpdocdir}"
551 doins "${x}"
644 gzip -f -9 "${phpdocdir}/${x##*/}" 552 gzip -f -9 "${D}/${phpdocdir}/${x##*/}"
645 elif [[ ! -e "${x}" ]] ; then 553 elif [[ ! -e "${x}" ]] ; then
646 echo "dodoc-php: ${x} does not exist" 1>&2 554 echo "dodoc-php: ${x} does not exist" 1>&2
647 fi 555 fi
648done 556done
649} 557}
558
559# @FUNCTION: dohtml-php
560# @USAGE: <list of html docs>
561# @DESCRIPTION:
562# Alternative to dohtml function for use in our PHP eclasses and ebuilds.
563# Stored here because depend.php gets always sourced everywhere in the PHP
564# ebuilds and eclasses. It simply is dohtml with a changed path to the docs.
565# NOTE: No support for [-a|-A|-p|-x] options is provided!
566dohtml-php() {
567if [[ $# -lt 1 ]] ; then
568 echo "$0: at least one argument needed" 1>&2
569 exit 1
570fi
571
572phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
573
574for x in $@ ; do
575 if [[ -s "${x}" ]] ; then
576 insinto "${phphtmldir}"
577 doins "${x}"
578 elif [[ ! -e "${x}" ]] ; then
579 echo "dohtml-php: ${x} does not exist" 1>&2
580 fi
581done
582}

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20