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

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.36 - (show annotations) (download)
Wed Jun 24 13:36:03 2015 UTC (13 days, 6 hours ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.35: +3 -1 lines
Error occurred while calculating annotation data.
depend.php.eclass is deprecated and is set to be removed 30 days after bug 552836 is resolved

1 # Copyright 1999-2015 Gentoo Foundation
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 $
4
5 # @DEAD
6 # @ECLASS: depend.php.eclass
7 # @MAINTAINER:
8 # Gentoo PHP team <php-bugs@gentoo.org>
9 # @AUTHOR:
10 # Author: Stuart Herbert <stuart@gentoo.org>
11 # Author: Luca Longinotti <chtekk@gentoo.org>
12 # Author: Jakub Moc <jakub@gentoo.org> (documentation)
13 # @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features.
14 # @DESCRIPTION:
15 # This eclass provides functions that allow ebuilds to depend on php5 and check
16 # for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install
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
19
20 inherit eutils multilib
21
22 # PHP5-only depend functions
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.
28 need_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.
39 need_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
47 # @DESCRIPTION:
48 # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
49 # (with any SAPI).
50 need_php5() {
51 DEPEND="${DEPEND} =dev-lang/php-5*"
52 RDEPEND="${RDEPEND} =dev-lang/php-5*"
53 PHP_VERSION="5"
54 PHP_SHARED_CAT="php5"
55 }
56
57 # common settings go in here
58 uses_php5() {
59 # cache this
60 libdir=$(get_libdir)
61
62 PHPIZE="/usr/${libdir}/php5/bin/phpize"
63 PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
64 PHPCLI="/usr/${libdir}/php5/bin/php"
65 PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
66 PHP_PKG="$(best_version =dev-lang/php-5*)"
67 PHPPREFIX="/usr/${libdir}/php5"
68 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
69
70 einfo
71 einfo "Using ${PHP_PKG}"
72 einfo
73 }
74
75 # general PHP depend functions
76
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.
81 need_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
88 # @DESCRIPTION:
89 # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
90 # (any version) with either cgi or apache2 SAPI.
91 need_php_httpd() {
92 DEPEND="${DEPEND} virtual/httpd-php"
93 RDEPEND="${RDEPEND} virtual/httpd-php"
94 }
95
96 # @FUNCTION: need_php
97 # @DESCRIPTION:
98 # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
99 # (any version with any SAPI).
100 need_php() {
101 DEPEND="${DEPEND} dev-lang/php"
102 RDEPEND="${RDEPEND} dev-lang/php"
103 PHP_SHARED_CAT="php"
104 }
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.
111 need_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
120 # @FUNCTION: has_php
121 # @DESCRIPTION:
122 # 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
124 # are installed.
125 has_php() {
126 # Detect which PHP version we have installed
127 if has_version '=dev-lang/php-5*' ; then
128 PHP_VERSION="5"
129 else
130 die "Unable to find an installed dev-lang/php package"
131 fi
132
133 # If we get here, then PHP_VERSION tells us which version of PHP we
134 # want to use
135 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.
153 require_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 }
181
182 # @FUNCTION: require_php_with_use
183 # @USAGE: <list of USE flags>
184 # @DESCRIPTION:
185 # Call this function from pkg_setup if your package requires PHP compiled
186 # with specific USE flags. Returns if all of the listed USE flags are enabled.
187 # Dies if any of the listed USE flags are disabled.
188
189 # @VARIABLE: PHPCHECKNODIE
190 # @DESCRIPTION:
191 # You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple
192 # require_php_with_(any)_use checks without making the ebuild die on every failure.
193 # This is useful in cases when certain PHP features are only required if specific
194 # USE flag(s) are enabled for that ebuild.
195 # @CODE
196 # Example:
197 #
198 # local flags="pcre session snmp sockets wddx"
199 # use mysql && flags="${flags} mysql"
200 # use postgres && flags="${flags} postgres"
201 # if ! PHPCHECKNODIE="yes" require_php_with_use ${flags} \
202 # || ! PHPCHECKNODIE="yes" require_php_with_any_use gd gd-external ; then
203 # die "Re-install ${PHP_PKG} with ${flags} and either gd or gd-external"
204 # fi
205 # @CODE
206 require_php_with_use() {
207 has_php
208
209 local missing_use=""
210 local x
211
212 einfo "Checking for required PHP feature(s) ..."
213
214 for x in $@ ; do
215 case $x in
216 pcre|spl|reflection|mhash)
217 eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
218 eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break"
219 eqawarn "if you check the USE flags against PHP 5.3 ebuilds."
220 eqawarn "Please use USE dependencies from EAPI 2 instead"
221 ;;
222 esac
223
224 if ! built_with_use =${PHP_PKG} ${x} ; then
225 einfo " Discovered missing USE flag: ${x}"
226 missing_use="${missing_use} ${x}"
227 fi
228 done
229
230 if [[ -z "${missing_use}" ]] ; then
231 if [[ -z "${PHPCHECKNODIE}" ]] ; then
232 return
233 else
234 return 0
235 fi
236 fi
237
238 if [[ -z "${PHPCHECKNODIE}" ]] ; then
239 eerror
240 eerror "${PHP_PKG} needs to be re-installed with all of the following"
241 eerror "USE flags enabled:"
242 eerror
243 eerror " $@"
244 eerror
245 die "Missing PHP USE flags found"
246 else
247 return 1
248 fi
249 }
250
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.
257 require_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
306 has_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
321 has_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
336 has_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
347 # ========================================================================
348 # require_*() functions
349 #
350 # These functions die() if PHP was built without the required features
351 # ========================================================================
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
360 require_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
384 require_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
415 # @FUNCTION: require_php_cgi
416 # @DESCRIPTION:
417 # 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.
419 # @RETURN: die if feature is missing
420 require_php_cgi() {
421 # If PHP_PKG is set, then we have remembered our PHP settings
422 # from last time
423 if [[ -n ${PHP_PKG} ]] ; then
424 return
425 fi
426
427 local PHP_PACKAGE_FOUND=""
428
429 if has_version '=dev-lang/php-5*' ; then
430 PHP_PACKAGE_FOUND="1"
431 pkg="$(best_version '=dev-lang/php-5*')"
432 if built_with_use =${pkg} cgi ; then
433 PHP_VERSION="5"
434 fi
435 fi
436
437 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
438 die "Unable to find an installed dev-lang/php package"
439 fi
440
441 if [[ -z ${PHP_VERSION} ]] ; then
442 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
443 fi
444
445 # If we get here, then PHP_VERSION tells us which version of PHP we
446 # want to use
447 uses_php${PHP_VERSION}
448 }
449
450 # @FUNCTION: require_sqlite
451 # @DESCRIPTION:
452 # Require a PHP built with SQLite support
453 # @RETURN: die if feature is missing
454 require_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
477 require_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 # ========================================================================
503 # Misc functions
504 #
505 # These functions provide miscellaneous checks and functionality.
506 # ========================================================================
507
508 # @FUNCTION: php_binary_extension
509 # @DESCRIPTION:
510 # Executes some checks needed when installing a binary PHP extension.
511 php_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
547 # @FUNCTION: dodoc-php
548 # @USAGE: <list of docs>
549 # @DESCRIPTION:
550 # Alternative to dodoc function for use in our PHP eclasses and ebuilds.
551 # Stored here because depend.php gets always sourced everywhere in the PHP
552 # ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
553 # NOTE: No support for docinto is provided!
554 dodoc-php() {
555 if [[ $# -lt 1 ]] ; then
556 echo "$0: at least one argument needed" 1>&2
557 exit 1
558 fi
559
560 phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
561
562 for x in $@ ; do
563 if [[ -s "${x}" ]] ; then
564 insinto "${phpdocdir}"
565 doins "${x}"
566 gzip -f -9 "${D}/${phpdocdir}/${x##*/}"
567 elif [[ ! -e "${x}" ]] ; then
568 echo "dodoc-php: ${x} does not exist" 1>&2
569 fi
570 done
571 }
572
573 # @FUNCTION: dohtml-php
574 # @USAGE: <list of html docs>
575 # @DESCRIPTION:
576 # Alternative to dohtml function for use in our PHP eclasses and ebuilds.
577 # Stored here because depend.php gets always sourced everywhere in the PHP
578 # ebuilds and eclasses. It simply is dohtml with a changed path to the docs.
579 # NOTE: No support for [-a|-A|-p|-x] options is provided!
580 dohtml-php() {
581 if [[ $# -lt 1 ]] ; then
582 echo "$0: at least one argument needed" 1>&2
583 exit 1
584 fi
585
586 phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
587
588 for x in $@ ; do
589 if [[ -s "${x}" ]] ; then
590 insinto "${phphtmldir}"
591 doins "${x}"
592 elif [[ ! -e "${x}" ]] ; then
593 echo "dohtml-php: ${x} does not exist" 1>&2
594 fi
595 done
596 }

  ViewVC Help
Powered by ViewVC 1.1.20