/[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.2 Revision 1.10
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 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.2 2005/09/04 15:15:37 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.10 2006/01/21 09:15:08 sebastian Exp $
4# 4#
5# ======================================================================== 5# ========================================================================
6# 6#
7# depend.php.eclass 7# depend.php.eclass
8# functions to allow ebuilds to depend on php4 and/or php5 8# functions to allow ebuilds to depend on php4 and/or php5
9# 9#
10# Author: Stuart Herbert 10# Author: Stuart Herbert
11# (stuart@gentoo.org) 11# <stuart@gentoo.org>
12#
13# Author: Luca Longinotti
14# <chtekk@gentoo.org>
15#
16# Maintained by the PHP Herd <php-bugs@gentoo.org>
12# 17#
13# ======================================================================== 18# ========================================================================
14 19
15inherit eutils 20inherit eutils
16 21
22# PHP4-only depend functions
17need_php4_cli() 23need_php4_cli()
18{ 24{
19 DEPEND="${DEPEND} =virtual/php-4*" 25 DEPEND="${DEPEND} =virtual/php-4*"
20 RDEPEND="${RDEPEND} =virtual/php-4*" 26 RDEPEND="${RDEPEND} =virtual/php-4*"
21 PHP_VERSION=4 27 PHP_VERSION=4
52 einfo 58 einfo
53 einfo "Using ${PHP_PKG}" 59 einfo "Using ${PHP_PKG}"
54 einfo 60 einfo
55} 61}
56 62
63# PHP5-only depend functions
57need_php5_cli() 64need_php5_cli()
58{ 65{
59 DEPEND="${DEPEND} =virtual/php-5*" 66 DEPEND="${DEPEND} =virtual/php-5*"
60 RDEPEND="${RDEPEND} =virtual/php-5*" 67 RDEPEND="${RDEPEND} =virtual/php-5*"
61 PHP_VERSION=5 68 PHP_VERSION=5
92 einfo 99 einfo
93 einfo "Using ${PHP_PKG}" 100 einfo "Using ${PHP_PKG}"
94 einfo 101 einfo
95} 102}
96 103
104# general PHP depend functions
105need_php_cli()
106{
107 DEPEND="${DEPEND} virtual/php"
108 RDEPEND="${RDEPEND} virtual/php"
109}
110
111need_php_httpd()
112{
113 DEPEND="${DEPEND} virtual/httpd-php"
114 RDEPEND="${RDEPEND} virtual/httpd-php"
115}
116
97need_php() 117need_php()
98{ 118{
99 DEPEND="${DEPEND} dev-lang/php" 119 DEPEND="${DEPEND} dev-lang/php"
100 RDEPEND="${RDEPEND} dev-lang/php" 120 RDEPEND="${RDEPEND} dev-lang/php"
101 PHP_SHARED_CAT="php" 121 PHP_SHARED_CAT="php"
120# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2) 140# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2)
121# 141#
122# returns if any one of the listed SAPIs has been installed 142# returns if any one of the listed SAPIs has been installed
123# dies if none of the listed SAPIs has been installed 143# dies if none of the listed SAPIs has been installed
124 144
125require_php_sapi_from() { 145require_php_sapi_from()
146{
126 has_php 147 has_php
127 148
128 local has_sapi=0 149 local has_sapi=0
129 local x 150 local x
130 151
159# $1 ... a list of USE flags 180# $1 ... a list of USE flags
160# 181#
161# returns if all of the listed USE flags are set 182# returns if all of the listed USE flags are set
162# dies if any of the listed USE flags are not set 183# dies if any of the listed USE flags are not set
163 184
164require_php_with_use() { 185require_php_with_use()
186{
165 has_php 187 has_php
166 188
167 local missing_use= 189 local missing_use=
168 local x 190 local x
169 191
187 eerror " $@" 209 eerror " $@"
188 eerror 210 eerror
189 die "Re-install ${PHP_PKG}" 211 die "Re-install ${PHP_PKG}"
190} 212}
191 213
192# call this function from your src_compile & src_install methods 214# call this function from your pkg_setup, src_compile & src_install methods
193# if you need to know where the PHP binaries are installed 215# if you need to know where the PHP binaries are installed and their data
194 216
195has_php() 217has_php()
196{ 218{
197 # if PHP_PKG is set, then we have remembered our PHP settings 219 # if PHP_PKG is set, then we have remembered our PHP settings
198 # from last time 220 # from last time
221
199 if [[ -n ${PHP_PKG} ]]; then 222 if [[ -n ${PHP_PKG} ]]; then
200 return 223 return
201 fi 224 fi
202 225
203 if [[ -z ${PHP_VERSION} ]]; then 226 if [[ -z ${PHP_VERSION} ]]; then
204 # detect which PHP version installed 227 # detect which PHP version installed
228 if has_version '=dev-lang/php-4*' ; then
229 PHP_VERSION=4
205 if has_version '=dev-lang/php-5*' ; then 230 elif has_version '=dev-lang/php-5*' ; then
206 PHP_VERSION=5 231 PHP_VERSION=5
207 elif has_version '=dev-lang/php-4*' ; then
208 PHP_VERSION=4
209 else 232 else
210 die "Unable to find an installed dev-lang/php package" 233 die "Unable to find an installed dev-lang/php package"
211 fi 234 fi
212 fi 235 fi
213 236
221# has_*() functions 244# has_*() functions
222# 245#
223# these functions return 0 if the condition is satisfied, or 1 otherwise 246# these functions return 0 if the condition is satisfied, or 1 otherwise
224# ======================================================================== 247# ========================================================================
225 248
249# check if our PHP was compiled with ZTS (Zend Thread Safety)
250
226has_zts() 251has_zts()
227{ 252{
228 has_php 253 has_php
229 254
230 if built_with_use =${PHP_PKG} apache2 threads ; then 255 if built_with_use =${PHP_PKG} apache2 threads ; then
232 fi 257 fi
233 258
234 return 1 259 return 1
235} 260}
236 261
262# check if our PHP was built with Hardened-PHP active
263
264has_hardenedphp()
265{
266 has_php
267
268 if built_with_use =${PHP_PKG} hardenedphp ; then
269 return 0
270 fi
271
272 return 1
273}
274
237# ======================================================================== 275# ========================================================================
238# require_*() functions 276# require_*() functions
239# 277#
240# These functions die() if PHP was built without the required USE flag(s) 278# These functions die() if PHP was built without the required USE flag(s)
241# ======================================================================== 279# ========================================================================
280
281# require a PHP built with PDO support for PHP5
242 282
243require_pdo() 283require_pdo()
244{ 284{
245 has_php 285 has_php
246 286
247 # do we have php5.1 installed? 287 # do we have php5.1 installed?
248 288
249 if [[ ${PHP_VERSION} == 4 ]] ; then 289 if [[ ${PHP_VERSION} == 4 ]] ; then
250 eerror 290 eerror
291 eerror "This package requires PDO."
251 eerror "This package requires PDO. PDO is only available for PHP 5." 292 eerror "PDO is only available for PHP 5."
252 eerror "Please install dev-lang/php-5*" 293 eerror "Please install dev-lang/php-5*"
253 eerror 294 eerror
254 die "PHP 5 not installed" 295 die "PHP 5 not installed"
255 fi 296 fi
256 297
264 305
265 if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then 306 if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then
266 return 307 return
267 fi 308 fi
268 309
269 # it suffices that pecl-pdo was installed to have PDO support 310 # ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
270 311
271 if has_version dev-php5/pecl-pdo ; then 312 if has_version dev-php5/pecl-pdo ; then
272 return 313 return
273 fi 314 fi
274 315
275 # if we get here, then we have no PDO support :( 316 # if we get here, then we have no PDO support
276 317
277 eerror 318 eerror
278 eerror "No PDO extension for PHP found." 319 eerror "No PDO extension for PHP found."
279 eerror "Please note that PDO only exists for PHP 5." 320 eerror "Please note that PDO only exists for PHP 5."
280 eerror "Please install a PDO extension for PHP 5," 321 eerror "Please install a PDO extension for PHP 5,"
282 eerror "the 'pdo-external' USE flag or you must" 323 eerror "the 'pdo-external' USE flag or you must"
283 eerror "install dev-lang/php-5.1* with either" 324 eerror "install dev-lang/php-5.1* with either"
284 eerror "the 'pdo' or the 'pdo-external' USE flags" 325 eerror "the 'pdo' or the 'pdo-external' USE flags"
285 eerror "turned on." 326 eerror "turned on."
286 eerror 327 eerror
287 die "No PDO extension found for PHP" 328 die "No PDO extension found for PHP 5"
288} 329}
289 330
290# determines which installed PHP version has the CLI sapi 331# determines which installed PHP version has the CLI sapi
291# useful for PEAR eclass, or anything which needs to run PHP 332# useful for PEAR eclass, or anything which needs to run PHP
292# scripts 333# scripts depending on the cli sapi
293 334
294require_php_cli() 335require_php_cli()
295{ 336{
296 # if PHP_PKG is set, then we have remembered our PHP settings 337 # if PHP_PKG is set, then we have remembered our PHP settings
297 # from last time 338 # from last time
339
298 if [[ -n ${PHP_PKG} ]]; then 340 if [[ -n ${PHP_PKG} ]]; then
299 return 341 return
300 fi 342 fi
301 343
302 # detect which PHP version installed 344 # detect which PHP version installed
345 if has_version '=dev-lang/php-4*' ; then
346 PHP_PACKAGE_FOUND=1
347 pkg="`best_version '=dev-lang/php-4*'`"
348 if built_with_use =${pkg} cli ; then
349 PHP_VERSION=4
350 fi
351 fi
352
303 if has_version '=dev-lang/php-5*' ; then 353 if has_version '=dev-lang/php-5*' ; then
354 PHP_PACKAGE_FOUND=1
304 pkg="`best_version '=dev-lang/php-5*'`" 355 pkg="`best_version '=dev-lang/php-5*'`"
305 if built_with_use =${pkg} cli ; then 356 if built_with_use =${pkg} cli ; then
306 PHP_VERSION=5 357 PHP_VERSION=5
307 fi 358 fi
308 elif has_version '=dev-lang/php-4*' ; then
309 pkg="`best_version '=dev-lang/php-4*'`"
310 if built_with_use =${pkg} cli ; then
311 PHP_VERSION=4
312 fi 359 fi
313 else 360
361 if [[ -z ${PHP_PACKAGE_FOUND} ]]; then
314 die "Unable to find an installed dev-lang/php package" 362 die "Unable to find an installed dev-lang/php package"
315 fi 363 fi
316 364
317 if [[ -z ${PHP_VERSION} ]]; then 365 if [[ -z ${PHP_VERSION} ]]; then
318 die "No PHP CLI installed" 366 die "No PHP CLI installed"
319 fi 367 fi
320 368
321 # if we get here, then PHP_VERSION tells us which version of PHP we 369 # if we get here, then PHP_VERSION tells us which version of PHP we
322 # want to use 370 # want to use
371
323 uses_php${PHP_VERSION} 372 uses_php${PHP_VERSION}
324} 373}
325 374
375# determines which installed PHP version has the CGI sapi
376# useful for anything which needs to run PHP scripts
377# depending on the cgi sapi
378
379require_php_cgi()
380{
381 # if PHP_PKG is set, then we have remembered our PHP settings
382 # from last time
383
384 if [[ -n ${PHP_PKG} ]]; then
385 return
386 fi
387
388 # detect which PHP version installed
389 if has_version '=dev-lang/php-4*' ; then
390 PHP_PACKAGE_FOUND=1
391 pkg="`best_version '=dev-lang/php-4*'`"
392 if built_with_use =${pkg} cgi ; then
393 PHP_VERSION=4
394 fi
395 fi
396
397 if has_version '=dev-lang/php-5*' ; then
398 PHP_PACKAGE_FOUND=1
399 pkg="`best_version '=dev-lang/php-5*'`"
400 if built_with_use =${pkg} cgi ; then
401 PHP_VERSION=5
402 fi
403 fi
404
405 if [[ -z ${PHP_PACKAGE_FOUND} ]]; then
406 die "Unable to find an installed dev-lang/php package"
407 fi
408
409 if [[ -z ${PHP_VERSION} ]]; then
410 die "No PHP CGI installed"
411 fi
412
413 # if we get here, then PHP_VERSION tells us which version of PHP we
414 # want to use
415
416 uses_php${PHP_VERSION}
417}
418
326# require a PHP built with sqlite support 419# require a PHP built with sqlite support
327 420
328require_sqlite() 421require_sqlite()
329{ 422{
330 has_php 423 has_php
331 424
332 # has our PHP been built w/ sqlite? 425 # has our PHP been built with sqlite?
426
333 if built_with_use =${PHP_PKG} sqlite ; then 427 if built_with_use =${PHP_PKG} sqlite ; then
334 return 428 return
335 fi 429 fi
336 430
337 # do we have pecl-sqlite installed for PHP4? 431 # do we have pecl-sqlite installed for PHP 4?
432
338 if [[ ${PHP_VERSION} == 4 ]] ; then 433 if [[ ${PHP_VERSION} == 4 ]] ; then
339 if has_version dev-php4/pecl-sqlite ; then 434 if has_version dev-php4/pecl-sqlite ; then
340 return 435 return
341 fi 436 fi
342 fi 437 fi
343 438
344 # if we get here, then we don't have any php/sqlite support installed 439 # if we get here, then we don't have any sqlite support for PHP installed
440
345 eerror 441 eerror
346 eerror "No sqlite extension for PHP found." 442 eerror "No sqlite extension for PHP found."
347 eerror "Please install an sqlite extension for PHP," 443 eerror "Please install an sqlite extension for PHP,"
348 eerror "this is done best by simply adding the" 444 eerror "this is done best by simply adding the"
349 eerror "'sqlite' USE flag when emerging dev-lang/php." 445 eerror "'sqlite' USE flag when emerging dev-lang/php."
350 eerror 446 eerror
351 die "No sqlite extension for PHP found" 447 die "No sqlite extension for PHP found"
352} 448}
449
450# require a PHP built with GD support
451
452require_gd()
453{
454 has_php
455
456 # do we have the internal GD support installed?
457
458 if built_with_use =${PHP_PKG} gd ; then
459 return
460 fi
461
462 # ok, maybe GD was built using the external support?
463
464 if built_with_use =${PHP_PKG} gd-external ; then
465 return
466 fi
467
468 # if we get here, then we have no GD support
469
470 eerror
471 eerror "No GD support for PHP found."
472 eerror "Please install the GD support for PHP,"
473 eerror "you must install dev-lang/php with either"
474 eerror "the 'gd' or the 'gd-external' USE flags"
475 eerror "turned on."
476 eerror
477 die "No GD support found for PHP"
478}
479
480# ========================================================================
481# Misc functions
482#
483# These functions provide miscellaneous checks and functionality.
484# ========================================================================
485
486# executes some checks needed when installing a binary PHP extension
487
488php_binary_extension() {
489 has_php
490
491 # binary extensions do not support the change of PHP
492 # API version, so they can't be installed when USE flags
493 # are enabled wich change the PHP API version
494
495 if built_with_use =${PHP_PKG} hardenedphp ; then
496 eerror
497 eerror "You cannot install binary PHP extensions"
498 eerror "when the 'hardenedphp' USE flag is enabled!"
499 eerror "Please reemerge dev-lang/php with the"
500 eerror "'hardenedphp' USE flag turned off."
501 eerror
502 die "'hardenedphp' USE flag turned on"
503 fi
504
505 if built_with_use =${PHP_PKG} debug ; then
506 eerror
507 eerror "You cannot install binary PHP extensions"
508 eerror "when the 'debug' USE flag is enabled!"
509 eerror "Please reemerge dev-lang/php with the"
510 eerror "'debug' USE flag turned off."
511 eerror
512 die "'debug' USE flag turned on"
513 fi
514}
515
516# alternative to dodoc for use in our php eclasses and ebuilds
517# stored here because depend.php gets always sourced everywhere
518# in the PHP ebuilds and eclasses
519# it simply is dodoc with a changed path to the docs
520# no support for docinto is given!
521
522dodoc-php()
523{
524if [ $# -lt 1 ] ; then
525 echo "$0: at least one argument needed" 1>&2
526 exit 1
527fi
528
529phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/"
530
531if [ ! -d "${phpdocdir}" ] ; then
532 install -d "${phpdocdir}"
533fi
534
535for x in "$@" ; do
536 if [ -s "${x}" ] ; then
537 install -m0644 "${x}" "${phpdocdir}"
538 gzip -f -9 "${phpdocdir}/${x##*/}"
539 elif [ ! -e "${x}" ] ; then
540 echo "dodoc-php: ${x} does not exist" 1>&2
541 fi
542done
543}

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20