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

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.35

  ViewVC Help
Powered by ViewVC 1.1.20