/[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.17 Revision 1.32
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2012 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.17 2007/02/02 19:09:33 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.32 2012/06/02 19:16:31 zmedico Exp $
4# 4
5# ========================================================================
6#
7# depend.php.eclass 5# @ECLASS: depend.php.eclass
8# functions to allow ebuilds to depend on php4 and/or php5 6# @MAINTAINER:
9# 7# Gentoo PHP team <php-bugs@gentoo.org>
10# Author: Stuart Herbert 8# @AUTHOR:
11# <stuart@gentoo.org> 9# Author: Stuart Herbert <stuart@gentoo.org>
12# 10# Author: Luca Longinotti <chtekk@gentoo.org>
13# Author: Luca Longinotti 11# Author: Jakub Moc <jakub@gentoo.org> (documentation)
14# <chtekk@gentoo.org> 12# @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features.
15# 13# @DESCRIPTION:
16# Maintained by the PHP Herd <php-bugs@gentoo.org> 14# This eclass provides functions that allow ebuilds to depend on php5 and check
17# 15# for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install
18# ======================================================================== 16# documentation for PHP packages to php-specific location.
19 17
20inherit eutils phpconfutils 18inherit eutils multilib phpconfutils
21
22# PHP4-only depend functions
23need_php4_cli() {
24 DEPEND="${DEPEND} =virtual/php-4*"
25 RDEPEND="${RDEPEND} =virtual/php-4*"
26 PHP_VERSION="4"
27}
28
29need_php4_httpd() {
30 DEPEND="${DEPEND} =virtual/httpd-php-4*"
31 RDEPEND="${RDEPEND} =virtual/httpd-php-4*"
32 PHP_VERSION="4"
33}
34
35need_php4() {
36 DEPEND="${DEPEND} =dev-lang/php-4*"
37 RDEPEND="${RDEPEND} =dev-lang/php-4*"
38 PHP_VERSION="4"
39 PHP_SHARED_CAT="php4"
40}
41
42# common settings go in here
43uses_php4() {
44 # cache this
45 libdir=$(get_libdir)
46
47 PHPIZE="/usr/${libdir}/php4/bin/phpize"
48 PHPCONFIG="/usr/${libdir}/php4/bin/php-config"
49 PHPCLI="/usr/${libdir}/php4/bin/php"
50 PHPCGI="/usr/${libdir}/php4/bin/php-cgi"
51 PHP_PKG="`best_version =dev-lang/php-4*`"
52 PHPPREFIX="/usr/${libdir}/php4"
53 EXT_DIR="`${PHPCONFIG} --extension-dir 2>/dev/null`"
54
55 einfo
56 einfo "Using ${PHP_PKG}"
57 einfo
58}
59 19
60# PHP5-only depend functions 20# PHP5-only depend functions
21
22# @FUNCTION: need_php5_cli
23# @DESCRIPTION:
24# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
25# with cli SAPI.
61need_php5_cli() { 26need_php5_cli() {
62 DEPEND="${DEPEND} =virtual/php-5*" 27 DEPEND="${DEPEND} =dev-lang/php-5*"
63 RDEPEND="${RDEPEND} =virtual/php-5*" 28 RDEPEND="${RDEPEND} =dev-lang/php-5*"
64 PHP_VERSION="5" 29 PHP_VERSION="5"
65} 30}
66 31
32# @FUNCTION: need_php5_httpd
33# @DESCRIPTION:
34# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
35# with either cgi or apache2 SAPI.
67need_php5_httpd() { 36need_php5_httpd() {
68 DEPEND="${DEPEND} =virtual/httpd-php-5*" 37 DEPEND="${DEPEND} =virtual/httpd-php-5*"
69 RDEPEND="${RDEPEND} =virtual/httpd-php-5*" 38 RDEPEND="${RDEPEND} =virtual/httpd-php-5*"
70 PHP_VERSION="5" 39 PHP_VERSION="5"
71} 40}
72 41
42# @FUNCTION: need_php5
43# @DESCRIPTION:
44# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
45# (with any SAPI).
73need_php5() { 46need_php5() {
74 DEPEND="${DEPEND} =dev-lang/php-5*" 47 DEPEND="${DEPEND} =dev-lang/php-5*"
75 RDEPEND="${RDEPEND} =dev-lang/php-5*" 48 RDEPEND="${RDEPEND} =dev-lang/php-5*"
76 PHP_VERSION="5" 49 PHP_VERSION="5"
77 PHP_SHARED_CAT="php5" 50 PHP_SHARED_CAT="php5"
84 57
85 PHPIZE="/usr/${libdir}/php5/bin/phpize" 58 PHPIZE="/usr/${libdir}/php5/bin/phpize"
86 PHPCONFIG="/usr/${libdir}/php5/bin/php-config" 59 PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
87 PHPCLI="/usr/${libdir}/php5/bin/php" 60 PHPCLI="/usr/${libdir}/php5/bin/php"
88 PHPCGI="/usr/${libdir}/php5/bin/php-cgi" 61 PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
89 PHP_PKG="`best_version =dev-lang/php-5*`" 62 PHP_PKG="$(best_version =dev-lang/php-5*)"
90 PHPPREFIX="/usr/${libdir}/php5" 63 PHPPREFIX="/usr/${libdir}/php5"
91 EXT_DIR="`${PHPCONFIG} --extension-dir 2>/dev/null`" 64 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
92 65
93 einfo 66 einfo
94 einfo "Using ${PHP_PKG}" 67 einfo "Using ${PHP_PKG}"
95 einfo 68 einfo
96} 69}
97 70
98# general PHP depend functions 71# general PHP depend functions
72
73# @FUNCTION: need_php_cli
74# @DESCRIPTION:
75# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
76# (any version) with cli SAPI.
99need_php_cli() { 77need_php_cli() {
100 DEPEND="${DEPEND} virtual/php" 78 DEPEND="${DEPEND} dev-lang/php"
101 RDEPEND="${RDEPEND} virtual/php" 79 RDEPEND="${RDEPEND} dev-lang/php"
102} 80}
103 81
82# @FUNCTION: need_php_httpd
83# @DESCRIPTION:
84# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
85# (any version) with either cgi or apache2 SAPI.
104need_php_httpd() { 86need_php_httpd() {
105 DEPEND="${DEPEND} virtual/httpd-php" 87 DEPEND="${DEPEND} virtual/httpd-php"
106 RDEPEND="${RDEPEND} virtual/httpd-php" 88 RDEPEND="${RDEPEND} virtual/httpd-php"
107} 89}
108 90
91# @FUNCTION: need_php
92# @DESCRIPTION:
93# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
94# (any version with any SAPI).
109need_php() { 95need_php() {
110 DEPEND="${DEPEND} dev-lang/php" 96 DEPEND="${DEPEND} dev-lang/php"
111 RDEPEND="${RDEPEND} dev-lang/php" 97 RDEPEND="${RDEPEND} dev-lang/php"
112 PHP_SHARED_CAT="php" 98 PHP_SHARED_CAT="php"
113} 99}
114 100
101# @FUNCTION: need_php_by_category
102# @DESCRIPTION:
103# Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version
104# determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or
105# dev-php5, respectively.
115need_php_by_category() { 106need_php_by_category() {
116 case "${CATEGORY}" in 107 case "${CATEGORY}" in
117 dev-php) need_php ;; 108 dev-php) need_php ;;
118 dev-php4) need_php4 ;; 109 *) die "Version of PHP required by packages in category ${CATEGORY} unknown"
119 dev-php5) need_php5 ;;
120 *) die "I don't know which version of PHP packages in ${CATEGORY} require"
121 esac 110 esac
122} 111}
123 112
113
114# @FUNCTION: has_php
115# @DESCRIPTION:
124# Call this function from your pkg_setup, src_compile and src_install methods 116# Call this function from your pkg_setup, src_compile, src_install etc. if you
125# if you need to know where the PHP binaries are installed and their data 117# need to know which PHP version is being used and where the PHP binaries/data
126 118# are installed.
127has_php() { 119has_php() {
128 # If PHP_PKG is already set, then we have remembered our PHP settings
129 # from last time
130 if [[ -n ${PHP_PKG} ]] ; then
131 return
132 fi
133
134 if [[ -z ${PHP_VERSION} ]] ; then
135 # Detect which PHP version we have installed 120 # Detect which PHP version we have installed
136 if has_version '=dev-lang/php-5*' ; then 121 if has_version '=dev-lang/php-5*' ; then
137 PHP_VERSION="5" 122 PHP_VERSION="5"
138 elif has_version '=dev-lang/php-4*' ; then
139 PHP_VERSION="4"
140 else 123 else
141 die "Unable to find an installed dev-lang/php package" 124 die "Unable to find an installed dev-lang/php package"
142 fi
143 fi 125 fi
144 126
145 # If we get here, then PHP_VERSION tells us which version of PHP we 127 # If we get here, then PHP_VERSION tells us which version of PHP we
146 # want to use 128 # want to use
147 uses_php${PHP_VERSION} 129 uses_php${PHP_VERSION}
148} 130}
149 131
132# @FUNCTION: require_php_sapi_from
133# @USAGE: <list of SAPIs>
134# @DESCRIPTION:
150# Call this function from pkg_setup if your package only works with 135# Call this function from pkg_setup if your package only works with
151# specific SAPIs 136# specific SAPI(s) and specify a list of PHP SAPI USE flags that are
137# required (one or more from cli, cgi, apache2) as arguments.
138# Returns if any of the listed SAPIs have been installed, dies if none
139# of them is available.
152# 140#
153# $1 ... a list of PHP SAPI USE flags (cli, cgi, apache, apache2) 141# Unfortunately, if you want to be really sure that the required SAPI is
154# 142# provided by PHP, you will have to use this function or similar ones (like
155# Returns if any one of the listed SAPIs have been installed 143# require_php_cli or require_php_cgi) in pkg_setup until we are able to
156# Dies if none of the listed SAPIs have been installed 144# depend on USE flags being enabled. The above described need_php[45]_cli
157 145# and need_php[45]_httpd functions cannot guarantee these requirements.
146# See Bug 2272 for details.
158require_php_sapi_from() { 147require_php_sapi_from() {
159 has_php 148 has_php
160 149
161 local has_sapi="0" 150 local has_sapi="0"
162 local x 151 local x
181 eerror " $@" 170 eerror " $@"
182 eerror 171 eerror
183 die "No compatible PHP SAPIs found" 172 die "No compatible PHP SAPIs found"
184} 173}
185 174
175# @FUNCTION: require_php_with_use
176# @USAGE: <list of USE flags>
177# @DESCRIPTION:
186# Call this function from pkg_setup if your package requires PHP compiled 178# Call this function from pkg_setup if your package requires PHP compiled
187# with specific USE flags 179# with specific USE flags. Returns if all of the listed USE flags are enabled.
180# Dies if any of the listed USE flags are disabled.
181
182# @VARIABLE: PHPCHECKNODIE
183# @DESCRIPTION:
184# You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple
185# require_php_with_(any)_use checks without making the ebuild die on every failure.
186# This is useful in cases when certain PHP features are only required if specific
187# USE flag(s) are enabled for that ebuild.
188# @CODE
189# Example:
188# 190#
189# $1 ... a list of USE flags 191# local flags="pcre session snmp sockets wddx"
190# 192# use mysql && flags="${flags} mysql"
191# Returns if all of the listed USE flags are enabled 193# use postgres && flags="${flags} postgres"
192# Dies if any of the listed USE flags are disabled 194# if ! PHPCHECKNODIE="yes" require_php_with_use ${flags} \
193 195# || ! PHPCHECKNODIE="yes" require_php_with_any_use gd gd-external ; then
196# die "Re-install ${PHP_PKG} with ${flags} and either gd or gd-external"
197# fi
198# @CODE
194require_php_with_use() { 199require_php_with_use() {
195 has_php 200 has_php
196 201
197 local missing_use="" 202 local missing_use=""
198 local x 203 local x
199 204
200 einfo "Checking for required PHP feature(s) ..." 205 einfo "Checking for required PHP feature(s) ..."
201 206
202 for x in $@ ; do 207 for x in $@ ; do
208 case $x in
209 pcre|spl|reflection|mhash)
210 eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
211 eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break"
212 eqawarn "if you check the USE flags against PHP 5.3 ebuilds."
213 eqawarn "Please use USE dependencies from EAPI 2 instead"
214 ;;
215 esac
216
203 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then 217 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
204 einfo " Discovered missing USE flag: ${x}" 218 einfo " Discovered missing USE flag: ${x}"
205 missing_use="${missing_use} ${x}" 219 missing_use="${missing_use} ${x}"
206 fi 220 fi
207 done 221 done
225 else 239 else
226 return 1 240 return 1
227 fi 241 fi
228} 242}
229 243
244# @FUNCTION: require_php_with_any_use
245# @USAGE: <list of USE flags>
246# @DESCRIPTION:
230# Call this function from pkg_setup if your package requires PHP compiled 247# Call this function from pkg_setup if your package requires PHP compiled with
231# with any of specified USE flags
232#
233# $1 ... a list of USE flags
234#
235# Returns if any of the listed USE flags are enabled 248# any of specified USE flags. Returns if any of the listed USE flags are enabled.
236# Dies if all of the listed USE flags are disabled 249# Dies if all of the listed USE flags are disabled.
237
238require_php_with_any_use() { 250require_php_with_any_use() {
239 has_php 251 has_php
240 252
241 local missing_use="" 253 local missing_use=""
242 local x 254 local x
277# has_*() functions 289# has_*() functions
278# 290#
279# These functions return 0 if the condition is satisfied, 1 otherwise 291# These functions return 0 if the condition is satisfied, 1 otherwise
280# ======================================================================== 292# ========================================================================
281 293
294# @FUNCTION: has_zts
295# @DESCRIPTION:
282# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled 296# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled.
283 297# @RETURN: 0 if true, 1 otherwise
284has_zts() { 298has_zts() {
285 has_php 299 has_php
286 300
287 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then 301 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then
288 return 0 302 return 0
289 fi 303 fi
290 304
291 return 1 305 return 1
292} 306}
293 307
308# @FUNCTION: has_debug
309# @DESCRIPTION:
294# Check if our PHP was built with Hardened-PHP enabled 310# Check if our PHP was built with debug support enabled.
295 311# @RETURN: 0 if true, 1 otherwise
296has_hardenedphp() { 312has_debug() {
297 has_php 313 has_php
298 314
299 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then 315 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
300 return 0 316 return 0
301 fi 317 fi
302 318
303 return 1 319 return 1
304} 320}
305 321
322# @FUNCTION: has_concurrentmodphp
323# @DESCRIPTION:
306# Check if our PHP was built with debug support enabled 324# Check if our PHP was built with the concurrentmodphp support enabled.
307 325# @RETURN: 0 if true, 1 otherwise
308has_debug() { 326has_concurrentmodphp() {
309 has_php 327 has_php
310 328
311 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then 329 if built_with_use =${PHP_PKG} apache2 concurrentmodphp || phpconfutils_built_with_use =${PHP_PKG} apache2 concurrentmodphp ; then
312 return 0 330 return 0
313 fi 331 fi
314 332
315 return 1 333 return 1
316} 334}
319# require_*() functions 337# require_*() functions
320# 338#
321# These functions die() if PHP was built without the required features 339# These functions die() if PHP was built without the required features
322# ======================================================================== 340# ========================================================================
323 341
342# @FUNCTION: require_pdo
343# @DESCRIPTION:
324# Require a PHP built with PDO support (PHP5 only) 344# Require a PHP built with PDO support (PHP5 only).
325 345# This function is now redundant and DEPRECATED since
346# pdo-external use flag and pecl-pdo-* ebuilds were removed.
347# You should use require_php_with_use pdo instead now.
348# @RETURN: die if feature is missing
326require_pdo() { 349require_pdo() {
327 has_php 350 has_php
328
329 # Do we have PHP5 installed?
330 if [[ "${PHP_VERSION}" == "4" ]] ; then
331 eerror
332 eerror "This package requires PDO."
333 eerror "PDO is only available for PHP 5."
334 eerror "You must install =dev-lang/php-5.0* with"
335 eerror "the 'pdo-external' USE flag or you must"
336 eerror "install >=dev-lang/php-5.1 with either"
337 eerror "the 'pdo' or the 'pdo-external' USE flags"
338 eerror "turned on."
339 eerror
340 die "PHP 5 not installed"
341 fi
342 351
343 # Was PHP5 compiled with internal PDO support? 352 # Was PHP5 compiled with internal PDO support?
344 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then 353 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then
345 return 354 return
346 fi 355 else
347
348 # Ok, maybe PDO was built as an external extension?
349 if ( built_with_use =${PHP_PKG} pdo-external || phpconfutils_built_with_use =${PHP_PKG} pdo-external ) && has_version 'dev-php5/pecl-pdo' ; then
350 return
351 fi
352
353 # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
354 if has_version 'dev-php5/pecl-pdo' ; then
355 return
356 fi
357
358 # If we get here, then we have no PDO support
359 eerror 356 eerror
360 eerror "No PDO extension for PHP found." 357 eerror "No PDO extension for PHP found."
361 eerror "Please note that PDO only exists for PHP 5." 358 eerror "Please note that PDO only exists for PHP 5."
362 eerror "Please install a PDO extension for PHP 5," 359 eerror "Please install a PDO extension for PHP 5."
363 eerror "you must install =dev-lang/php-5.0* with" 360 eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"."
364 eerror "the 'pdo-external' USE flag or you must"
365 eerror "install >=dev-lang/php-5.1 with either"
366 eerror "the 'pdo' or the 'pdo-external' USE flags"
367 eerror "turned on."
368 eerror 361 eerror
369 die "No PDO extension for PHP 5 found" 362 die "No PDO extension for PHP 5 found"
363 fi
370} 364}
371 365
366# @FUNCTION: require_php_cli
367# @DESCRIPTION:
372# Determines which installed PHP version has the CLI SAPI enabled, 368# Determines which installed PHP version has the CLI SAPI enabled.
373# useful for PEAR stuff, or anything which needs to run PHP 369# Useful for PEAR stuff, or anything which needs to run PHP script
374# scripts depending on the CLI SAPI 370# depending on the CLI SAPI.
375 371# @RETURN: die if feature is missing
376require_php_cli() { 372require_php_cli() {
377 # If PHP_PKG is set, then we have remembered our PHP settings 373 # If PHP_PKG is set, then we have remembered our PHP settings
378 # from last time 374 # from last time
379 if [[ -n ${PHP_PKG} ]] ; then 375 if [[ -n ${PHP_PKG} ]] ; then
380 return 376 return
381 fi 377 fi
382 378
383 local PHP_PACKAGE_FOUND="" 379 local PHP_PACKAGE_FOUND=""
384 380
385 # Detect which PHP version we have installed
386 if has_version '=dev-lang/php-4*' ; then
387 PHP_PACKAGE_FOUND="1"
388 pkg="`best_version '=dev-lang/php-4*'`"
389 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
390 PHP_VERSION="4"
391 fi
392 fi
393
394 if has_version '=dev-lang/php-5*' ; then 381 if has_version '=dev-lang/php-5*' ; then
395 PHP_PACKAGE_FOUND="1" 382 PHP_PACKAGE_FOUND="1"
396 pkg="`best_version '=dev-lang/php-5*'`" 383 pkg="$(best_version '=dev-lang/php-5*')"
397 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then 384 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
398 PHP_VERSION="5" 385 PHP_VERSION="5"
399 fi 386 fi
400 fi 387 fi
401 388
402 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 389 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
403 die "Unable to find an installed dev-lang/php package" 390 die "Unable to find an installed dev-lang/php package"
404 fi 391 fi
405 392
406 if [[ -z ${PHP_VERSION} ]] ; then 393 if [[ -z ${PHP_VERSION} ]] ; then
407 die "No PHP CLI installed" 394 die "No PHP CLI installed. Re-emerge dev-lang/php with USE=cli."
408 fi 395 fi
409 396
410 # If we get here, then PHP_VERSION tells us which version of PHP we 397 # If we get here, then PHP_VERSION tells us which version of PHP we
411 # want to use 398 # want to use
412 uses_php${PHP_VERSION} 399 uses_php${PHP_VERSION}
413} 400}
414 401
402# @FUNCTION: require_php_cgi
403# @DESCRIPTION:
415# Determines which installed PHP version has the CGI SAPI enabled, 404# Determines which installed PHP version has the CGI SAPI enabled.
416# useful for anything which needs to run PHP scripts 405# Useful for anything which needs to run PHP scripts depending on the CGI SAPI.
417# depending on the CGI SAPI 406# @RETURN: die if feature is missing
418
419require_php_cgi() { 407require_php_cgi() {
420 # If PHP_PKG is set, then we have remembered our PHP settings 408 # If PHP_PKG is set, then we have remembered our PHP settings
421 # from last time 409 # from last time
422 if [[ -n ${PHP_PKG} ]] ; then 410 if [[ -n ${PHP_PKG} ]] ; then
423 return 411 return
424 fi 412 fi
425 413
426 local PHP_PACKAGE_FOUND="" 414 local PHP_PACKAGE_FOUND=""
427 415
428 # Detect which PHP version we have installed
429 if has_version '=dev-lang/php-4*' ; then
430 PHP_PACKAGE_FOUND="1"
431 pkg="`best_version '=dev-lang/php-4*'`"
432 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
433 PHP_VERSION="4"
434 fi
435 fi
436
437 if has_version '=dev-lang/php-5*' ; then 416 if has_version '=dev-lang/php-5*' ; then
438 PHP_PACKAGE_FOUND="1" 417 PHP_PACKAGE_FOUND="1"
439 pkg="`best_version '=dev-lang/php-5*'`" 418 pkg="$(best_version '=dev-lang/php-5*')"
440 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then 419 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
441 PHP_VERSION="5" 420 PHP_VERSION="5"
442 fi 421 fi
443 fi 422 fi
444 423
445 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 424 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
446 die "Unable to find an installed dev-lang/php package" 425 die "Unable to find an installed dev-lang/php package"
447 fi 426 fi
448 427
449 if [[ -z ${PHP_VERSION} ]] ; then 428 if [[ -z ${PHP_VERSION} ]] ; then
450 die "No PHP CGI installed" 429 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
451 fi 430 fi
452 431
453 # If we get here, then PHP_VERSION tells us which version of PHP we 432 # If we get here, then PHP_VERSION tells us which version of PHP we
454 # want to use 433 # want to use
455 uses_php${PHP_VERSION} 434 uses_php${PHP_VERSION}
456} 435}
457 436
437# @FUNCTION: require_sqlite
438# @DESCRIPTION:
458# Require a PHP built with SQLite support 439# Require a PHP built with SQLite support
459 440# @RETURN: die if feature is missing
460require_sqlite() { 441require_sqlite() {
461 has_php 442 has_php
462 443
463 # Has our PHP been built with SQLite support? 444 # Has our PHP been built with SQLite support?
464 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then 445 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then
465 return 446 return
466 fi
467
468 # Do we have pecl-sqlite installed for PHP4?
469 if [[ "${PHP_VERSION}" == "4" ]] ; then
470 if has_version 'dev-php4/pecl-sqlite' ; then
471 return
472 fi
473 fi 447 fi
474 448
475 # If we get here, then we don't have any SQLite support for PHP installed 449 # If we get here, then we don't have any SQLite support for PHP installed
476 eerror 450 eerror
477 eerror "No SQLite extension for PHP found." 451 eerror "No SQLite extension for PHP found."
480 eerror "'sqlite' USE flag when emerging dev-lang/php." 454 eerror "'sqlite' USE flag when emerging dev-lang/php."
481 eerror 455 eerror
482 die "No SQLite extension for PHP found" 456 die "No SQLite extension for PHP found"
483} 457}
484 458
459# @FUNCTION: require_gd
460# @DESCRIPTION:
485# Require a PHP built with GD support 461# Require a PHP built with GD support
486 462# @RETURN: die if feature is missing
487require_gd() { 463require_gd() {
488 has_php 464 has_php
489 465
490 # Do we have the internal GD support installed? 466 # Do we have the internal GD support installed?
491 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then 467 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then
512# Misc functions 488# Misc functions
513# 489#
514# These functions provide miscellaneous checks and functionality. 490# These functions provide miscellaneous checks and functionality.
515# ======================================================================== 491# ========================================================================
516 492
493# @FUNCTION: php_binary_extension
494# @DESCRIPTION:
517# Executes some checks needed when installing a binary PHP extension 495# Executes some checks needed when installing a binary PHP extension.
518
519php_binary_extension() { 496php_binary_extension() {
520 has_php 497 has_php
521 498
522 local PUSE_ENABLED="" 499 local PUSE_ENABLED=""
523 500
524 # Binary extensions do not support the change of PHP 501 # Binary extensions do not support the change of PHP
525 # API version, so they can't be installed when USE flags 502 # API version, so they can't be installed when USE flags
526 # are enabled which change the PHP API version, they also 503 # are enabled which change the PHP API version, they also
527 # don't provide correctly versioned symbols for our use 504 # don't provide correctly versioned symbols for our use
528 505
529 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then 506 if has_debug ; then
530 eerror
531 eerror "You cannot install binary PHP extensions"
532 eerror "when the 'hardenedphp' USE flag is enabled!"
533 eerror "Please reemerge dev-lang/php with the"
534 eerror "'hardenedphp' USE flag turned off."
535 eerror
536 PUSE_ENABLED="1"
537 fi
538
539 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
540 eerror 507 eerror
541 eerror "You cannot install binary PHP extensions" 508 eerror "You cannot install binary PHP extensions"
542 eerror "when the 'debug' USE flag is enabled!" 509 eerror "when the 'debug' USE flag is enabled!"
543 eerror "Please reemerge dev-lang/php with the" 510 eerror "Please reemerge dev-lang/php with the"
544 eerror "'debug' USE flag turned off." 511 eerror "'debug' USE flag turned off."
545 eerror 512 eerror
546 PUSE_ENABLED="1" 513 PUSE_ENABLED="1"
547 fi 514 fi
548 515
549 if built_with_use =${PHP_PKG} concurrentmodphp || phpconfutils_built_with_use =${PHP_PKG} concurrentmodphp ; then 516 if has_concurrentmodphp ; then
550 eerror 517 eerror
551 eerror "You cannot install binary PHP extensions when" 518 eerror "You cannot install binary PHP extensions when"
552 eerror "the 'concurrentmodphp' USE flag is enabled!" 519 eerror "the 'concurrentmodphp' USE flag is enabled!"
553 eerror "Please reemerge dev-lang/php with the" 520 eerror "Please reemerge dev-lang/php with the"
554 eerror "'concurrentmodphp' USE flag turned off." 521 eerror "'concurrentmodphp' USE flag turned off."
555 eerror 522 eerror
556 PUSE_ENABLED="1" 523 PUSE_ENABLED="1"
557 fi 524 fi
558 525
559 if [[ -n ${PUSE_ENABLED} ]] ; then 526 if [[ -n ${PUSE_ENABLED} ]] ; then
560 die "'hardenedphp' and/or 'debug' and/or 'concurrentmodphp' USE flags turned on!" 527 die "'debug' and/or 'concurrentmodphp' USE flags turned on!"
561 fi 528 fi
562} 529}
563 530
531# @FUNCTION: dodoc-php
532# @USAGE: <list of docs>
533# @DESCRIPTION:
564# Alternative to dodoc function for use in our PHP eclasses and 534# Alternative to dodoc function for use in our PHP eclasses and ebuilds.
565# ebuilds.
566# Stored here because depend.php gets always sourced everywhere 535# Stored here because depend.php gets always sourced everywhere in the PHP
567# in the PHP ebuilds and eclasses.
568# It simply is dodoc with a changed path to the docs. 536# ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
569# NOTE: no support for docinto is given! 537# NOTE: No support for docinto is provided!
570
571dodoc-php() { 538dodoc-php() {
572if [[ $# -lt 1 ]] ; then 539if [[ $# -lt 1 ]] ; then
573 echo "$0: at least one argument needed" 1>&2 540 echo "$0: at least one argument needed" 1>&2
574 exit 1 541 exit 1
575fi 542fi
576 543
577phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/" 544phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
578
579if [[ ! -d "${phpdocdir}" ]] ; then
580 install -d "${phpdocdir}"
581fi
582 545
583for x in $@ ; do 546for x in $@ ; do
584 if [[ -s "${x}" ]] ; then 547 if [[ -s "${x}" ]] ; then
585 install -m0644 "${x}" "${phpdocdir}" 548 insinto "${phpdocdir}"
549 doins "${x}"
586 gzip -f -9 "${phpdocdir}/${x##*/}" 550 gzip -f -9 "${D}/${phpdocdir}/${x##*/}"
587 elif [[ ! -e "${x}" ]] ; then 551 elif [[ ! -e "${x}" ]] ; then
588 echo "dodoc-php: ${x} does not exist" 1>&2 552 echo "dodoc-php: ${x} does not exist" 1>&2
589 fi 553 fi
590done 554done
591} 555}
556
557# @FUNCTION: dohtml-php
558# @USAGE: <list of html docs>
559# @DESCRIPTION:
560# Alternative to dohtml function for use in our PHP eclasses and ebuilds.
561# Stored here because depend.php gets always sourced everywhere in the PHP
562# ebuilds and eclasses. It simply is dohtml with a changed path to the docs.
563# NOTE: No support for [-a|-A|-p|-x] options is provided!
564dohtml-php() {
565if [[ $# -lt 1 ]] ; then
566 echo "$0: at least one argument needed" 1>&2
567 exit 1
568fi
569
570phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
571
572for x in $@ ; do
573 if [[ -s "${x}" ]] ; then
574 insinto "${phphtmldir}"
575 doins "${x}"
576 elif [[ ! -e "${x}" ]] ; then
577 echo "dohtml-php: ${x} does not exist" 1>&2
578 fi
579done
580}

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.20