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

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.34

  ViewVC Help
Powered by ViewVC 1.1.20