| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2007 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.12 2006/03/24 23:05:47 chtekk Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.19 2007/05/12 14:22:12 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 | # |
12 | # |
| 13 | # Author: Luca Longinotti |
13 | # Author: Luca Longinotti |
| 14 | # <chtekk@gentoo.org> |
14 | # <chtekk@gentoo.org> |
| 15 | # |
15 | # |
| 16 | # Maintained by the PHP Herd <php-bugs@gentoo.org> |
16 | # Maintained by the PHP Team <php-bugs@gentoo.org> |
| 17 | # |
17 | # |
| 18 | # ======================================================================== |
18 | # ======================================================================== |
| 19 | |
19 | |
| 20 | inherit eutils phpconfutils |
20 | inherit eutils phpconfutils |
| 21 | |
21 | |
| … | |
… | |
| 48 | PHPCONFIG="/usr/${libdir}/php4/bin/php-config" |
48 | PHPCONFIG="/usr/${libdir}/php4/bin/php-config" |
| 49 | PHPCLI="/usr/${libdir}/php4/bin/php" |
49 | PHPCLI="/usr/${libdir}/php4/bin/php" |
| 50 | PHPCGI="/usr/${libdir}/php4/bin/php-cgi" |
50 | PHPCGI="/usr/${libdir}/php4/bin/php-cgi" |
| 51 | PHP_PKG="`best_version =dev-lang/php-4*`" |
51 | PHP_PKG="`best_version =dev-lang/php-4*`" |
| 52 | PHPPREFIX="/usr/${libdir}/php4" |
52 | PHPPREFIX="/usr/${libdir}/php4" |
|
|
53 | EXT_DIR="`${PHPCONFIG} --extension-dir 2>/dev/null`" |
| 53 | |
54 | |
| 54 | einfo |
55 | einfo |
| 55 | einfo "Using ${PHP_PKG}" |
56 | einfo "Using ${PHP_PKG}" |
| 56 | einfo |
57 | einfo |
| 57 | } |
58 | } |
| … | |
… | |
| 85 | PHPCONFIG="/usr/${libdir}/php5/bin/php-config" |
86 | PHPCONFIG="/usr/${libdir}/php5/bin/php-config" |
| 86 | PHPCLI="/usr/${libdir}/php5/bin/php" |
87 | PHPCLI="/usr/${libdir}/php5/bin/php" |
| 87 | PHPCGI="/usr/${libdir}/php5/bin/php-cgi" |
88 | PHPCGI="/usr/${libdir}/php5/bin/php-cgi" |
| 88 | PHP_PKG="`best_version =dev-lang/php-5*`" |
89 | PHP_PKG="`best_version =dev-lang/php-5*`" |
| 89 | PHPPREFIX="/usr/${libdir}/php5" |
90 | PHPPREFIX="/usr/${libdir}/php5" |
|
|
91 | EXT_DIR="`${PHPCONFIG} --extension-dir 2>/dev/null`" |
| 90 | |
92 | |
| 91 | einfo |
93 | einfo |
| 92 | einfo "Using ${PHP_PKG}" |
94 | einfo "Using ${PHP_PKG}" |
| 93 | einfo |
95 | einfo |
| 94 | } |
96 | } |
| … | |
… | |
| 113 | need_php_by_category() { |
115 | need_php_by_category() { |
| 114 | case "${CATEGORY}" in |
116 | case "${CATEGORY}" in |
| 115 | dev-php) need_php ;; |
117 | dev-php) need_php ;; |
| 116 | dev-php4) need_php4 ;; |
118 | dev-php4) need_php4 ;; |
| 117 | dev-php5) need_php5 ;; |
119 | dev-php5) need_php5 ;; |
| 118 | *) die "I don't know which version of PHP packages in ${CATEGORY} require" |
120 | *) die "Version of PHP required by packages in category ${CATEGORY} unknown" |
| 119 | esac |
121 | esac |
| 120 | } |
122 | } |
| 121 | |
123 | |
| 122 | # Call this function from your pkg_setup, src_compile and src_install methods |
124 | # Call this function from your pkg_setup, src_compile and src_install methods |
| 123 | # if you need to know where the PHP binaries are installed and their data |
125 | # if you need to know where the PHP binaries are installed and their data |
| … | |
… | |
| 146 | } |
148 | } |
| 147 | |
149 | |
| 148 | # Call this function from pkg_setup if your package only works with |
150 | # Call this function from pkg_setup if your package only works with |
| 149 | # specific SAPIs |
151 | # specific SAPIs |
| 150 | # |
152 | # |
| 151 | # $1 ... a list of PHP SAPI USE flags (cli, cgi, apache, apache2) |
153 | # $1 ... a list of PHP SAPI USE flags (cli, cgi, apache2) |
| 152 | # |
154 | # |
| 153 | # Returns if any one of the listed SAPIs have been installed |
155 | # Returns if any one of the listed SAPIs have been installed |
| 154 | # Dies if none of the listed SAPIs have been installed |
156 | # Dies if none of the listed SAPIs have been installed |
| 155 | |
157 | |
| 156 | require_php_sapi_from() { |
158 | require_php_sapi_from() { |
| … | |
… | |
| 160 | local x |
162 | local x |
| 161 | |
163 | |
| 162 | einfo "Checking for compatible SAPI(s)" |
164 | einfo "Checking for compatible SAPI(s)" |
| 163 | |
165 | |
| 164 | for x in $@ ; do |
166 | for x in $@ ; do |
| 165 | if built_with_use =${PHP_PKG} ${x} ; then |
167 | if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then |
| 166 | einfo " Discovered compatible SAPI ${x}" |
168 | einfo " Discovered compatible SAPI ${x}" |
| 167 | has_sapi="1" |
169 | has_sapi="1" |
| 168 | fi |
170 | fi |
| 169 | done |
171 | done |
| 170 | |
172 | |
| … | |
… | |
| 193 | has_php |
195 | has_php |
| 194 | |
196 | |
| 195 | local missing_use="" |
197 | local missing_use="" |
| 196 | local x |
198 | local x |
| 197 | |
199 | |
| 198 | einfo "Checking for required PHP feature(s):" |
200 | einfo "Checking for required PHP feature(s) ..." |
| 199 | |
201 | |
| 200 | for x in $@ ; do |
202 | for x in $@ ; do |
| 201 | if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then |
203 | if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then |
| 202 | einfo " Discovered missing USE flag ${x}" |
204 | einfo " Discovered missing USE flag: ${x}" |
| 203 | missing_use="${missing_use} ${x}" |
205 | missing_use="${missing_use} ${x}" |
| 204 | fi |
206 | fi |
| 205 | done |
207 | done |
| 206 | |
208 | |
| 207 | if [[ -z ${missing_use} ]] ; then |
209 | if [[ -z "${missing_use}" ]] ; then |
|
|
210 | if [[ -z "${PHPCHECKNODIE}" ]] ; then |
| 208 | return |
211 | return |
|
|
212 | else |
|
|
213 | return 0 |
| 209 | fi |
214 | fi |
|
|
215 | fi |
| 210 | |
216 | |
|
|
217 | if [[ -z "${PHPCHECKNODIE}" ]] ; then |
| 211 | eerror |
218 | eerror |
| 212 | eerror "${PHP_PKG} needs to be re-installed with all of the following" |
219 | eerror "${PHP_PKG} needs to be re-installed with all of the following" |
| 213 | eerror "USE flags enabled:" |
220 | eerror "USE flags enabled:" |
| 214 | eerror |
221 | eerror |
| 215 | eerror " $@" |
222 | eerror " $@" |
| 216 | eerror |
223 | eerror |
| 217 | die "Missing PHP USE flags found" |
224 | die "Missing PHP USE flags found" |
|
|
225 | else |
|
|
226 | return 1 |
|
|
227 | fi |
| 218 | } |
228 | } |
| 219 | |
229 | |
| 220 | # Call this function from pkg_setup if your package requires PHP compiled |
230 | # Call this function from pkg_setup if your package requires PHP compiled |
| 221 | # with any of specified USE flags |
231 | # with any of specified USE flags |
| 222 | # |
232 | # |
| … | |
… | |
| 229 | has_php |
239 | has_php |
| 230 | |
240 | |
| 231 | local missing_use="" |
241 | local missing_use="" |
| 232 | local x |
242 | local x |
| 233 | |
243 | |
| 234 | einfo "Checking for required PHP feature(s):" |
244 | einfo "Checking for required PHP feature(s) ..." |
| 235 | |
245 | |
| 236 | for x in $@ ; do |
246 | for x in $@ ; do |
| 237 | if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then |
247 | if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then |
| 238 | einfo " USE flag ${x} is enabled, ok ..." |
248 | einfo " USE flag ${x} is enabled, ok ..." |
| 239 | return |
249 | return |
| 240 | else |
250 | else |
| 241 | missing_use="${missing_use} ${x}" |
251 | missing_use="${missing_use} ${x}" |
| 242 | fi |
252 | fi |
| 243 | done |
253 | done |
| 244 | |
254 | |
| 245 | if [[ -z ${missing_use} ]] ; then |
255 | if [[ -z "${missing_use}" ]] ; then |
|
|
256 | if [[ -z "${PHPCHECKNODIE}" ]] ; then |
| 246 | return |
257 | return |
|
|
258 | else |
|
|
259 | return 0 |
| 247 | fi |
260 | fi |
|
|
261 | fi |
| 248 | |
262 | |
|
|
263 | if [[ -z "${PHPCHECKNODIE}" ]] ; then |
| 249 | eerror |
264 | eerror |
| 250 | eerror "${PHP_PKG} needs to be re-installed with any of the following" |
265 | eerror "${PHP_PKG} needs to be re-installed with any of the following" |
| 251 | eerror "USE flags enabled:" |
266 | eerror "USE flags enabled:" |
| 252 | eerror |
267 | eerror |
| 253 | eerror " $@" |
268 | eerror " $@" |
| 254 | eerror |
269 | eerror |
| 255 | die "Missing PHP USE flags found" |
270 | die "Missing PHP USE flags found" |
|
|
271 | else |
|
|
272 | return 1 |
|
|
273 | fi |
| 256 | } |
274 | } |
| 257 | |
275 | |
| 258 | # ======================================================================== |
276 | # ======================================================================== |
| 259 | # has_*() functions |
277 | # has_*() functions |
| 260 | # |
278 | # |
| … | |
… | |
| 264 | # Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled |
282 | # Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled |
| 265 | |
283 | |
| 266 | has_zts() { |
284 | has_zts() { |
| 267 | has_php |
285 | has_php |
| 268 | |
286 | |
| 269 | if built_with_use =${PHP_PKG} apache2 threads ; then |
287 | if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then |
| 270 | return 0 |
288 | return 0 |
| 271 | fi |
289 | fi |
| 272 | |
290 | |
| 273 | return 1 |
291 | return 1 |
| 274 | } |
292 | } |
| 275 | |
293 | |
| 276 | # Check if our PHP was built with Hardened-PHP enabled |
294 | # Check if our PHP was built with debug support enabled |
| 277 | |
295 | |
| 278 | has_hardenedphp() { |
296 | has_debug() { |
| 279 | has_php |
297 | has_php |
| 280 | |
298 | |
| 281 | if built_with_use =${PHP_PKG} hardenedphp ; then |
299 | if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then |
| 282 | return 0 |
300 | return 0 |
| 283 | fi |
301 | fi |
| 284 | |
302 | |
| 285 | return 1 |
303 | return 1 |
| 286 | } |
304 | } |
| 287 | |
305 | |
| 288 | # Check if our PHP was built with debug support enabled |
306 | # Check if our PHP was built with the concurrentmodphp support enabled |
| 289 | |
307 | |
| 290 | has_debug() { |
308 | has_concurrentmodphp() { |
| 291 | has_php |
309 | has_php |
| 292 | |
310 | |
| 293 | if built_with_use =${PHP_PKG} debug ; then |
311 | if built_with_use =${PHP_PKG} apache2 concurrentmodphp || phpconfutils_built_with_use =${PHP_PKG} apache2 concurrentmodphp ; then |
| 294 | return 0 |
312 | return 0 |
| 295 | fi |
313 | fi |
| 296 | |
314 | |
| 297 | return 1 |
315 | return 1 |
| 298 | } |
316 | } |
| … | |
… | |
| 311 | # Do we have PHP5 installed? |
329 | # Do we have PHP5 installed? |
| 312 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
330 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
| 313 | eerror |
331 | eerror |
| 314 | eerror "This package requires PDO." |
332 | eerror "This package requires PDO." |
| 315 | eerror "PDO is only available for PHP 5." |
333 | eerror "PDO is only available for PHP 5." |
| 316 | eerror "You must install =dev-lang/php-5.0* with" |
334 | eerror "You must install >=dev-lang/php-5.1 with" |
| 317 | eerror "the 'pdo-external' USE flag or you must" |
|
|
| 318 | eerror "install >=dev-lang/php-5.1 with either" |
|
|
| 319 | eerror "the 'pdo' or the 'pdo-external' USE flags" |
335 | eerror "either the 'pdo' or the 'pdo-external'" |
| 320 | eerror "turned on." |
336 | eerror "USE flags turned on." |
| 321 | eerror |
337 | eerror |
| 322 | die "PHP 5 not installed" |
338 | die "PHP 5 not installed" |
| 323 | fi |
339 | fi |
| 324 | |
340 | |
| 325 | # Was PHP5 compiled with internal PDO support? |
341 | # Was PHP5 compiled with internal PDO support? |
| 326 | if built_with_use =${PHP_PKG} pdo ; then |
342 | if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then |
| 327 | return |
343 | return |
| 328 | fi |
344 | fi |
| 329 | |
345 | |
| 330 | # Ok, maybe PDO was built as an external extension? |
346 | # Ok, maybe PDO was built as an external extension? |
| 331 | if built_with_use =${PHP_PKG} pdo-external && has_version 'dev-php5/pecl-pdo' ; then |
347 | if ( built_with_use =${PHP_PKG} pdo-external || phpconfutils_built_with_use =${PHP_PKG} pdo-external ) && has_version 'dev-php5/pecl-pdo' ; then |
| 332 | return |
348 | return |
| 333 | fi |
349 | fi |
| 334 | |
350 | |
| 335 | # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support |
351 | # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support |
| 336 | if has_version 'dev-php5/pecl-pdo' ; then |
352 | if has_version 'dev-php5/pecl-pdo' ; then |
| 337 | return |
353 | return |
| 338 | fi |
354 | fi |
| 339 | |
355 | |
| 340 | # If we get here, then we have no PDO support |
356 | # If we get here, then we don't have PDO support |
| 341 | eerror |
357 | eerror |
| 342 | eerror "No PDO extension for PHP found." |
358 | eerror "No PDO extension for PHP found." |
| 343 | eerror "Please note that PDO only exists for PHP 5." |
359 | eerror "Please note that PDO only exists for PHP 5." |
| 344 | eerror "Please install a PDO extension for PHP 5," |
360 | eerror "Please install a PDO extension for PHP 5," |
| 345 | eerror "you must install =dev-lang/php-5.0* with" |
361 | eerror "you must install >=dev-lang/php-5.1 with" |
| 346 | eerror "the 'pdo-external' USE flag or you must" |
|
|
| 347 | eerror "install >=dev-lang/php-5.1 with either" |
|
|
| 348 | eerror "the 'pdo' or the 'pdo-external' USE flags" |
362 | eerror "either the 'pdo' or the 'pdo-external'" |
| 349 | eerror "turned on." |
363 | eerror "USE flags turned on." |
| 350 | eerror |
364 | eerror |
| 351 | die "No PDO extension for PHP 5 found" |
365 | die "No PDO extension for PHP 5 found" |
| 352 | } |
366 | } |
| 353 | |
367 | |
| 354 | # Determines which installed PHP version has the CLI SAPI enabled, |
368 | # Determines which installed PHP version has the CLI SAPI enabled, |
| … | |
… | |
| 366 | |
380 | |
| 367 | # Detect which PHP version we have installed |
381 | # Detect which PHP version we have installed |
| 368 | if has_version '=dev-lang/php-4*' ; then |
382 | if has_version '=dev-lang/php-4*' ; then |
| 369 | PHP_PACKAGE_FOUND="1" |
383 | PHP_PACKAGE_FOUND="1" |
| 370 | pkg="`best_version '=dev-lang/php-4*'`" |
384 | pkg="`best_version '=dev-lang/php-4*'`" |
| 371 | if built_with_use =${pkg} cli ; then |
385 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
| 372 | PHP_VERSION="4" |
386 | PHP_VERSION="4" |
| 373 | fi |
387 | fi |
| 374 | fi |
388 | fi |
| 375 | |
389 | |
| 376 | if has_version '=dev-lang/php-5*' ; then |
390 | if has_version '=dev-lang/php-5*' ; then |
| 377 | PHP_PACKAGE_FOUND="1" |
391 | PHP_PACKAGE_FOUND="1" |
| 378 | pkg="`best_version '=dev-lang/php-5*'`" |
392 | pkg="`best_version '=dev-lang/php-5*'`" |
| 379 | if built_with_use =${pkg} cli ; then |
393 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
| 380 | PHP_VERSION="5" |
394 | PHP_VERSION="5" |
| 381 | fi |
395 | fi |
| 382 | fi |
396 | fi |
| 383 | |
397 | |
| 384 | if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then |
398 | if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then |
| … | |
… | |
| 409 | |
423 | |
| 410 | # Detect which PHP version we have installed |
424 | # Detect which PHP version we have installed |
| 411 | if has_version '=dev-lang/php-4*' ; then |
425 | if has_version '=dev-lang/php-4*' ; then |
| 412 | PHP_PACKAGE_FOUND="1" |
426 | PHP_PACKAGE_FOUND="1" |
| 413 | pkg="`best_version '=dev-lang/php-4*'`" |
427 | pkg="`best_version '=dev-lang/php-4*'`" |
| 414 | if built_with_use =${pkg} cgi ; then |
428 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
| 415 | PHP_VERSION="4" |
429 | PHP_VERSION="4" |
| 416 | fi |
430 | fi |
| 417 | fi |
431 | fi |
| 418 | |
432 | |
| 419 | if has_version '=dev-lang/php-5*' ; then |
433 | if has_version '=dev-lang/php-5*' ; then |
| 420 | PHP_PACKAGE_FOUND="1" |
434 | PHP_PACKAGE_FOUND="1" |
| 421 | pkg="`best_version '=dev-lang/php-5*'`" |
435 | pkg="`best_version '=dev-lang/php-5*'`" |
| 422 | if built_with_use =${pkg} cgi ; then |
436 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
| 423 | PHP_VERSION="5" |
437 | PHP_VERSION="5" |
| 424 | fi |
438 | fi |
| 425 | fi |
439 | fi |
| 426 | |
440 | |
| 427 | if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then |
441 | if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then |
| … | |
… | |
| 503 | |
517 | |
| 504 | local PUSE_ENABLED="" |
518 | local PUSE_ENABLED="" |
| 505 | |
519 | |
| 506 | # Binary extensions do not support the change of PHP |
520 | # Binary extensions do not support the change of PHP |
| 507 | # API version, so they can't be installed when USE flags |
521 | # API version, so they can't be installed when USE flags |
| 508 | # are enabled wich change the PHP API version |
522 | # are enabled which change the PHP API version, they also |
|
|
523 | # don't provide correctly versioned symbols for our use |
| 509 | |
524 | |
| 510 | if built_with_use =${PHP_PKG} hardenedphp ; then |
525 | if has_debug ; then |
| 511 | eerror |
|
|
| 512 | eerror "You cannot install binary PHP extensions" |
|
|
| 513 | eerror "when the 'hardenedphp' USE flag is enabled!" |
|
|
| 514 | eerror "Please reemerge dev-lang/php with the" |
|
|
| 515 | eerror "'hardenedphp' USE flag turned off." |
|
|
| 516 | eerror |
|
|
| 517 | PUSE_ENABLED="1" |
|
|
| 518 | fi |
|
|
| 519 | |
|
|
| 520 | if built_with_use =${PHP_PKG} debug ; then |
|
|
| 521 | eerror |
526 | eerror |
| 522 | eerror "You cannot install binary PHP extensions" |
527 | eerror "You cannot install binary PHP extensions" |
| 523 | eerror "when the 'debug' USE flag is enabled!" |
528 | eerror "when the 'debug' USE flag is enabled!" |
| 524 | eerror "Please reemerge dev-lang/php with the" |
529 | eerror "Please reemerge dev-lang/php with the" |
| 525 | eerror "'debug' USE flag turned off." |
530 | eerror "'debug' USE flag turned off." |
| 526 | eerror |
531 | eerror |
| 527 | PUSE_ENABLED="1" |
532 | PUSE_ENABLED="1" |
| 528 | fi |
533 | fi |
| 529 | |
534 | |
|
|
535 | if has_concurrentmodphp ; then |
|
|
536 | eerror |
|
|
537 | eerror "You cannot install binary PHP extensions when" |
|
|
538 | eerror "the 'concurrentmodphp' USE flag is enabled!" |
|
|
539 | eerror "Please reemerge dev-lang/php with the" |
|
|
540 | eerror "'concurrentmodphp' USE flag turned off." |
|
|
541 | eerror |
|
|
542 | PUSE_ENABLED="1" |
|
|
543 | fi |
|
|
544 | |
| 530 | if [[ -n ${PUSE_ENABLED} ]] ; then |
545 | if [[ -n ${PUSE_ENABLED} ]] ; then |
| 531 | die "'hardenedphp' and/or 'debug' USE flags turned on" |
546 | die "'debug' and/or 'concurrentmodphp' USE flags turned on!" |
| 532 | fi |
547 | fi |
| 533 | } |
548 | } |
| 534 | |
549 | |
| 535 | # Alternative to dodoc function for use in our PHP eclasses and |
550 | # Alternative to dodoc function for use in our PHP eclasses and |
| 536 | # ebuilds. |
551 | # ebuilds. |