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