/[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.1 Revision 1.9
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.1 2005/09/04 10:54:53 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.9 2006/01/21 09:02:44 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"
116# 136#
117# this function will disappear when USE-based deps are supported by 137# this function will disappear when USE-based deps are supported by
118# Portage 138# Portage
119# 139#
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
155# 176#
156# this function will disappear when USE-based deps are supported by 177# this function will disappear when USE-based deps are supported by
157# Portage 178# Portage
158# 179#
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 pkg="`best_version '=dev-lang/php-4*'`"
347 if built_with_use =${pkg} cli ; then
348 PHP_VERSION=4
349 fi
303 if has_version '=dev-lang/php-5*' ; then 350 elif has_version '=dev-lang/php-5*' ; then
304 pkg="`best_version '=dev-lang/php-5*'`" 351 pkg="`best_version '=dev-lang/php-5*'`"
305 if built_with_use =${pkg} cli ; then 352 if built_with_use =${pkg} cli ; then
306 PHP_VERSION=5 353 PHP_VERSION=5
307 fi 354 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
313 else 355 else
314 die "Unable to find an installed dev-lang/php package" 356 die "Unable to find an installed dev-lang/php package"
315 fi 357 fi
316 358
317 if [[ -z ${PHP_VERSION} ]]; then 359 if [[ -z ${PHP_VERSION} ]]; then
318 die "No PHP CLI installed" 360 die "No PHP CLI installed"
319 fi 361 fi
320 362
321 # if we get here, then PHP_VERSION tells us which version of PHP we 363 # if we get here, then PHP_VERSION tells us which version of PHP we
322 # want to use 364 # want to use
365
323 uses_php${PHP_VERSION} 366 uses_php${PHP_VERSION}
324} 367}
325 368
369# determines which installed PHP version has the CGI sapi
370# useful for anything which needs to run PHP scripts
371# depending on the cgi sapi
372
373require_php_cgi()
374{
375 # if PHP_PKG is set, then we have remembered our PHP settings
376 # from last time
377
378 if [[ -n ${PHP_PKG} ]]; then
379 return
380 fi
381
382 # detect which PHP version installed
383 if has_version '=dev-lang/php-4*' ; then
384 PHP_PACKAGE_FOUND=1
385 pkg="`best_version '=dev-lang/php-4*'`"
386 if built_with_use =${pkg} cgi ; then
387 PHP_VERSION=4
388 fi
389 fi
390
391 if has_version '=dev-lang/php-5*' ; then
392 PHP_PACKAGE_FOUND=1
393 pkg="`best_version '=dev-lang/php-5*'`"
394 if built_with_use =${pkg} cgi ; then
395 PHP_VERSION=5
396 fi
397 fi
398
399 if [[ -z ${PHP_PACKAGE_FOUND} ]]; then
400 die "Unable to find an installed dev-lang/php package"
401 fi
402
403 if [[ -z ${PHP_VERSION} ]]; then
404 die "No PHP CGI installed"
405 fi
406
407 # if we get here, then PHP_VERSION tells us which version of PHP we
408 # want to use
409
410 uses_php${PHP_VERSION}
411}
412
326# require a PHP built with sqlite support 413# require a PHP built with sqlite support
327 414
328require_sqlite() 415require_sqlite()
329{ 416{
330 has_php 417 has_php
331 418
332 # has our PHP been built w/ sqlite? 419 # has our PHP been built with sqlite?
420
333 if built_with_use =${PHP_PKG} sqlite ; then 421 if built_with_use =${PHP_PKG} sqlite ; then
334 return 422 return
335 fi 423 fi
336 424
337 # do we have pecl-sqlite installed for PHP4? 425 # do we have pecl-sqlite installed for PHP 4?
426
338 if [[ ${PHP_VERSION} == 4 ]] ; then 427 if [[ ${PHP_VERSION} == 4 ]] ; then
339 if has_version dev-php4/pecl-sqlite ; then 428 if has_version dev-php4/pecl-sqlite ; then
340 return 429 return
341 fi 430 fi
342 fi 431 fi
343 432
344 # if we get here, then we don't have any php/sqlite support installed 433 # if we get here, then we don't have any sqlite support for PHP installed
434
345 eerror 435 eerror
346 eerror "No sqlite extension for PHP found." 436 eerror "No sqlite extension for PHP found."
347 eerror "Please install an sqlite extension for PHP," 437 eerror "Please install an sqlite extension for PHP,"
348 eerror "this is done best by simply adding the" 438 eerror "this is done best by simply adding the"
349 eerror "'sqlite' USE flag when emerging dev-lang/php." 439 eerror "'sqlite' USE flag when emerging dev-lang/php."
350 eerror 440 eerror
351 die "No sqlite extension for PHP found" 441 die "No sqlite extension for PHP found"
352} 442}
443
444# require a PHP built with GD support
445
446require_gd()
447{
448 has_php
449
450 # do we have the internal GD support installed?
451
452 if built_with_use =${PHP_PKG} gd ; then
453 return
454 fi
455
456 # ok, maybe GD was built using the external support?
457
458 if built_with_use =${PHP_PKG} gd-external ; then
459 return
460 fi
461
462 # if we get here, then we have no GD support
463
464 eerror
465 eerror "No GD support for PHP found."
466 eerror "Please install the GD support for PHP,"
467 eerror "you must install dev-lang/php with either"
468 eerror "the 'gd' or the 'gd-external' USE flags"
469 eerror "turned on."
470 eerror
471 die "No GD support found for PHP"
472}
473
474# ========================================================================
475# Misc functions
476#
477# These functions provide miscellaneous checks and functionality.
478# ========================================================================
479
480# executes some checks needed when installing a binary PHP extension
481
482php_binary_extension() {
483 has_php
484
485 # binary extensions do not support the change of PHP
486 # API version, so they can't be installed when USE flags
487 # are enabled wich change the PHP API version
488
489 if built_with_use =${PHP_PKG} hardenedphp ; then
490 eerror
491 eerror "You cannot install binary PHP extensions"
492 eerror "when the 'hardenedphp' USE flag is enabled!"
493 eerror "Please reemerge dev-lang/php with the"
494 eerror "'hardenedphp' USE flag turned off."
495 eerror
496 die "'hardenedphp' USE flag turned on"
497 fi
498
499 if built_with_use =${PHP_PKG} debug ; then
500 eerror
501 eerror "You cannot install binary PHP extensions"
502 eerror "when the 'debug' USE flag is enabled!"
503 eerror "Please reemerge dev-lang/php with the"
504 eerror "'debug' USE flag turned off."
505 eerror
506 die "'debug' USE flag turned on"
507 fi
508}
509
510# alternative to dodoc for use in our php eclasses and ebuilds
511# stored here because depend.php gets always sourced everywhere
512# in the PHP ebuilds and eclasses
513# it simply is dodoc with a changed path to the docs
514# no support for docinto is given!
515
516dodoc-php()
517{
518if [ $# -lt 1 ] ; then
519 echo "$0: at least one argument needed" 1>&2
520 exit 1
521fi
522
523phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/"
524
525if [ ! -d "${phpdocdir}" ] ; then
526 install -d "${phpdocdir}"
527fi
528
529for x in "$@" ; do
530 if [ -s "${x}" ] ; then
531 install -m0644 "${x}" "${phpdocdir}"
532 gzip -f -9 "${phpdocdir}/${x##*/}"
533 elif [ ! -e "${x}" ] ; then
534 echo "dodoc-php: ${x} does not exist" 1>&2
535 fi
536done
537}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20