/[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.4
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.4 2005/09/16 20:25:21 trapni 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"
116# 131#
117# this function will disappear when USE-based deps are supported by 132# this function will disappear when USE-based deps are supported by
118# Portage 133# Portage
119# 134#
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
155# 171#
156# this function will disappear when USE-based deps are supported by 172# this function will disappear when USE-based deps are supported by
157# Portage 173# Portage
158# 174#
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
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
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-5*' ; then
379 pkg="`best_version '=dev-lang/php-5*'`"
380 if built_with_use =${pkg} cgi ; then
381 PHP_VERSION=5
382 fi
383 elif 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 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
433require_gd()
434{
435 has_php
436
437 # do we have the internal GD support installed?
438
439 if built_with_use =${PHP_PKG} gd ; then
440 return
441 fi
442
443 # ok, maybe GD was built using the external support?
444
445 if built_with_use =${PHP_PKG} gd-external ; then
446 return
447 fi
448
449 # if we get here, then we have no GD support
450
451 eerror
452 eerror "No GD support for PHP found."
453 eerror "Please install the GD support for PHP,"
454 eerror "you must install dev-lang/php with either"
455 eerror "the 'gd' or the 'gd-external' USE flags"
456 eerror "turned on."
457 eerror
458 die "No GD support found for PHP"
459}

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

  ViewVC Help
Powered by ViewVC 1.1.20