/[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.7
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.7 2005/11/20 01:35:05 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
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 pkg="`best_version '=dev-lang/php-4*'`"
385 if built_with_use =${pkg} cgi ; then
386 PHP_VERSION=4
387 fi
388 elif has_version '=dev-lang/php-5*' ; then
389 pkg="`best_version '=dev-lang/php-5*'`"
390 if built_with_use =${pkg} cgi ; then
391 PHP_VERSION=5
392 fi
393 else
394 die "Unable to find an installed dev-lang/php package"
395 fi
396
397 if [[ -z ${PHP_VERSION} ]]; then
398 die "No PHP CGI installed"
399 fi
400
401 # if we get here, then PHP_VERSION tells us which version of PHP we
402 # want to use
403
404 uses_php${PHP_VERSION}
405}
406
326# require a PHP built with sqlite support 407# require a PHP built with sqlite support
327 408
328require_sqlite() 409require_sqlite()
329{ 410{
330 has_php 411 has_php
331 412
332 # has our PHP been built w/ sqlite? 413 # has our PHP been built with sqlite?
414
333 if built_with_use =${PHP_PKG} sqlite ; then 415 if built_with_use =${PHP_PKG} sqlite ; then
334 return 416 return
335 fi 417 fi
336 418
337 # do we have pecl-sqlite installed for PHP4? 419 # do we have pecl-sqlite installed for PHP 4?
420
338 if [[ ${PHP_VERSION} == 4 ]] ; then 421 if [[ ${PHP_VERSION} == 4 ]] ; then
339 if has_version dev-php4/pecl-sqlite ; then 422 if has_version dev-php4/pecl-sqlite ; then
340 return 423 return
341 fi 424 fi
342 fi 425 fi
343 426
344 # if we get here, then we don't have any php/sqlite support installed 427 # if we get here, then we don't have any sqlite support for PHP installed
428
345 eerror 429 eerror
346 eerror "No sqlite extension for PHP found." 430 eerror "No sqlite extension for PHP found."
347 eerror "Please install an sqlite extension for PHP," 431 eerror "Please install an sqlite extension for PHP,"
348 eerror "this is done best by simply adding the" 432 eerror "this is done best by simply adding the"
349 eerror "'sqlite' USE flag when emerging dev-lang/php." 433 eerror "'sqlite' USE flag when emerging dev-lang/php."
350 eerror 434 eerror
351 die "No sqlite extension for PHP found" 435 die "No sqlite extension for PHP found"
352} 436}
437
438# require a PHP built with GD support
439
440require_gd()
441{
442 has_php
443
444 # do we have the internal GD support installed?
445
446 if built_with_use =${PHP_PKG} gd ; then
447 return
448 fi
449
450 # ok, maybe GD was built using the external support?
451
452 if built_with_use =${PHP_PKG} gd-external ; then
453 return
454 fi
455
456 # if we get here, then we have no GD support
457
458 eerror
459 eerror "No GD support for PHP found."
460 eerror "Please install the GD support for PHP,"
461 eerror "you must install dev-lang/php with either"
462 eerror "the 'gd' or the 'gd-external' USE flags"
463 eerror "turned on."
464 eerror
465 die "No GD support found for PHP"
466}
467
468# ========================================================================
469# Misc functions
470#
471# These functions provide miscellaneous checks and functionality.
472# ========================================================================
473
474# executes some checks needed when installing a binary PHP extension
475
476php_binary_extension() {
477 has_php
478
479 # binary extensions do not support the change of PHP
480 # API version, so they can't be installed when USE flags
481 # are enabled wich change the PHP API version
482
483 if built_with_use =${PHP_PKG} hardenedphp ; then
484 eerror
485 eerror "You cannot install binary PHP extensions"
486 eerror "when the 'hardenedphp' USE flag is enabled!"
487 eerror "Please reemerge dev-lang/php with the"
488 eerror "'hardenedphp' USE flag turned off."
489 eerror
490 die "'hardenedphp' USE flag turned on"
491 fi
492
493 if built_with_use =${PHP_PKG} debug ; then
494 eerror
495 eerror "You cannot install binary PHP extensions"
496 eerror "when the 'debug' USE flag is enabled!"
497 eerror "Please reemerge dev-lang/php with the"
498 eerror "'debug' USE flag turned off."
499 eerror
500 die "'debug' USE flag turned on"
501 fi
502}
503
504# alternative to dodoc for use in our php eclasses and ebuilds
505# stored here because depend.php gets always sourced everywhere
506# in the PHP ebuilds and eclasses
507# it simply is dodoc with a changed path to the docs
508# no support for docinto is given!
509
510dodoc-php()
511{
512if [ $# -lt 1 ] ; then
513 echo "$0: at least one argument needed" 1>&2
514 exit 1
515fi
516
517phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/"
518
519if [ ! -d "${phpdocdir}" ] ; then
520 install -d "${phpdocdir}"
521fi
522
523for x in "$@" ; do
524 if [ -s "${x}" ] ; then
525 install -m0644 "${x}" "${phpdocdir}"
526 gzip -f -9 "${phpdocdir}/${x##*/}"
527 elif [ ! -e "${x}" ] ; then
528 echo "dodoc-php: ${x} does not exist" 1>&2
529 fi
530done
531}

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

  ViewVC Help
Powered by ViewVC 1.1.20