/[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.4 Revision 1.11
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.4 2005/09/16 20:25:21 trapni Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.11 2006/01/21 11:48:29 chtekk 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
131# 136#
132# this function will disappear when USE-based deps are supported by 137# this function will disappear when USE-based deps are supported by
133# Portage 138# Portage
134# 139#
135# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2) 140# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2)
136# 141#
137# returns if any one of the listed SAPIs has been installed 142# returns if any one of the listed SAPIs has been installed
138# dies if none of the listed SAPIs has been installed 143# dies if none of the listed SAPIs has been installed
139 144
140require_php_sapi_from() 145require_php_sapi_from()
141{ 146{
171# 176#
172# this function will disappear when USE-based deps are supported by 177# this function will disappear when USE-based deps are supported by
173# Portage 178# Portage
174# 179#
175# $1 ... a list of USE flags 180# $1 ... a list of USE flags
176# 181#
177# returns if all of the listed USE flags are set 182# returns if all of the listed USE flags are set
178# dies if any of the listed USE flags are not set 183# dies if any of the listed USE flags are not set
179 184
180require_php_with_use() 185require_php_with_use()
181{ 186{
182 has_php 187 has_php
183 188
184 local missing_use= 189 local missing_use=""
185 local x 190 local x
186 191
187 einfo "Checking for required PHP feature(s):" 192 einfo "Checking for required PHP feature(s):"
188 193
189 for x in $@ ; do 194 for x in $@ ; do
191 einfo " Discovered missing USE flag ${x}" 196 einfo " Discovered missing USE flag ${x}"
192 missing_use="${missing_use} ${x}" 197 missing_use="${missing_use} ${x}"
193 fi 198 fi
194 done 199 done
195 200
196 if [[ -z ${missing_use} ]]; then 201 if [[ -z ${missing_use} ]] ; then
197 return 202 return
198 fi 203 fi
199 204
200 eerror 205 eerror
201 eerror "${PHP_PKG} needs to be re-installed with all of the following" 206 eerror "${PHP_PKG} needs to be re-installed with all of the following"
212has_php() 217has_php()
213{ 218{
214 # 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
215 # from last time 220 # from last time
216 221
217 if [[ -n ${PHP_PKG} ]]; then 222 if [[ -n ${PHP_PKG} ]] ; then
218 return 223 return
219 fi 224 fi
220 225
221 if [[ -z ${PHP_VERSION} ]]; then 226 if [[ -z ${PHP_VERSION} ]] ; then
222 # detect which PHP version installed 227 # detect which PHP version installed
223 if has_version '=dev-lang/php-5*' ; then 228 if has_version '=dev-lang/php-5*' ; then
224 PHP_VERSION=5 229 PHP_VERSION=5
225 elif has_version '=dev-lang/php-4*' ; then 230 elif has_version '=dev-lang/php-4*' ; then
226 PHP_VERSION=4 231 PHP_VERSION=4
277 282
278require_pdo() 283require_pdo()
279{ 284{
280 has_php 285 has_php
281 286
282 # do we have php5.1 installed? 287 # do we have php5 installed?
283 288
284 if [[ ${PHP_VERSION} == 4 ]] ; then 289 if [[ ${PHP_VERSION} == 4 ]] ; then
285 eerror 290 eerror
286 eerror "This package requires PDO." 291 eerror "This package requires PDO."
287 eerror "PDO is only available for PHP 5." 292 eerror "PDO is only available for PHP 5."
288 eerror "Please install dev-lang/php-5*" 293 eerror "You must install =dev-lang/php-5.0* with"
294 eerror "the 'pdo-external' USE flag or you must"
295 eerror "install >=dev-lang/php-5.1 with either"
296 eerror "the 'pdo' or the 'pdo-external' USE flags"
297 eerror "turned on."
289 eerror 298 eerror
290 die "PHP 5 not installed" 299 die "PHP 5 not installed"
291 fi 300 fi
292 301
293 # was php5 compiled w/ pdo support? 302 # was php5 compiled w/ pdo support?
312 321
313 eerror 322 eerror
314 eerror "No PDO extension for PHP found." 323 eerror "No PDO extension for PHP found."
315 eerror "Please note that PDO only exists for PHP 5." 324 eerror "Please note that PDO only exists for PHP 5."
316 eerror "Please install a PDO extension for PHP 5," 325 eerror "Please install a PDO extension for PHP 5,"
317 eerror "you must install dev-lang/php-5.0* with" 326 eerror "you must install =dev-lang/php-5.0* with"
318 eerror "the 'pdo-external' USE flag or you must" 327 eerror "the 'pdo-external' USE flag or you must"
319 eerror "install dev-lang/php-5.1* with either" 328 eerror "install >=dev-lang/php-5.1 with either"
320 eerror "the 'pdo' or the 'pdo-external' USE flags" 329 eerror "the 'pdo' or the 'pdo-external' USE flags"
321 eerror "turned on." 330 eerror "turned on."
322 eerror 331 eerror
323 die "No PDO extension found for PHP 5" 332 die "No PDO extension found for PHP 5"
324} 333}
330require_php_cli() 339require_php_cli()
331{ 340{
332 # if PHP_PKG is set, then we have remembered our PHP settings 341 # if PHP_PKG is set, then we have remembered our PHP settings
333 # from last time 342 # from last time
334 343
335 if [[ -n ${PHP_PKG} ]]; then 344 if [[ -n ${PHP_PKG} ]] ; then
336 return 345 return
337 fi 346 fi
338 347
339 # detect which PHP version installed 348 # detect which PHP version installed
349 if has_version '=dev-lang/php-4*' ; then
350 PHP_PACKAGE_FOUND=1
351 pkg="`best_version '=dev-lang/php-4*'`"
352 if built_with_use =${pkg} cli ; then
353 PHP_VERSION=4
354 fi
355 fi
356
340 if has_version '=dev-lang/php-5*' ; then 357 if has_version '=dev-lang/php-5*' ; then
358 PHP_PACKAGE_FOUND=1
341 pkg="`best_version '=dev-lang/php-5*'`" 359 pkg="`best_version '=dev-lang/php-5*'`"
342 if built_with_use =${pkg} cli ; then 360 if built_with_use =${pkg} cli ; then
343 PHP_VERSION=5 361 PHP_VERSION=5
344 fi 362 fi
345 elif has_version '=dev-lang/php-4*' ; then
346 pkg="`best_version '=dev-lang/php-4*'`"
347 if built_with_use =${pkg} cli ; then
348 PHP_VERSION=4
349 fi 363 fi
350 else 364
365 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
351 die "Unable to find an installed dev-lang/php package" 366 die "Unable to find an installed dev-lang/php package"
352 fi 367 fi
353 368
354 if [[ -z ${PHP_VERSION} ]]; then 369 if [[ -z ${PHP_VERSION} ]] ; then
355 die "No PHP CLI installed" 370 die "No PHP CLI installed"
356 fi 371 fi
357 372
358 # if we get here, then PHP_VERSION tells us which version of PHP we 373 # if we get here, then PHP_VERSION tells us which version of PHP we
359 # want to use 374 # want to use
368require_php_cgi() 383require_php_cgi()
369{ 384{
370 # if PHP_PKG is set, then we have remembered our PHP settings 385 # if PHP_PKG is set, then we have remembered our PHP settings
371 # from last time 386 # from last time
372 387
373 if [[ -n ${PHP_PKG} ]]; then 388 if [[ -n ${PHP_PKG} ]] ; then
374 return 389 return
375 fi 390 fi
376 391
377 # detect which PHP version installed 392 # detect which PHP version installed
393 if has_version '=dev-lang/php-4*' ; then
394 PHP_PACKAGE_FOUND=1
395 pkg="`best_version '=dev-lang/php-4*'`"
396 if built_with_use =${pkg} cgi ; then
397 PHP_VERSION=4
398 fi
399 fi
400
378 if has_version '=dev-lang/php-5*' ; then 401 if has_version '=dev-lang/php-5*' ; then
402 PHP_PACKAGE_FOUND=1
379 pkg="`best_version '=dev-lang/php-5*'`" 403 pkg="`best_version '=dev-lang/php-5*'`"
380 if built_with_use =${pkg} cgi ; then 404 if built_with_use =${pkg} cgi ; then
381 PHP_VERSION=5 405 PHP_VERSION=5
382 fi 406 fi
383 elif has_version '=dev-lang/php-4*' ; then
384 pkg="`best_version '=dev-lang/php-4*'`"
385 if built_with_use =${pkg} cgi ; then
386 PHP_VERSION=4
387 fi 407 fi
388 else 408
409 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
389 die "Unable to find an installed dev-lang/php package" 410 die "Unable to find an installed dev-lang/php package"
390 fi 411 fi
391 412
392 if [[ -z ${PHP_VERSION} ]]; then 413 if [[ -z ${PHP_VERSION} ]] ; then
393 die "No PHP CGI installed" 414 die "No PHP CGI installed"
394 fi 415 fi
395 416
396 # if we get here, then PHP_VERSION tells us which version of PHP we 417 # if we get here, then PHP_VERSION tells us which version of PHP we
397 # want to use 418 # want to use
427 eerror "this is done best by simply adding the" 448 eerror "this is done best by simply adding the"
428 eerror "'sqlite' USE flag when emerging dev-lang/php." 449 eerror "'sqlite' USE flag when emerging dev-lang/php."
429 eerror 450 eerror
430 die "No sqlite extension for PHP found" 451 die "No sqlite extension for PHP found"
431} 452}
453
454# require a PHP built with GD support
432 455
433require_gd() 456require_gd()
434{ 457{
435 has_php 458 has_php
436 459
455 eerror "the 'gd' or the 'gd-external' USE flags" 478 eerror "the 'gd' or the 'gd-external' USE flags"
456 eerror "turned on." 479 eerror "turned on."
457 eerror 480 eerror
458 die "No GD support found for PHP" 481 die "No GD support found for PHP"
459} 482}
483
484# ========================================================================
485# Misc functions
486#
487# These functions provide miscellaneous checks and functionality.
488# ========================================================================
489
490# executes some checks needed when installing a binary PHP extension
491
492php_binary_extension() {
493 has_php
494
495 # binary extensions do not support the change of PHP
496 # API version, so they can't be installed when USE flags
497 # are enabled wich change the PHP API version
498
499 if built_with_use =${PHP_PKG} hardenedphp ; then
500 eerror
501 eerror "You cannot install binary PHP extensions"
502 eerror "when the 'hardenedphp' USE flag is enabled!"
503 eerror "Please reemerge dev-lang/php with the"
504 eerror "'hardenedphp' USE flag turned off."
505 eerror
506 die "'hardenedphp' USE flag turned on"
507 fi
508
509 if built_with_use =${PHP_PKG} debug ; then
510 eerror
511 eerror "You cannot install binary PHP extensions"
512 eerror "when the 'debug' USE flag is enabled!"
513 eerror "Please reemerge dev-lang/php with the"
514 eerror "'debug' USE flag turned off."
515 eerror
516 die "'debug' USE flag turned on"
517 fi
518}
519
520# alternative to dodoc for use in our php eclasses and ebuilds
521# stored here because depend.php gets always sourced everywhere
522# in the PHP ebuilds and eclasses
523# it simply is dodoc with a changed path to the docs
524# no support for docinto is given!
525
526dodoc-php()
527{
528if [ $# -lt 1 ] ; then
529 echo "$0: at least one argument needed" 1>&2
530 exit 1
531fi
532
533phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/"
534
535if [ ! -d "${phpdocdir}" ] ; then
536 install -d "${phpdocdir}"
537fi
538
539for x in "$@" ; do
540 if [ -s "${x}" ] ; then
541 install -m0644 "${x}" "${phpdocdir}"
542 gzip -f -9 "${phpdocdir}/${x##*/}"
543 elif [ ! -e "${x}" ] ; then
544 echo "dodoc-php: ${x} does not exist" 1>&2
545 fi
546done
547}

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20