/[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.36 Revision 1.37
1# Copyright 1999-2015 Gentoo Foundation 1# Copyright 1999-2015 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.36 2015/06/24 13:36:03 grknight Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.37 2015/07/17 18:29:39 grknight Exp $
4 4
5# @DEAD 5# @DEAD
6# @ECLASS: depend.php.eclass 6# @ECLASS: depend.php.eclass
7# @MAINTAINER: 7# @MAINTAINER:
8# Gentoo PHP team <php-bugs@gentoo.org> 8# Gentoo PHP team <php-bugs@gentoo.org>
19 19
20inherit eutils multilib 20inherit eutils multilib
21 21
22# PHP5-only depend functions 22# PHP5-only depend functions
23 23
24# @FUNCTION: need_php5_cli
25# @DESCRIPTION:
26# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
27# with cli SAPI.
28need_php5_cli() {
29 eqawarn "(need_php5_cli) Deprecated function call. Set to be removed on 2015-07-17"
30 DEPEND="${DEPEND} =dev-lang/php-5*"
31 RDEPEND="${RDEPEND} =dev-lang/php-5*"
32 PHP_VERSION="5"
33}
34
35# @FUNCTION: need_php5_httpd
36# @DESCRIPTION:
37# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
38# with either cgi or apache2 SAPI.
39need_php5_httpd() {
40 eqawarn "(need_php5_httpd) Deprecated function call. Set to be removed on 2015-07-17"
41 DEPEND="${DEPEND} =virtual/httpd-php-5*"
42 RDEPEND="${RDEPEND} =virtual/httpd-php-5*"
43 PHP_VERSION="5"
44}
45
46# @FUNCTION: need_php5 24# @FUNCTION: need_php5
47# @DESCRIPTION: 25# @DESCRIPTION:
48# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5 26# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
49# (with any SAPI). 27# (with any SAPI).
50need_php5() { 28need_php5() {
72 einfo 50 einfo
73} 51}
74 52
75# general PHP depend functions 53# general PHP depend functions
76 54
77# @FUNCTION: need_php_cli
78# @DESCRIPTION:
79# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
80# (any version) with cli SAPI.
81need_php_cli() {
82 eqawarn "(need_php_cli) Deprecated function call. Set to be removed on 2015-07-17"
83 DEPEND="${DEPEND} dev-lang/php"
84 RDEPEND="${RDEPEND} dev-lang/php"
85}
86
87# @FUNCTION: need_php_httpd 55# @FUNCTION: need_php_httpd
88# @DESCRIPTION: 56# @DESCRIPTION:
89# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP 57# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
90# (any version) with either cgi or apache2 SAPI. 58# (any version) with either cgi or apache2 SAPI.
91need_php_httpd() { 59need_php_httpd() {
100need_php() { 68need_php() {
101 DEPEND="${DEPEND} dev-lang/php" 69 DEPEND="${DEPEND} dev-lang/php"
102 RDEPEND="${RDEPEND} dev-lang/php" 70 RDEPEND="${RDEPEND} dev-lang/php"
103 PHP_SHARED_CAT="php" 71 PHP_SHARED_CAT="php"
104} 72}
105
106# @FUNCTION: need_php_by_category
107# @DESCRIPTION:
108# Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version
109# determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or
110# dev-php5, respectively.
111need_php_by_category() {
112 eqawarn "(need_php_by_category) Deprecated function call. Set to be removed on 2015-07-17"
113 case "${CATEGORY}" in
114 dev-php) need_php ;;
115 *) die "Version of PHP required by packages in category ${CATEGORY} unknown"
116 esac
117}
118
119 73
120# @FUNCTION: has_php 74# @FUNCTION: has_php
121# @DESCRIPTION: 75# @DESCRIPTION:
122# Call this function from your pkg_setup, src_compile, src_install etc. if you 76# Call this function from your pkg_setup, src_compile, src_install etc. if you
123# need to know which PHP version is being used and where the PHP binaries/data 77# need to know which PHP version is being used and where the PHP binaries/data
131 fi 85 fi
132 86
133 # If we get here, then PHP_VERSION tells us which version of PHP we 87 # If we get here, then PHP_VERSION tells us which version of PHP we
134 # want to use 88 # want to use
135 uses_php${PHP_VERSION} 89 uses_php${PHP_VERSION}
136}
137
138# @FUNCTION: require_php_sapi_from
139# @USAGE: <list of SAPIs>
140# @DESCRIPTION:
141# Call this function from pkg_setup if your package only works with
142# specific SAPI(s) and specify a list of PHP SAPI USE flags that are
143# required (one or more from cli, cgi, apache2) as arguments.
144# Returns if any of the listed SAPIs have been installed, dies if none
145# of them is available.
146#
147# Unfortunately, if you want to be really sure that the required SAPI is
148# provided by PHP, you will have to use this function or similar ones (like
149# require_php_cli or require_php_cgi) in pkg_setup until we are able to
150# depend on USE flags being enabled. The above described need_php[45]_cli
151# and need_php[45]_httpd functions cannot guarantee these requirements.
152# See Bug 2272 for details.
153require_php_sapi_from() {
154 eqawarn "(require_php_sapi_from) Deprecated function call. Set to be removed on 2015-07-17"
155 has_php
156
157 local has_sapi="0"
158 local x
159
160 einfo "Checking for compatible SAPI(s)"
161
162 for x in $@ ; do
163 if built_with_use =${PHP_PKG} ${x} ; then
164 einfo " Discovered compatible SAPI ${x}"
165 has_sapi="1"
166 fi
167 done
168
169 if [[ "${has_sapi}" == "1" ]] ; then
170 return
171 fi
172
173 eerror
174 eerror "${PHP_PKG} needs to be re-installed with one of the following"
175 eerror "USE flags enabled:"
176 eerror
177 eerror " $@"
178 eerror
179 die "No compatible PHP SAPIs found"
180} 90}
181 91
182# @FUNCTION: require_php_with_use 92# @FUNCTION: require_php_with_use
183# @USAGE: <list of USE flags> 93# @USAGE: <list of USE flags>
184# @DESCRIPTION: 94# @DESCRIPTION:
246 else 156 else
247 return 1 157 return 1
248 fi 158 fi
249} 159}
250 160
251# @FUNCTION: require_php_with_any_use
252# @USAGE: <list of USE flags>
253# @DESCRIPTION:
254# Call this function from pkg_setup if your package requires PHP compiled with
255# any of specified USE flags. Returns if any of the listed USE flags are enabled.
256# Dies if all of the listed USE flags are disabled.
257require_php_with_any_use() {
258 eqawarn "(require_php_with_any_use) Deprecated function call. Set to be removed on 2015-07-17"
259 has_php
260
261 local missing_use=""
262 local x
263
264 einfo "Checking for required PHP feature(s) ..."
265
266 for x in $@ ; do
267 if built_with_use =${PHP_PKG} ${x} ; then
268 einfo " USE flag ${x} is enabled, ok ..."
269 return
270 else
271 missing_use="${missing_use} ${x}"
272 fi
273 done
274
275 if [[ -z "${missing_use}" ]] ; then
276 if [[ -z "${PHPCHECKNODIE}" ]] ; then
277 return
278 else
279 return 0
280 fi
281 fi
282
283 if [[ -z "${PHPCHECKNODIE}" ]] ; then
284 eerror
285 eerror "${PHP_PKG} needs to be re-installed with any of the following"
286 eerror "USE flags enabled:"
287 eerror
288 eerror " $@"
289 eerror
290 die "Missing PHP USE flags found"
291 else
292 return 1
293 fi
294}
295
296# ========================================================================
297# has_*() functions
298#
299# These functions return 0 if the condition is satisfied, 1 otherwise
300# ========================================================================
301
302# @FUNCTION: has_zts
303# @DESCRIPTION:
304# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled.
305# @RETURN: 0 if true, 1 otherwise
306has_zts() {
307 eqawarn "(has_zts) Deprecated function call. Set to be removed on 2015-07-17"
308 has_php
309
310 if built_with_use =${PHP_PKG} apache2 threads ; then
311 return 0
312 fi
313
314 return 1
315}
316
317# @FUNCTION: has_debug
318# @DESCRIPTION:
319# Check if our PHP was built with debug support enabled.
320# @RETURN: 0 if true, 1 otherwise
321has_debug() {
322 eqawarn "(has_debug) Deprecated function call. Set to be removed on 2015-07-17"
323 has_php
324
325 if built_with_use =${PHP_PKG} debug ; then
326 return 0
327 fi
328
329 return 1
330}
331
332# @FUNCTION: has_concurrentmodphp
333# @DESCRIPTION:
334# Check if our PHP was built with the concurrentmodphp support enabled.
335# @RETURN: 0 if true, 1 otherwise
336has_concurrentmodphp() {
337 eqawarn "(has_concurrentmodphp) Deprecated function call. Set to be removed on 2015-07-17"
338 has_php
339
340 if built_with_use =${PHP_PKG} apache2 concurrentmodphp ; then
341 return 0
342 fi
343
344 return 1
345}
346 161
347# ======================================================================== 162# ========================================================================
348# require_*() functions 163# require_*() functions
349# 164#
350# These functions die() if PHP was built without the required features 165# These functions die() if PHP was built without the required features
351# ======================================================================== 166# ========================================================================
352
353# @FUNCTION: require_pdo
354# @DESCRIPTION:
355# Require a PHP built with PDO support (PHP5 only).
356# This function is now redundant and DEPRECATED since
357# pdo-external use flag and pecl-pdo-* ebuilds were removed.
358# You should use require_php_with_use pdo instead now.
359# @RETURN: die if feature is missing
360require_pdo() {
361 eqawarn "(require_pdo) Deprecated function call. Set to be removed on 2015-07-17"
362 has_php
363
364 # Was PHP5 compiled with internal PDO support?
365 if built_with_use =${PHP_PKG} pdo ; then
366 return
367 else
368 eerror
369 eerror "No PDO extension for PHP found."
370 eerror "Please note that PDO only exists for PHP 5."
371 eerror "Please install a PDO extension for PHP 5."
372 eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"."
373 eerror
374 die "No PDO extension for PHP 5 found"
375 fi
376}
377
378# @FUNCTION: require_php_cli
379# @DESCRIPTION:
380# Determines which installed PHP version has the CLI SAPI enabled.
381# Useful for PEAR stuff, or anything which needs to run PHP script
382# depending on the CLI SAPI.
383# @RETURN: die if feature is missing
384require_php_cli() {
385 eqawarn "(require_php_cli) Deprecated function call. Set to be removed on 2015-07-17"
386 # If PHP_PKG is set, then we have remembered our PHP settings
387 # from last time
388 if [[ -n ${PHP_PKG} ]] ; then
389 return
390 fi
391
392 local PHP_PACKAGE_FOUND=""
393
394 if has_version '=dev-lang/php-5*' ; then
395 PHP_PACKAGE_FOUND="1"
396 pkg="$(best_version '=dev-lang/php-5*')"
397 if built_with_use =${pkg} cli ; then
398 PHP_VERSION="5"
399 fi
400 fi
401
402 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
403 die "Unable to find an installed dev-lang/php package"
404 fi
405
406 if [[ -z ${PHP_VERSION} ]] ; then
407 die "No PHP CLI installed. Re-emerge dev-lang/php with USE=cli."
408 fi
409
410 # If we get here, then PHP_VERSION tells us which version of PHP we
411 # want to use
412 uses_php${PHP_VERSION}
413}
414 167
415# @FUNCTION: require_php_cgi 168# @FUNCTION: require_php_cgi
416# @DESCRIPTION: 169# @DESCRIPTION:
417# Determines which installed PHP version has the CGI SAPI enabled. 170# Determines which installed PHP version has the CGI SAPI enabled.
418# Useful for anything which needs to run PHP scripts depending on the CGI SAPI. 171# Useful for anything which needs to run PHP scripts depending on the CGI SAPI.
445 # If we get here, then PHP_VERSION tells us which version of PHP we 198 # If we get here, then PHP_VERSION tells us which version of PHP we
446 # want to use 199 # want to use
447 uses_php${PHP_VERSION} 200 uses_php${PHP_VERSION}
448} 201}
449 202
450# @FUNCTION: require_sqlite
451# @DESCRIPTION:
452# Require a PHP built with SQLite support
453# @RETURN: die if feature is missing
454require_sqlite() {
455 eqawarn "(require_sqlite) Deprecated function call. Set to be removed on 2015-07-17"
456 has_php
457
458 # Has our PHP been built with SQLite support?
459 if built_with_use =${PHP_PKG} sqlite ; then
460 return
461 fi
462
463 # If we get here, then we don't have any SQLite support for PHP installed
464 eerror
465 eerror "No SQLite extension for PHP found."
466 eerror "Please install an SQLite extension for PHP,"
467 eerror "this is done best by simply adding the"
468 eerror "'sqlite' USE flag when emerging dev-lang/php."
469 eerror
470 die "No SQLite extension for PHP found"
471}
472
473# @FUNCTION: require_gd
474# @DESCRIPTION:
475# Require a PHP built with GD support
476# @RETURN: die if feature is missing
477require_gd() {
478 eqawarn "(require_gd) Deprecated function call. Set to be removed on 2015-07-17"
479 has_php
480
481 # Do we have the internal GD support installed?
482 if built_with_use =${PHP_PKG} gd ; then
483 return
484 fi
485
486 # Ok, maybe GD was built using the external library support?
487 if built_with_use =${PHP_PKG} gd-external ; then
488 return
489 fi
490
491 # If we get here, then we have no GD support
492 eerror
493 eerror "No GD support for PHP found."
494 eerror "Please install the GD support for PHP,"
495 eerror "you must install dev-lang/php with either"
496 eerror "the 'gd' or the 'gd-external' USE flags"
497 eerror "turned on."
498 eerror
499 die "No GD support found for PHP"
500}
501
502# ======================================================================== 203# ========================================================================
503# Misc functions 204# Misc functions
504# 205#
505# These functions provide miscellaneous checks and functionality. 206# These functions provide miscellaneous checks and functionality.
506# ======================================================================== 207# ========================================================================
507
508# @FUNCTION: php_binary_extension
509# @DESCRIPTION:
510# Executes some checks needed when installing a binary PHP extension.
511php_binary_extension() {
512 eqawarn "(php_binary_extension) Deprecated function call. Set to be removed on 2015-07-17"
513 has_php
514
515 local PUSE_ENABLED=""
516
517 # Binary extensions do not support the change of PHP
518 # API version, so they can't be installed when USE flags
519 # are enabled which change the PHP API version, they also
520 # don't provide correctly versioned symbols for our use
521
522 if has_debug ; then
523 eerror
524 eerror "You cannot install binary PHP extensions"
525 eerror "when the 'debug' USE flag is enabled!"
526 eerror "Please reemerge dev-lang/php with the"
527 eerror "'debug' USE flag turned off."
528 eerror
529 PUSE_ENABLED="1"
530 fi
531
532 if has_concurrentmodphp ; then
533 eerror
534 eerror "You cannot install binary PHP extensions when"
535 eerror "the 'concurrentmodphp' USE flag is enabled!"
536 eerror "Please reemerge dev-lang/php with the"
537 eerror "'concurrentmodphp' USE flag turned off."
538 eerror
539 PUSE_ENABLED="1"
540 fi
541
542 if [[ -n ${PUSE_ENABLED} ]] ; then
543 die "'debug' and/or 'concurrentmodphp' USE flags turned on!"
544 fi
545}
546 208
547# @FUNCTION: dodoc-php 209# @FUNCTION: dodoc-php
548# @USAGE: <list of docs> 210# @USAGE: <list of docs>
549# @DESCRIPTION: 211# @DESCRIPTION:
550# Alternative to dodoc function for use in our PHP eclasses and ebuilds. 212# Alternative to dodoc function for use in our PHP eclasses and ebuilds.

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.20