/[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.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.1 2005/09/04 10:54:53 stuart 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
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
170 einfo "Checking for required PHP feature(s):" 192 einfo "Checking for required PHP feature(s):"
171 193
172 for x in $@ ; do 194 for x in $@ ; do
174 einfo " Discovered missing USE flag ${x}" 196 einfo " Discovered missing USE flag ${x}"
175 missing_use="${missing_use} ${x}" 197 missing_use="${missing_use} ${x}"
176 fi 198 fi
177 done 199 done
178 200
179 if [[ -z ${missing_use} ]]; then 201 if [[ -z ${missing_use} ]] ; then
180 return 202 return
181 fi 203 fi
182 204
183 eerror 205 eerror
184 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"
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
205 if has_version '=dev-lang/php-5*' ; then 228 if has_version '=dev-lang/php-5*' ; then
206 PHP_VERSION=5 229 PHP_VERSION=5
207 elif has_version '=dev-lang/php-4*' ; then 230 elif has_version '=dev-lang/php-4*' ; then
208 PHP_VERSION=4 231 PHP_VERSION=4
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# ========================================================================
242 280
281# require a PHP built with PDO support for PHP5
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 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 "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."
253 eerror 298 eerror
254 die "PHP 5 not installed" 299 die "PHP 5 not installed"
255 fi 300 fi
256 301
257 # was php5 compiled w/ pdo support? 302 # was php5 compiled w/ pdo support?
264 309
265 if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then 310 if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then
266 return 311 return
267 fi 312 fi
268 313
269 # it suffices that pecl-pdo was installed to have PDO support 314 # ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
270 315
271 if has_version dev-php5/pecl-pdo ; then 316 if has_version dev-php5/pecl-pdo ; then
272 return 317 return
273 fi 318 fi
274 319
275 # if we get here, then we have no PDO support :( 320 # if we get here, then we have no PDO support
276 321
277 eerror 322 eerror
278 eerror "No PDO extension for PHP found." 323 eerror "No PDO extension for PHP found."
279 eerror "Please note that PDO only exists for PHP 5." 324 eerror "Please note that PDO only exists for PHP 5."
280 eerror "Please install a PDO extension for PHP 5," 325 eerror "Please install a PDO extension for PHP 5,"
281 eerror "you must install dev-lang/php-5.0* with" 326 eerror "you must install =dev-lang/php-5.0* with"
282 eerror "the 'pdo-external' USE flag or you must" 327 eerror "the 'pdo-external' USE flag or you must"
283 eerror "install dev-lang/php-5.1* with either" 328 eerror "install >=dev-lang/php-5.1 with either"
284 eerror "the 'pdo' or the 'pdo-external' USE flags" 329 eerror "the 'pdo' or the 'pdo-external' USE flags"
285 eerror "turned on." 330 eerror "turned on."
286 eerror 331 eerror
287 die "No PDO extension found for PHP" 332 die "No PDO extension found for PHP 5"
288} 333}
289 334
290# determines which installed PHP version has the CLI sapi 335# determines which installed PHP version has the CLI sapi
291# useful for PEAR eclass, or anything which needs to run PHP 336# useful for PEAR eclass, or anything which needs to run PHP
292# scripts 337# scripts depending on the cli sapi
293 338
294require_php_cli() 339require_php_cli()
295{ 340{
296 # 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
297 # from last time 342 # from last time
343
298 if [[ -n ${PHP_PKG} ]]; then 344 if [[ -n ${PHP_PKG} ]] ; then
299 return 345 return
300 fi 346 fi
301 347
302 # 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
303 if has_version '=dev-lang/php-5*' ; then 357 if has_version '=dev-lang/php-5*' ; then
358 PHP_PACKAGE_FOUND=1
304 pkg="`best_version '=dev-lang/php-5*'`" 359 pkg="`best_version '=dev-lang/php-5*'`"
305 if built_with_use =${pkg} cli ; then 360 if built_with_use =${pkg} cli ; then
306 PHP_VERSION=5 361 PHP_VERSION=5
307 fi 362 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 363 fi
313 else 364
365 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
314 die "Unable to find an installed dev-lang/php package" 366 die "Unable to find an installed dev-lang/php package"
315 fi 367 fi
316 368
317 if [[ -z ${PHP_VERSION} ]]; then 369 if [[ -z ${PHP_VERSION} ]] ; then
318 die "No PHP CLI installed" 370 die "No PHP CLI installed"
319 fi 371 fi
320 372
321 # 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
322 # want to use 374 # want to use
375
323 uses_php${PHP_VERSION} 376 uses_php${PHP_VERSION}
324} 377}
325 378
379# determines which installed PHP version has the CGI sapi
380# useful for anything which needs to run PHP scripts
381# depending on the cgi sapi
382
383require_php_cgi()
384{
385 # if PHP_PKG is set, then we have remembered our PHP settings
386 # from last time
387
388 if [[ -n ${PHP_PKG} ]] ; then
389 return
390 fi
391
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
401 if has_version '=dev-lang/php-5*' ; then
402 PHP_PACKAGE_FOUND=1
403 pkg="`best_version '=dev-lang/php-5*'`"
404 if built_with_use =${pkg} cgi ; then
405 PHP_VERSION=5
406 fi
407 fi
408
409 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
410 die "Unable to find an installed dev-lang/php package"
411 fi
412
413 if [[ -z ${PHP_VERSION} ]] ; then
414 die "No PHP CGI installed"
415 fi
416
417 # if we get here, then PHP_VERSION tells us which version of PHP we
418 # want to use
419
420 uses_php${PHP_VERSION}
421}
422
326# require a PHP built with sqlite support 423# require a PHP built with sqlite support
327 424
328require_sqlite() 425require_sqlite()
329{ 426{
330 has_php 427 has_php
331 428
332 # has our PHP been built w/ sqlite? 429 # has our PHP been built with sqlite?
430
333 if built_with_use =${PHP_PKG} sqlite ; then 431 if built_with_use =${PHP_PKG} sqlite ; then
334 return 432 return
335 fi 433 fi
336 434
337 # do we have pecl-sqlite installed for PHP4? 435 # do we have pecl-sqlite installed for PHP 4?
436
338 if [[ ${PHP_VERSION} == 4 ]] ; then 437 if [[ ${PHP_VERSION} == 4 ]] ; then
339 if has_version dev-php4/pecl-sqlite ; then 438 if has_version dev-php4/pecl-sqlite ; then
340 return 439 return
341 fi 440 fi
342 fi 441 fi
343 442
344 # if we get here, then we don't have any php/sqlite support installed 443 # if we get here, then we don't have any sqlite support for PHP installed
444
345 eerror 445 eerror
346 eerror "No sqlite extension for PHP found." 446 eerror "No sqlite extension for PHP found."
347 eerror "Please install an sqlite extension for PHP," 447 eerror "Please install an sqlite extension for PHP,"
348 eerror "this is done best by simply adding the" 448 eerror "this is done best by simply adding the"
349 eerror "'sqlite' USE flag when emerging dev-lang/php." 449 eerror "'sqlite' USE flag when emerging dev-lang/php."
350 eerror 450 eerror
351 die "No sqlite extension for PHP found" 451 die "No sqlite extension for PHP found"
352} 452}
453
454# require a PHP built with GD support
455
456require_gd()
457{
458 has_php
459
460 # do we have the internal GD support installed?
461
462 if built_with_use =${PHP_PKG} gd ; then
463 return
464 fi
465
466 # ok, maybe GD was built using the external support?
467
468 if built_with_use =${PHP_PKG} gd-external ; then
469 return
470 fi
471
472 # if we get here, then we have no GD support
473
474 eerror
475 eerror "No GD support for PHP found."
476 eerror "Please install the GD support for PHP,"
477 eerror "you must install dev-lang/php with either"
478 eerror "the 'gd' or the 'gd-external' USE flags"
479 eerror "turned on."
480 eerror
481 die "No GD support found for PHP"
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.1  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20