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

  ViewVC Help
Powered by ViewVC 1.1.20