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

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

  ViewVC Help
Powered by ViewVC 1.1.20