/[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.1.1 Revision 1.2
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.1.1 2005/11/30 09:59:31 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.2 2005/09/04 15:15:37 swegener 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>
17# 12#
18# ======================================================================== 13# ========================================================================
19 14
20inherit eutils 15inherit eutils
21 16
22# PHP4-only depend functions
23need_php4_cli() 17need_php4_cli()
24{ 18{
25 DEPEND="${DEPEND} =virtual/php-4*" 19 DEPEND="${DEPEND} =virtual/php-4*"
26 RDEPEND="${RDEPEND} =virtual/php-4*" 20 RDEPEND="${RDEPEND} =virtual/php-4*"
27 PHP_VERSION=4 21 PHP_VERSION=4
58 einfo 52 einfo
59 einfo "Using ${PHP_PKG}" 53 einfo "Using ${PHP_PKG}"
60 einfo 54 einfo
61} 55}
62 56
63# PHP5-only depend functions
64need_php5_cli() 57need_php5_cli()
65{ 58{
66 DEPEND="${DEPEND} =virtual/php-5*" 59 DEPEND="${DEPEND} =virtual/php-5*"
67 RDEPEND="${RDEPEND} =virtual/php-5*" 60 RDEPEND="${RDEPEND} =virtual/php-5*"
68 PHP_VERSION=5 61 PHP_VERSION=5
99 einfo 92 einfo
100 einfo "Using ${PHP_PKG}" 93 einfo "Using ${PHP_PKG}"
101 einfo 94 einfo
102} 95}
103 96
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
117need_php() 97need_php()
118{ 98{
119 DEPEND="${DEPEND} dev-lang/php" 99 DEPEND="${DEPEND} dev-lang/php"
120 RDEPEND="${RDEPEND} dev-lang/php" 100 RDEPEND="${RDEPEND} dev-lang/php"
121 PHP_SHARED_CAT="php" 101 PHP_SHARED_CAT="php"
136# 116#
137# this function will disappear when USE-based deps are supported by 117# this function will disappear when USE-based deps are supported by
138# Portage 118# Portage
139# 119#
140# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2) 120# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2)
141# 121#
142# returns if any one of the listed SAPIs has been installed 122# returns if any one of the listed SAPIs has been installed
143# dies if none of the listed SAPIs has been installed 123# dies if none of the listed SAPIs has been installed
144 124
145require_php_sapi_from() 125require_php_sapi_from() {
146{
147 has_php 126 has_php
148 127
149 local has_sapi=0 128 local has_sapi=0
150 local x 129 local x
151 130
176# 155#
177# this function will disappear when USE-based deps are supported by 156# this function will disappear when USE-based deps are supported by
178# Portage 157# Portage
179# 158#
180# $1 ... a list of USE flags 159# $1 ... a list of USE flags
181# 160#
182# returns if all of the listed USE flags are set 161# returns if all of the listed USE flags are set
183# dies if any of the listed USE flags are not set 162# dies if any of the listed USE flags are not set
184 163
185require_php_with_use() 164require_php_with_use() {
186{
187 has_php 165 has_php
188 166
189 local missing_use= 167 local missing_use=
190 local x 168 local x
191 169
209 eerror " $@" 187 eerror " $@"
210 eerror 188 eerror
211 die "Re-install ${PHP_PKG}" 189 die "Re-install ${PHP_PKG}"
212} 190}
213 191
214# call this function from your pkg_setup, src_compile & src_install methods 192# call this function from your src_compile & src_install methods
215# if you need to know where the PHP binaries are installed and their data 193# if you need to know where the PHP binaries are installed
216 194
217has_php() 195has_php()
218{ 196{
219 # if PHP_PKG is set, then we have remembered our PHP settings 197 # if PHP_PKG is set, then we have remembered our PHP settings
220 # from last time 198 # from last time
221
222 if [[ -n ${PHP_PKG} ]]; then 199 if [[ -n ${PHP_PKG} ]]; then
223 return 200 return
224 fi 201 fi
225 202
226 if [[ -z ${PHP_VERSION} ]]; then 203 if [[ -z ${PHP_VERSION} ]]; then
227 # detect which PHP version installed 204 # detect which PHP version installed
205 if has_version '=dev-lang/php-5*' ; then
206 PHP_VERSION=5
228 if has_version '=dev-lang/php-4*' ; then 207 elif has_version '=dev-lang/php-4*' ; then
229 PHP_VERSION=4 208 PHP_VERSION=4
230 elif has_version '=dev-lang/php-5*' ; then
231 PHP_VERSION=5
232 else 209 else
233 die "Unable to find an installed dev-lang/php package" 210 die "Unable to find an installed dev-lang/php package"
234 fi 211 fi
235 fi 212 fi
236 213
244# has_*() functions 221# has_*() functions
245# 222#
246# these functions return 0 if the condition is satisfied, or 1 otherwise 223# these functions return 0 if the condition is satisfied, or 1 otherwise
247# ======================================================================== 224# ========================================================================
248 225
249# check if our PHP was compiled with ZTS (Zend Thread Safety)
250
251has_zts() 226has_zts()
252{ 227{
253 has_php 228 has_php
254 229
255 if built_with_use =${PHP_PKG} apache2 threads ; then 230 if built_with_use =${PHP_PKG} apache2 threads ; then
257 fi 232 fi
258 233
259 return 1 234 return 1
260} 235}
261 236
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
275# ======================================================================== 237# ========================================================================
276# require_*() functions 238# require_*() functions
277# 239#
278# These functions die() if PHP was built without the required USE flag(s) 240# These functions die() if PHP was built without the required USE flag(s)
279# ======================================================================== 241# ========================================================================
280
281# require a PHP built with PDO support for PHP5
282 242
283require_pdo() 243require_pdo()
284{ 244{
285 has_php 245 has_php
286 246
287 # do we have php5.1 installed? 247 # do we have php5.1 installed?
288 248
289 if [[ ${PHP_VERSION} == 4 ]] ; then 249 if [[ ${PHP_VERSION} == 4 ]] ; then
290 eerror 250 eerror
291 eerror "This package requires PDO."
292 eerror "PDO is only available for PHP 5." 251 eerror "This package requires PDO. PDO is only available for PHP 5."
293 eerror "Please install dev-lang/php-5*" 252 eerror "Please install dev-lang/php-5*"
294 eerror 253 eerror
295 die "PHP 5 not installed" 254 die "PHP 5 not installed"
296 fi 255 fi
297 256
305 264
306 if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then 265 if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then
307 return 266 return
308 fi 267 fi
309 268
310 # ok, as last resort, it suffices that pecl-pdo was installed to have PDO support 269 # it suffices that pecl-pdo was installed to have PDO support
311 270
312 if has_version dev-php5/pecl-pdo ; then 271 if has_version dev-php5/pecl-pdo ; then
313 return 272 return
314 fi 273 fi
315 274
316 # if we get here, then we have no PDO support 275 # if we get here, then we have no PDO support :(
317 276
318 eerror 277 eerror
319 eerror "No PDO extension for PHP found." 278 eerror "No PDO extension for PHP found."
320 eerror "Please note that PDO only exists for PHP 5." 279 eerror "Please note that PDO only exists for PHP 5."
321 eerror "Please install a PDO extension for PHP 5," 280 eerror "Please install a PDO extension for PHP 5,"
323 eerror "the 'pdo-external' USE flag or you must" 282 eerror "the 'pdo-external' USE flag or you must"
324 eerror "install dev-lang/php-5.1* with either" 283 eerror "install dev-lang/php-5.1* with either"
325 eerror "the 'pdo' or the 'pdo-external' USE flags" 284 eerror "the 'pdo' or the 'pdo-external' USE flags"
326 eerror "turned on." 285 eerror "turned on."
327 eerror 286 eerror
328 die "No PDO extension found for PHP 5" 287 die "No PDO extension found for PHP"
329} 288}
330 289
331# determines which installed PHP version has the CLI sapi 290# determines which installed PHP version has the CLI sapi
332# useful for PEAR eclass, or anything which needs to run PHP 291# useful for PEAR eclass, or anything which needs to run PHP
333# scripts depending on the cli sapi 292# scripts
334 293
335require_php_cli() 294require_php_cli()
336{ 295{
337 # if PHP_PKG is set, then we have remembered our PHP settings 296 # if PHP_PKG is set, then we have remembered our PHP settings
338 # from last time 297 # from last time
339
340 if [[ -n ${PHP_PKG} ]]; then 298 if [[ -n ${PHP_PKG} ]]; then
341 return 299 return
342 fi 300 fi
343 301
344 # detect which PHP version installed 302 # detect which PHP version installed
303 if has_version '=dev-lang/php-5*' ; then
304 pkg="`best_version '=dev-lang/php-5*'`"
305 if built_with_use =${pkg} cli ; then
306 PHP_VERSION=5
307 fi
345 if has_version '=dev-lang/php-4*' ; then 308 elif has_version '=dev-lang/php-4*' ; then
346 pkg="`best_version '=dev-lang/php-4*'`" 309 pkg="`best_version '=dev-lang/php-4*'`"
347 if built_with_use =${pkg} cli ; then 310 if built_with_use =${pkg} cli ; then
348 PHP_VERSION=4 311 PHP_VERSION=4
349 fi 312 fi
350 elif has_version '=dev-lang/php-5*' ; then
351 pkg="`best_version '=dev-lang/php-5*'`"
352 if built_with_use =${pkg} cli ; then
353 PHP_VERSION=5
354 fi
355 else 313 else
356 die "Unable to find an installed dev-lang/php package" 314 die "Unable to find an installed dev-lang/php package"
357 fi 315 fi
358 316
359 if [[ -z ${PHP_VERSION} ]]; then 317 if [[ -z ${PHP_VERSION} ]]; then
360 die "No PHP CLI installed" 318 die "No PHP CLI installed"
361 fi 319 fi
362 320
363 # if we get here, then PHP_VERSION tells us which version of PHP we 321 # if we get here, then PHP_VERSION tells us which version of PHP we
364 # want to use 322 # want to use
365
366 uses_php${PHP_VERSION} 323 uses_php${PHP_VERSION}
367} 324}
368 325
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
407# require a PHP built with sqlite support 326# require a PHP built with sqlite support
408 327
409require_sqlite() 328require_sqlite()
410{ 329{
411 has_php 330 has_php
412 331
413 # has our PHP been built with sqlite? 332 # has our PHP been built w/ sqlite?
414
415 if built_with_use =${PHP_PKG} sqlite ; then 333 if built_with_use =${PHP_PKG} sqlite ; then
416 return 334 return
417 fi 335 fi
418 336
419 # do we have pecl-sqlite installed for PHP 4? 337 # do we have pecl-sqlite installed for PHP4?
420
421 if [[ ${PHP_VERSION} == 4 ]] ; then 338 if [[ ${PHP_VERSION} == 4 ]] ; then
422 if has_version dev-php4/pecl-sqlite ; then 339 if has_version dev-php4/pecl-sqlite ; then
423 return 340 return
424 fi 341 fi
425 fi 342 fi
426 343
427 # if we get here, then we don't have any sqlite support for PHP installed 344 # if we get here, then we don't have any php/sqlite support installed
428
429 eerror 345 eerror
430 eerror "No sqlite extension for PHP found." 346 eerror "No sqlite extension for PHP found."
431 eerror "Please install an sqlite extension for PHP," 347 eerror "Please install an sqlite extension for PHP,"
432 eerror "this is done best by simply adding the" 348 eerror "this is done best by simply adding the"
433 eerror "'sqlite' USE flag when emerging dev-lang/php." 349 eerror "'sqlite' USE flag when emerging dev-lang/php."
434 eerror 350 eerror
435 die "No sqlite extension for PHP found" 351 die "No sqlite extension for PHP found"
436} 352}
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.1.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20