/[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.13 Revision 1.28
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.13 2006/04/20 12:15:35 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.28 2010/10/12 19:34:49 olemarkus Exp $
4# 4
5# ======================================================================== 5# Author: Stuart Herbert <stuart@gentoo.org>
6# 6# Author: Luca Longinotti <chtekk@gentoo.org>
7# Author: Jakub Moc <jakub@gentoo.org> (documentation)
8
7# depend.php.eclass 9# @ECLASS: depend.php.eclass
8# functions to allow ebuilds to depend on php4 and/or php5 10# @MAINTAINER:
9# 11# Gentoo PHP team <php-bugs@gentoo.org>
10# Author: Stuart Herbert 12# @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features.
11# <stuart@gentoo.org> 13# @DESCRIPTION:
12# 14# This eclass provides functions that allow ebuilds to depend on php5 and check
13# Author: Luca Longinotti 15# for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install
14# <chtekk@gentoo.org> 16# documentation for PHP packages to php-specific location.
15# 17
16# Maintained by the PHP Herd <php-bugs@gentoo.org>
17#
18# ========================================================================
19 18
20inherit eutils phpconfutils 19inherit eutils phpconfutils
21 20
22# PHP4-only depend functions
23need_php4_cli() {
24 DEPEND="${DEPEND} =virtual/php-4*"
25 RDEPEND="${RDEPEND} =virtual/php-4*"
26 PHP_VERSION="4"
27}
28
29need_php4_httpd() {
30 DEPEND="${DEPEND} =virtual/httpd-php-4*"
31 RDEPEND="${RDEPEND} =virtual/httpd-php-4*"
32 PHP_VERSION="4"
33}
34
35need_php4() {
36 DEPEND="${DEPEND} =dev-lang/php-4*"
37 RDEPEND="${RDEPEND} =dev-lang/php-4*"
38 PHP_VERSION="4"
39 PHP_SHARED_CAT="php4"
40}
41
42# common settings go in here
43uses_php4() {
44 # cache this
45 libdir=$(get_libdir)
46
47 PHPIZE="/usr/${libdir}/php4/bin/phpize"
48 PHPCONFIG="/usr/${libdir}/php4/bin/php-config"
49 PHPCLI="/usr/${libdir}/php4/bin/php"
50 PHPCGI="/usr/${libdir}/php4/bin/php-cgi"
51 PHP_PKG="`best_version =dev-lang/php-4*`"
52 PHPPREFIX="/usr/${libdir}/php4"
53
54 einfo
55 einfo "Using ${PHP_PKG}"
56 einfo
57}
58
59# PHP5-only depend functions 21# PHP5-only depend functions
22
23# @FUNCTION: need_php5_cli
24# @DESCRIPTION:
25# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
26# with cli SAPI.
60need_php5_cli() { 27need_php5_cli() {
61 DEPEND="${DEPEND} =virtual/php-5*" 28 DEPEND="${DEPEND} =virtual/php-5*"
62 RDEPEND="${RDEPEND} =virtual/php-5*" 29 RDEPEND="${RDEPEND} =virtual/php-5*"
63 PHP_VERSION="5" 30 PHP_VERSION="5"
64} 31}
65 32
33# @FUNCTION: need_php5_httpd
34# @DESCRIPTION:
35# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
36# with either cgi or apache2 SAPI.
66need_php5_httpd() { 37need_php5_httpd() {
67 DEPEND="${DEPEND} =virtual/httpd-php-5*" 38 DEPEND="${DEPEND} =virtual/httpd-php-5*"
68 RDEPEND="${RDEPEND} =virtual/httpd-php-5*" 39 RDEPEND="${RDEPEND} =virtual/httpd-php-5*"
69 PHP_VERSION="5" 40 PHP_VERSION="5"
70} 41}
71 42
43# @FUNCTION: need_php5
44# @DESCRIPTION:
45# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
46# (with any SAPI).
72need_php5() { 47need_php5() {
73 DEPEND="${DEPEND} =dev-lang/php-5*" 48 DEPEND="${DEPEND} =dev-lang/php-5*"
74 RDEPEND="${RDEPEND} =dev-lang/php-5*" 49 RDEPEND="${RDEPEND} =dev-lang/php-5*"
75 PHP_VERSION="5" 50 PHP_VERSION="5"
76 PHP_SHARED_CAT="php5" 51 PHP_SHARED_CAT="php5"
83 58
84 PHPIZE="/usr/${libdir}/php5/bin/phpize" 59 PHPIZE="/usr/${libdir}/php5/bin/phpize"
85 PHPCONFIG="/usr/${libdir}/php5/bin/php-config" 60 PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
86 PHPCLI="/usr/${libdir}/php5/bin/php" 61 PHPCLI="/usr/${libdir}/php5/bin/php"
87 PHPCGI="/usr/${libdir}/php5/bin/php-cgi" 62 PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
88 PHP_PKG="`best_version =dev-lang/php-5*`" 63 PHP_PKG="$(best_version =dev-lang/php-5*)"
89 PHPPREFIX="/usr/${libdir}/php5" 64 PHPPREFIX="/usr/${libdir}/php5"
65 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
90 66
91 einfo 67 einfo
92 einfo "Using ${PHP_PKG}" 68 einfo "Using ${PHP_PKG}"
93 einfo 69 einfo
94} 70}
95 71
96# general PHP depend functions 72# general PHP depend functions
73
74# @FUNCTION: need_php_cli
75# @DESCRIPTION:
76# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
77# (any version) with cli SAPI.
97need_php_cli() { 78need_php_cli() {
98 DEPEND="${DEPEND} virtual/php" 79 DEPEND="${DEPEND} virtual/php"
99 RDEPEND="${RDEPEND} virtual/php" 80 RDEPEND="${RDEPEND} virtual/php"
100} 81}
101 82
83# @FUNCTION: need_php_httpd
84# @DESCRIPTION:
85# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
86# (any version) with either cgi or apache2 SAPI.
102need_php_httpd() { 87need_php_httpd() {
103 DEPEND="${DEPEND} virtual/httpd-php" 88 DEPEND="${DEPEND} virtual/httpd-php"
104 RDEPEND="${RDEPEND} virtual/httpd-php" 89 RDEPEND="${RDEPEND} virtual/httpd-php"
105} 90}
106 91
92# @FUNCTION: need_php
93# @DESCRIPTION:
94# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
95# (any version with any SAPI).
107need_php() { 96need_php() {
108 DEPEND="${DEPEND} dev-lang/php" 97 DEPEND="${DEPEND} dev-lang/php"
109 RDEPEND="${RDEPEND} dev-lang/php" 98 RDEPEND="${RDEPEND} dev-lang/php"
110 PHP_SHARED_CAT="php" 99 PHP_SHARED_CAT="php"
111} 100}
112 101
102# @FUNCTION: need_php_by_category
103# @DESCRIPTION:
104# Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version
105# determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or
106# dev-php5, respectively.
113need_php_by_category() { 107need_php_by_category() {
114 case "${CATEGORY}" in 108 case "${CATEGORY}" in
115 dev-php) need_php ;; 109 dev-php) need_php ;;
116 dev-php4) need_php4 ;;
117 dev-php5) need_php5 ;; 110 dev-php5) need_php5 ;;
118 *) die "I don't know which version of PHP packages in ${CATEGORY} require" 111 *) die "Version of PHP required by packages in category ${CATEGORY} unknown"
119 esac 112 esac
120} 113}
121 114
115
116# @FUNCTION: has_php
117# @DESCRIPTION:
122# Call this function from your pkg_setup, src_compile and src_install methods 118# Call this function from your pkg_setup, src_compile, src_install etc. if you
123# if you need to know where the PHP binaries are installed and their data 119# need to know which PHP version is being used and where the PHP binaries/data
124 120# are installed.
125has_php() { 121has_php() {
126 # If PHP_PKG is already set, then we have remembered our PHP settings
127 # from last time
128 if [[ -n ${PHP_PKG} ]] ; then
129 return
130 fi
131
132 if [[ -z ${PHP_VERSION} ]] ; then
133 # Detect which PHP version we have installed 122 # Detect which PHP version we have installed
134 if has_version '=dev-lang/php-5*' ; then 123 if has_version '=dev-lang/php-5*' ; then
135 PHP_VERSION="5" 124 PHP_VERSION="5"
136 elif has_version '=dev-lang/php-4*' ; then
137 PHP_VERSION="4"
138 else 125 else
139 die "Unable to find an installed dev-lang/php package" 126 die "Unable to find an installed dev-lang/php package"
140 fi
141 fi 127 fi
142 128
143 # If we get here, then PHP_VERSION tells us which version of PHP we 129 # If we get here, then PHP_VERSION tells us which version of PHP we
144 # want to use 130 # want to use
145 uses_php${PHP_VERSION} 131 uses_php${PHP_VERSION}
146} 132}
147 133
134# @FUNCTION: require_php_sapi_from
135# @USAGE: <list of SAPIs>
136# @DESCRIPTION:
148# Call this function from pkg_setup if your package only works with 137# Call this function from pkg_setup if your package only works with
149# specific SAPIs 138# specific SAPI(s) and specify a list of PHP SAPI USE flags that are
139# required (one or more from cli, cgi, apache2) as arguments.
140# Returns if any of the listed SAPIs have been installed, dies if none
141# of them is available.
150# 142#
151# $1 ... a list of PHP SAPI USE flags (cli, cgi, apache, apache2) 143# Unfortunately, if you want to be really sure that the required SAPI is
152# 144# provided by PHP, you will have to use this function or similar ones (like
153# Returns if any one of the listed SAPIs have been installed 145# require_php_cli or require_php_cgi) in pkg_setup until we are able to
154# Dies if none of the listed SAPIs have been installed 146# depend on USE flags being enabled. The above described need_php[45]_cli
155 147# and need_php[45]_httpd functions cannot guarantee these requirements.
148# See Bug 2272 for details.
156require_php_sapi_from() { 149require_php_sapi_from() {
157 has_php 150 has_php
158 151
159 local has_sapi="0" 152 local has_sapi="0"
160 local x 153 local x
179 eerror " $@" 172 eerror " $@"
180 eerror 173 eerror
181 die "No compatible PHP SAPIs found" 174 die "No compatible PHP SAPIs found"
182} 175}
183 176
177# @FUNCTION: require_php_with_use
178# @USAGE: <list of USE flags>
179# @DESCRIPTION:
184# Call this function from pkg_setup if your package requires PHP compiled 180# Call this function from pkg_setup if your package requires PHP compiled
185# with specific USE flags 181# with specific USE flags. Returns if all of the listed USE flags are enabled.
182# Dies if any of the listed USE flags are disabled.
183
184# @VARIABLE: PHPCHECKNODIE
185# @DESCRIPTION:
186# You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple
187# require_php_with_(any)_use checks without making the ebuild die on every failure.
188# This is useful in cases when certain PHP features are only required if specific
189# USE flag(s) are enabled for that ebuild.
190# @CODE
191# Example:
186# 192#
187# $1 ... a list of USE flags 193# local flags="pcre session snmp sockets wddx"
188# 194# use mysql && flags="${flags} mysql"
189# Returns if all of the listed USE flags are enabled 195# use postgres && flags="${flags} postgres"
190# Dies if any of the listed USE flags are disabled 196# if ! PHPCHECKNODIE="yes" require_php_with_use ${flags} \
191 197# || ! PHPCHECKNODIE="yes" require_php_with_any_use gd gd-external ; then
198# die "Re-install ${PHP_PKG} with ${flags} and either gd or gd-external"
199# fi
200# @CODE
192require_php_with_use() { 201require_php_with_use() {
193 has_php 202 has_php
194 203
195 local missing_use="" 204 local missing_use=""
196 local x 205 local x
197 206
198 einfo "Checking for required PHP feature(s):" 207 einfo "Checking for required PHP feature(s) ..."
199 208
200 for x in $@ ; do 209 for x in $@ ; do
210 case $x in
211 pcre|spl|reflection|mhash)
212 eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
213 eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break"
214 eqawarn "if you check the USE flags against PHP 5.3 ebuilds."
215 eqawarn "Please use USE dependencies from EAPI 2 instead"
216 ;;
217 esac
218
201 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then 219 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
202 einfo " Discovered missing USE flag ${x}" 220 einfo " Discovered missing USE flag: ${x}"
203 missing_use="${missing_use} ${x}" 221 missing_use="${missing_use} ${x}"
204 fi 222 fi
205 done 223 done
206 224
207 if [[ -z ${missing_use} ]] ; then 225 if [[ -z "${missing_use}" ]] ; then
226 if [[ -z "${PHPCHECKNODIE}" ]] ; then
208 return 227 return
228 else
229 return 0
209 fi 230 fi
231 fi
210 232
233 if [[ -z "${PHPCHECKNODIE}" ]] ; then
211 eerror 234 eerror
212 eerror "${PHP_PKG} needs to be re-installed with all of the following" 235 eerror "${PHP_PKG} needs to be re-installed with all of the following"
213 eerror "USE flags enabled:" 236 eerror "USE flags enabled:"
214 eerror 237 eerror
215 eerror " $@" 238 eerror " $@"
216 eerror 239 eerror
217 die "Missing PHP USE flags found" 240 die "Missing PHP USE flags found"
241 else
242 return 1
243 fi
218} 244}
219 245
246# @FUNCTION: require_php_with_any_use
247# @USAGE: <list of USE flags>
248# @DESCRIPTION:
220# Call this function from pkg_setup if your package requires PHP compiled 249# Call this function from pkg_setup if your package requires PHP compiled with
221# with any of specified USE flags
222#
223# $1 ... a list of USE flags
224#
225# Returns if any of the listed USE flags are enabled 250# any of specified USE flags. Returns if any of the listed USE flags are enabled.
226# Dies if all of the listed USE flags are disabled 251# Dies if all of the listed USE flags are disabled.
227
228require_php_with_any_use() { 252require_php_with_any_use() {
229 has_php 253 has_php
230 254
231 local missing_use="" 255 local missing_use=""
232 local x 256 local x
233 257
234 einfo "Checking for required PHP feature(s):" 258 einfo "Checking for required PHP feature(s) ..."
235 259
236 for x in $@ ; do 260 for x in $@ ; do
237 if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then 261 if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
238 einfo " USE flag ${x} is enabled, ok ..." 262 einfo " USE flag ${x} is enabled, ok ..."
239 return 263 return
240 else 264 else
241 missing_use="${missing_use} ${x}" 265 missing_use="${missing_use} ${x}"
242 fi 266 fi
243 done 267 done
244 268
245 if [[ -z ${missing_use} ]] ; then 269 if [[ -z "${missing_use}" ]] ; then
270 if [[ -z "${PHPCHECKNODIE}" ]] ; then
246 return 271 return
272 else
273 return 0
247 fi 274 fi
275 fi
248 276
277 if [[ -z "${PHPCHECKNODIE}" ]] ; then
249 eerror 278 eerror
250 eerror "${PHP_PKG} needs to be re-installed with any of the following" 279 eerror "${PHP_PKG} needs to be re-installed with any of the following"
251 eerror "USE flags enabled:" 280 eerror "USE flags enabled:"
252 eerror 281 eerror
253 eerror " $@" 282 eerror " $@"
254 eerror 283 eerror
255 die "Missing PHP USE flags found" 284 die "Missing PHP USE flags found"
285 else
286 return 1
287 fi
256} 288}
257 289
258# ======================================================================== 290# ========================================================================
259# has_*() functions 291# has_*() functions
260# 292#
261# These functions return 0 if the condition is satisfied, 1 otherwise 293# These functions return 0 if the condition is satisfied, 1 otherwise
262# ======================================================================== 294# ========================================================================
263 295
296# @FUNCTION: has_zts
297# @DESCRIPTION:
264# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled 298# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled.
265 299# @RETURN: 0 if true, 1 otherwise
266has_zts() { 300has_zts() {
267 has_php 301 has_php
268 302
269 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then 303 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then
270 return 0 304 return 0
271 fi 305 fi
272 306
273 return 1 307 return 1
274} 308}
275 309
310# @FUNCTION: has_debug
311# @DESCRIPTION:
276# Check if our PHP was built with Hardened-PHP enabled 312# Check if our PHP was built with debug support enabled.
277 313# @RETURN: 0 if true, 1 otherwise
278has_hardenedphp() { 314has_debug() {
279 has_php 315 has_php
280 316
281 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then 317 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
282 return 0 318 return 0
283 fi 319 fi
284 320
285 return 1 321 return 1
286} 322}
287 323
324# @FUNCTION: has_concurrentmodphp
325# @DESCRIPTION:
288# Check if our PHP was built with debug support enabled 326# Check if our PHP was built with the concurrentmodphp support enabled.
289 327# @RETURN: 0 if true, 1 otherwise
290has_debug() { 328has_concurrentmodphp() {
291 has_php 329 has_php
292 330
293 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then 331 if built_with_use =${PHP_PKG} apache2 concurrentmodphp || phpconfutils_built_with_use =${PHP_PKG} apache2 concurrentmodphp ; then
294 return 0 332 return 0
295 fi 333 fi
296 334
297 return 1 335 return 1
298} 336}
301# require_*() functions 339# require_*() functions
302# 340#
303# These functions die() if PHP was built without the required features 341# These functions die() if PHP was built without the required features
304# ======================================================================== 342# ========================================================================
305 343
344# @FUNCTION: require_pdo
345# @DESCRIPTION:
306# Require a PHP built with PDO support (PHP5 only) 346# Require a PHP built with PDO support (PHP5 only).
307 347# This function is now redundant and DEPRECATED since
348# pdo-external use flag and pecl-pdo-* ebuilds were removed.
349# You should use require_php_with_use pdo instead now.
350# @RETURN: die if feature is missing
308require_pdo() { 351require_pdo() {
309 has_php 352 has_php
310
311 # Do we have PHP5 installed?
312 if [[ "${PHP_VERSION}" == "4" ]] ; then
313 eerror
314 eerror "This package requires PDO."
315 eerror "PDO is only available for PHP 5."
316 eerror "You must install =dev-lang/php-5.0* 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"
320 eerror "turned on."
321 eerror
322 die "PHP 5 not installed"
323 fi
324 353
325 # Was PHP5 compiled with internal PDO support? 354 # Was PHP5 compiled with internal PDO support?
326 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then 355 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then
327 return 356 return
328 fi 357 else
329
330 # Ok, maybe PDO was built as an external extension?
331 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
333 fi
334
335 # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
336 if has_version 'dev-php5/pecl-pdo' ; then
337 return
338 fi
339
340 # If we get here, then we have no PDO support
341 eerror 358 eerror
342 eerror "No PDO extension for PHP found." 359 eerror "No PDO extension for PHP found."
343 eerror "Please note that PDO only exists for PHP 5." 360 eerror "Please note that PDO only exists for PHP 5."
344 eerror "Please install a PDO extension for PHP 5," 361 eerror "Please install a PDO extension for PHP 5."
345 eerror "you must install =dev-lang/php-5.0* with" 362 eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"."
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"
349 eerror "turned on."
350 eerror 363 eerror
351 die "No PDO extension for PHP 5 found" 364 die "No PDO extension for PHP 5 found"
365 fi
352} 366}
353 367
368# @FUNCTION: require_php_cli
369# @DESCRIPTION:
354# Determines which installed PHP version has the CLI SAPI enabled, 370# Determines which installed PHP version has the CLI SAPI enabled.
355# useful for PEAR stuff, or anything which needs to run PHP 371# Useful for PEAR stuff, or anything which needs to run PHP script
356# scripts depending on the CLI SAPI 372# depending on the CLI SAPI.
357 373# @RETURN: die if feature is missing
358require_php_cli() { 374require_php_cli() {
359 # If PHP_PKG is set, then we have remembered our PHP settings 375 # If PHP_PKG is set, then we have remembered our PHP settings
360 # from last time 376 # from last time
361 if [[ -n ${PHP_PKG} ]] ; then 377 if [[ -n ${PHP_PKG} ]] ; then
362 return 378 return
363 fi 379 fi
364 380
365 local PHP_PACKAGE_FOUND="" 381 local PHP_PACKAGE_FOUND=""
366 382
367 # Detect which PHP version we have installed
368 if has_version '=dev-lang/php-4*' ; then
369 PHP_PACKAGE_FOUND="1"
370 pkg="`best_version '=dev-lang/php-4*'`"
371 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
372 PHP_VERSION="4"
373 fi
374 fi
375
376 if has_version '=dev-lang/php-5*' ; then 383 if has_version '=dev-lang/php-5*' ; then
377 PHP_PACKAGE_FOUND="1" 384 PHP_PACKAGE_FOUND="1"
378 pkg="`best_version '=dev-lang/php-5*'`" 385 pkg="$(best_version '=dev-lang/php-5*')"
379 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then 386 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
380 PHP_VERSION="5" 387 PHP_VERSION="5"
381 fi 388 fi
382 fi 389 fi
383 390
384 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 391 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
385 die "Unable to find an installed dev-lang/php package" 392 die "Unable to find an installed dev-lang/php package"
386 fi 393 fi
387 394
388 if [[ -z ${PHP_VERSION} ]] ; then 395 if [[ -z ${PHP_VERSION} ]] ; then
389 die "No PHP CLI installed" 396 die "No PHP CLI installed. Re-emerge dev-lang/php with USE=cli."
390 fi 397 fi
391 398
392 # If we get here, then PHP_VERSION tells us which version of PHP we 399 # If we get here, then PHP_VERSION tells us which version of PHP we
393 # want to use 400 # want to use
394 uses_php${PHP_VERSION} 401 uses_php${PHP_VERSION}
395} 402}
396 403
404# @FUNCTION: require_php_cgi
405# @DESCRIPTION:
397# Determines which installed PHP version has the CGI SAPI enabled, 406# Determines which installed PHP version has the CGI SAPI enabled.
398# useful for anything which needs to run PHP scripts 407# Useful for anything which needs to run PHP scripts depending on the CGI SAPI.
399# depending on the CGI SAPI 408# @RETURN: die if feature is missing
400
401require_php_cgi() { 409require_php_cgi() {
402 # If PHP_PKG is set, then we have remembered our PHP settings 410 # If PHP_PKG is set, then we have remembered our PHP settings
403 # from last time 411 # from last time
404 if [[ -n ${PHP_PKG} ]] ; then 412 if [[ -n ${PHP_PKG} ]] ; then
405 return 413 return
406 fi 414 fi
407 415
408 local PHP_PACKAGE_FOUND="" 416 local PHP_PACKAGE_FOUND=""
409 417
410 # Detect which PHP version we have installed
411 if has_version '=dev-lang/php-4*' ; then
412 PHP_PACKAGE_FOUND="1"
413 pkg="`best_version '=dev-lang/php-4*'`"
414 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
415 PHP_VERSION="4"
416 fi
417 fi
418
419 if has_version '=dev-lang/php-5*' ; then 418 if has_version '=dev-lang/php-5*' ; then
420 PHP_PACKAGE_FOUND="1" 419 PHP_PACKAGE_FOUND="1"
421 pkg="`best_version '=dev-lang/php-5*'`" 420 pkg="$(best_version '=dev-lang/php-5*')"
422 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then 421 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
423 PHP_VERSION="5" 422 PHP_VERSION="5"
424 fi 423 fi
425 fi 424 fi
426 425
427 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 426 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
428 die "Unable to find an installed dev-lang/php package" 427 die "Unable to find an installed dev-lang/php package"
429 fi 428 fi
430 429
431 if [[ -z ${PHP_VERSION} ]] ; then 430 if [[ -z ${PHP_VERSION} ]] ; then
432 die "No PHP CGI installed" 431 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
433 fi 432 fi
434 433
435 # If we get here, then PHP_VERSION tells us which version of PHP we 434 # If we get here, then PHP_VERSION tells us which version of PHP we
436 # want to use 435 # want to use
437 uses_php${PHP_VERSION} 436 uses_php${PHP_VERSION}
438} 437}
439 438
439# @FUNCTION: require_sqlite
440# @DESCRIPTION:
440# Require a PHP built with SQLite support 441# Require a PHP built with SQLite support
441 442# @RETURN: die if feature is missing
442require_sqlite() { 443require_sqlite() {
443 has_php 444 has_php
444 445
445 # Has our PHP been built with SQLite support? 446 # Has our PHP been built with SQLite support?
446 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then 447 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then
447 return 448 return
448 fi
449
450 # Do we have pecl-sqlite installed for PHP4?
451 if [[ "${PHP_VERSION}" == "4" ]] ; then
452 if has_version 'dev-php4/pecl-sqlite' ; then
453 return
454 fi
455 fi 449 fi
456 450
457 # If we get here, then we don't have any SQLite support for PHP installed 451 # If we get here, then we don't have any SQLite support for PHP installed
458 eerror 452 eerror
459 eerror "No SQLite extension for PHP found." 453 eerror "No SQLite extension for PHP found."
462 eerror "'sqlite' USE flag when emerging dev-lang/php." 456 eerror "'sqlite' USE flag when emerging dev-lang/php."
463 eerror 457 eerror
464 die "No SQLite extension for PHP found" 458 die "No SQLite extension for PHP found"
465} 459}
466 460
461# @FUNCTION: require_gd
462# @DESCRIPTION:
467# Require a PHP built with GD support 463# Require a PHP built with GD support
468 464# @RETURN: die if feature is missing
469require_gd() { 465require_gd() {
470 has_php 466 has_php
471 467
472 # Do we have the internal GD support installed? 468 # Do we have the internal GD support installed?
473 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then 469 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then
494# Misc functions 490# Misc functions
495# 491#
496# These functions provide miscellaneous checks and functionality. 492# These functions provide miscellaneous checks and functionality.
497# ======================================================================== 493# ========================================================================
498 494
495# @FUNCTION: php_binary_extension
496# @DESCRIPTION:
499# Executes some checks needed when installing a binary PHP extension 497# Executes some checks needed when installing a binary PHP extension.
500
501php_binary_extension() { 498php_binary_extension() {
502 has_php 499 has_php
503 500
504 local PUSE_ENABLED="" 501 local PUSE_ENABLED=""
505 502
506 # Binary extensions do not support the change of PHP 503 # Binary extensions do not support the change of PHP
507 # API version, so they can't be installed when USE flags 504 # API version, so they can't be installed when USE flags
508 # are enabled wich change the PHP API version 505 # are enabled which change the PHP API version, they also
506 # don't provide correctly versioned symbols for our use
509 507
510 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then 508 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 || phpconfutils_built_with_use =${PHP_PKG} debug ; then
521 eerror 509 eerror
522 eerror "You cannot install binary PHP extensions" 510 eerror "You cannot install binary PHP extensions"
523 eerror "when the 'debug' USE flag is enabled!" 511 eerror "when the 'debug' USE flag is enabled!"
524 eerror "Please reemerge dev-lang/php with the" 512 eerror "Please reemerge dev-lang/php with the"
525 eerror "'debug' USE flag turned off." 513 eerror "'debug' USE flag turned off."
526 eerror 514 eerror
527 PUSE_ENABLED="1" 515 PUSE_ENABLED="1"
528 fi 516 fi
529 517
518 if has_concurrentmodphp ; then
519 eerror
520 eerror "You cannot install binary PHP extensions when"
521 eerror "the 'concurrentmodphp' USE flag is enabled!"
522 eerror "Please reemerge dev-lang/php with the"
523 eerror "'concurrentmodphp' USE flag turned off."
524 eerror
525 PUSE_ENABLED="1"
526 fi
527
530 if [[ -n ${PUSE_ENABLED} ]] ; then 528 if [[ -n ${PUSE_ENABLED} ]] ; then
531 die "'hardenedphp' and/or 'debug' USE flags turned on" 529 die "'debug' and/or 'concurrentmodphp' USE flags turned on!"
532 fi 530 fi
533} 531}
534 532
533# @FUNCTION: dodoc-php
534# @USAGE: <list of docs>
535# @DESCRIPTION:
535# Alternative to dodoc function for use in our PHP eclasses and 536# Alternative to dodoc function for use in our PHP eclasses and ebuilds.
536# ebuilds.
537# Stored here because depend.php gets always sourced everywhere 537# Stored here because depend.php gets always sourced everywhere in the PHP
538# in the PHP ebuilds and eclasses.
539# It simply is dodoc with a changed path to the docs. 538# ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
540# NOTE: no support for docinto is given! 539# NOTE: No support for docinto is provided!
541
542dodoc-php() { 540dodoc-php() {
543if [[ $# -lt 1 ]] ; then 541if [[ $# -lt 1 ]] ; then
544 echo "$0: at least one argument needed" 1>&2 542 echo "$0: at least one argument needed" 1>&2
545 exit 1 543 exit 1
546fi 544fi
547 545
548phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/" 546phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
549
550if [[ ! -d "${phpdocdir}" ]] ; then
551 install -d "${phpdocdir}"
552fi
553 547
554for x in $@ ; do 548for x in $@ ; do
555 if [[ -s "${x}" ]] ; then 549 if [[ -s "${x}" ]] ; then
556 install -m0644 "${x}" "${phpdocdir}" 550 insinto "${phpdocdir}"
551 doins "${x}"
557 gzip -f -9 "${phpdocdir}/${x##*/}" 552 gzip -f -9 "${D}/${phpdocdir}/${x##*/}"
558 elif [[ ! -e "${x}" ]] ; then 553 elif [[ ! -e "${x}" ]] ; then
559 echo "dodoc-php: ${x} does not exist" 1>&2 554 echo "dodoc-php: ${x} does not exist" 1>&2
560 fi 555 fi
561done 556done
562} 557}
558
559# @FUNCTION: dohtml-php
560# @USAGE: <list of html docs>
561# @DESCRIPTION:
562# Alternative to dohtml function for use in our PHP eclasses and ebuilds.
563# Stored here because depend.php gets always sourced everywhere in the PHP
564# ebuilds and eclasses. It simply is dohtml with a changed path to the docs.
565# NOTE: No support for [-a|-A|-p|-x] options is provided!
566dohtml-php() {
567if [[ $# -lt 1 ]] ; then
568 echo "$0: at least one argument needed" 1>&2
569 exit 1
570fi
571
572phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
573
574for x in $@ ; do
575 if [[ -s "${x}" ]] ; then
576 insinto "${phphtmldir}"
577 doins "${x}"
578 elif [[ ! -e "${x}" ]] ; then
579 echo "dohtml-php: ${x} does not exist" 1>&2
580 fi
581done
582}

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20