Gentoo Archives: gentoo-commits

From: "Ole Markus With (olemarkus)" <olemarkus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: php-ext-base-r1.eclass php-ext-pecl-r2.eclass php-ext-source-r2.eclass
Date: Wed, 06 Oct 2010 09:03:07
Message-Id: 20101006082551.A065120051@flycatcher.gentoo.org
1 olemarkus 10/10/06 08:25:51
2
3 Modified: php-ext-base-r1.eclass
4 Added: php-ext-pecl-r2.eclass php-ext-source-r2.eclass
5 Log:
6 Added eclasses required for minor version slotting of PHP
7 Changed php-ext-base-r1 to require dev-lang/php:5 to prevent mixing of
8 old-style slotting and new-style
9
10 Revision Changes Path
11 1.12 eclass/php-ext-base-r1.eclass
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/php-ext-base-r1.eclass?rev=1.12&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/php-ext-base-r1.eclass?rev=1.12&content-type=text/plain
15 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/php-ext-base-r1.eclass?r1=1.11&r2=1.12
16
17 Index: php-ext-base-r1.eclass
18 ===================================================================
19 RCS file: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v
20 retrieving revision 1.11
21 retrieving revision 1.12
22 diff -u -r1.11 -r1.12
23 --- php-ext-base-r1.eclass 26 Jul 2010 16:19:00 -0000 1.11
24 +++ php-ext-base-r1.eclass 6 Oct 2010 08:25:51 -0000 1.12
25 @@ -1,6 +1,6 @@
26 # Copyright 1999-2007 Gentoo Foundation
27 # Distributed under the terms of the GNU General Public License v2
28 -# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v 1.11 2010/07/26 16:19:00 mabi Exp $
29 +# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v 1.12 2010/10/06 08:25:51 olemarkus Exp $
30 #
31 # Author: Tal Peer <coredumb@g.o>
32 # Author: Stuart Herbert <stuart@g.o>
33 @@ -18,6 +18,8 @@
34 # Combined with php-ext-source-r1, we have a standardised solution for supporting
35 # PHP extensions.
36
37 +DEPEND="dev-lang/php:5"
38 +
39 inherit depend.php
40
41 EXPORT_FUNCTIONS src_install
42
43
44
45 1.1 eclass/php-ext-pecl-r2.eclass
46
47 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/php-ext-pecl-r2.eclass?rev=1.1&view=markup
48 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/php-ext-pecl-r2.eclass?rev=1.1&content-type=text/plain
49
50 Index: php-ext-pecl-r2.eclass
51 ===================================================================
52 # Copyright 1999-2007 Gentoo Foundation
53 # Distributed under the terms of the GNU General Public License v2
54 # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-pecl-r2.eclass,v 1.1 2010/10/06 08:25:51 olemarkus Exp $
55 #
56 # Author: Tal Peer <coredumb@g.o>
57 # Author: Luca Longinotti <chtekk@g.o>
58 # Author: Jakub Moc <jakub@g.o>
59
60 # @ECLASS: php-ext-pecl-r1.eclass
61 # @MAINTAINER:
62 # Gentoo PHP team <php-bugs@g.o>
63 # @BLURB: A uniform way of installing PECL extensions
64 # @DESCRIPTION:
65 # This eclass should be used by all dev-php[45]/pecl-* ebuilds
66 # as a uniform way of installing PECL extensions.
67 # For more information about PECL, see http://pecl.php.net/
68
69 # @ECLASS-VARIABLE: PHP_EXT_PECL_PKG
70 # @DESCRIPTION:
71 # Set in ebuild before inheriting this eclass if the tarball name
72 # differs from ${PN/pecl-/} so that SRC_URI and HOMEPAGE gets set
73 # correctly by the eclass.
74 #
75 # Setting this variable manually also affects PHP_EXT_NAME and ${S}
76 # unless you override those in ebuild. Also see PHP_EXT_PECL_FILENAME
77 # if this is not desired for whatever reason.
78
79 # @ECLASS-VARIABLE: PHP_EXT_PECL_FILENAME
80 # @DESCRIPTION:
81 # Set in ebuild before inheriting this eclass if the tarball name
82 # differs from ${PN/pecl-/} so that SRC_URI gets set correctly by
83 # the eclass.
84 #
85 # Unlike PHP_EXT_PECL_PKG, setting this variable does not affect
86 # HOMEPAGE, PHP_EXT_NAME or ${S}.
87
88
89 [[ -z "${PHP_EXT_PECL_PKG}" ]] && PHP_EXT_PECL_PKG="${PN/pecl-/}"
90
91 PECL_PKG="${PHP_EXT_PECL_PKG}"
92 MY_PV="${PV/_/}"
93 PECL_PKG_V="${PECL_PKG}-${MY_PV}"
94
95 [[ -z "${PHP_EXT_NAME}" ]] && PHP_EXT_NAME="${PECL_PKG}"
96
97 inherit php-ext-source-r2
98
99 EXPORT_FUNCTIONS src_compile src_install src_test
100
101 if [[ -n "${PHP_EXT_PECL_FILENAME}" ]] ; then
102 FILENAME="${PHP_EXT_PECL_FILENAME}-${MY_PV}.tgz"
103 else
104 FILENAME="${PECL_PKG_V}.tgz"
105 fi
106
107 SRC_URI="http://pecl.php.net/get/${FILENAME}"
108 HOMEPAGE="http://pecl.php.net/${PECL_PKG}"
109
110 S="${WORKDIR}/${PECL_PKG_V}"
111
112 # @FUNCTION: php-ext-pecl-r1_src_compile
113 # @DESCRIPTION:
114 # Takes care of standard compile for PECL packages.
115 php-ext-pecl-r2_src_compile() {
116 php-ext-source-r2_src_compile
117 }
118
119 # @FUNCTION: php-ext-pecl-r1_src_install
120 # @DESCRIPTION:
121 # Takes care of standard install for PECL packages.
122 # You can also simply add examples to IUSE to automagically install
123 # examples supplied with the package.
124
125 # @VARIABLE: DOCS
126 # @DESCRIPTION:
127 # Set in ebuild if you wish to install additional, package-specific documentation.
128 php-ext-pecl-r2_src_install() {
129 php-ext-source-r2_src_install
130
131 for doc in ${DOCS} "${WORKDIR}"/package.xml CREDITS ; do
132 [[ -s ${doc} ]] && dodoc ${doc}
133 done
134
135 if has examples ${IUSE} && use examples ; then
136 insinto /usr/share/doc/${CATEGORY}/${PF}/examples
137 doins -r examples/*
138 fi
139 }
140
141
142 # @FUNCTION: php-ext-pecl-r2_src_test
143 # @DESCRIPTION:
144 # Takes care of running any tests delivered with the PECL package.
145 # Testing is somewhat standardized across pecl extensions through phpize's
146 # run-tests.php - unfortunatly there are some quirks we need to work around
147 php-ext-pecl-r2_src_test() {
148
149 for slot in `php_get_slots`; do
150 NO_INTERACTION="yes" emake test
151 done
152
153 }
154
155
156
157 1.1 eclass/php-ext-source-r2.eclass
158
159 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/php-ext-source-r2.eclass?rev=1.1&view=markup
160 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/php-ext-source-r2.eclass?rev=1.1&content-type=text/plain
161
162 Index: php-ext-source-r2.eclass
163 ===================================================================
164 # Copyright 1999-2007 Gentoo Foundation
165 # Distributed under the terms of the GNU General Public License v2
166 # $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-source-r2.eclass,v 1.1 2010/10/06 08:25:51 olemarkus Exp $
167 #
168 # Author: Tal Peer <coredumb@g.o>
169 # Author: Stuart Herbert <stuart@g.o>
170 # Author: Luca Longinotti <chtekk@g.o>
171 # Author: Jakub Moc <jakub@g.o> (documentation)
172 # Author: Ole Markus With <olemarkus@g.o>
173
174 # @ECLASS: php-ext-source-r2.eclass
175 # @MAINTAINER:
176 # Gentoo PHP team <php-bugs@g.o>
177 # @BLURB: A unified interface for compiling and installing standalone PHP extensions.
178 # @DESCRIPTION:
179 # This eclass provides a unified interface for compiling and installing standalone
180 # PHP extensions (modules).
181
182 inherit flag-o-matic autotools
183
184 EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install
185
186 # @ECLASS-VARIABLE: PHP_EXT_NAME
187 # @DESCRIPTION:
188 # The extension name. This must be set, otherwise the eclass dies.
189 # Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild
190 # inherits that eclass, you must set this manually before inherit.
191 [[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
192
193 DEPEND=">=sys-devel/m4-1.4.3
194 >=sys-devel/libtool-1.5.18"
195 RDEPEND=""
196
197 # Because of USE deps, we require at least EAPI 2
198 case ${EAPI} in
199 2|3) ;;
200 *)
201 die "php-ext-source-r2 is not compatible with EAPI=${EAPI}"
202 esac
203
204 # @ECLASS-VARIABLE: PHP_EXT_NAME
205 # @DESCRIPTION:
206 # The extension name. This must be set, otherwise the eclass dies.
207 # Only automagically set by php-ext-pecl-r2.eclass, so unless your ebuild
208 # inherits that eclass, you must set this manually before inherit.
209 [[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
210
211 # @ECLASS-VARIABLE: PHP_EXT_INI
212 # @DESCRIPTION:
213 # Controls whether or not to add a line to php.ini for the extension.
214 # Defaults to "yes" and should not be changed in most cases.
215 [[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
216
217 # @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
218 # @DESCRIPTION:
219 # Controls whether the extension is a ZendEngine extension or not.
220 # Defaults to "no" and if you don't know what is it, you don't need it.
221 [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
222
223 # @ECLASS-VARIABLE: USE_PHP
224 # @DESCRIPTION:
225 # Lists the PHP slots compatibile the extension is compatibile with
226 [[ -z "$USE_PHP" ]] && USE_PHP="php5-2 php5-3"
227
228 for target in $USE_PHP; do
229 IUSE="${IUSE} php_targets_$target"
230 done
231
232 #Make sure at least one target is installed. Abuses USE dependencies.
233 for target in $USE_PHP; do
234 target=${target/+}
235 SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]"
236 slot=${target/php}
237 slot=${slot/-/.}
238 PHPDEPEND="$PHPDEPEND php_target_$target? ( dev-lang/php:${slot} )"
239 done
240
241 RDEPEND="${RDEPEND}
242 || ( $SELFDEPEND )
243 $PHPDEPEND"
244
245
246 # @FUNCTION: php-ext-source-r2_src_unpack
247 # @DESCRIPTION:
248 # runs standard src_unpack + _phpize
249 #
250 # @VARIABLE: PHP_EXT_SKIP_PHPIZE
251 # @DESCRIPTION:
252 # phpize will be run by default for all ebuilds that use
253 # php-ext-source-r1_src_unpack
254 # Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize.
255 php-ext-source-r2_src_unpack() {
256 unpack ${A}
257 local slot orig_s="$S"
258 for slot in $(php_get_slots); do
259 cp -r "$orig_s" "${WORKDIR}/$slot"
260 php_init_slot_env $slot
261 if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
262 php-ext-source-r2_phpize
263 fi
264 done
265 }
266
267 # @FUNCTION php-ext-source-r2_phpize
268 # @DESCRIPTION:
269 # Runs phpize and autotools in addition to the standard src_unpack
270 php-ext-source-r2_phpize() {
271 # Create configure out of config.m4
272 # I wish I could run this to solve #329071, but I cannot
273 #autotools_run_tool ${PHPIZE}
274 ${PHPIZE}
275 # force run of libtoolize and regeneration of related autotools
276 # files (bug 220519)
277 rm aclocal.m4
278 eautoreconf
279 }
280
281 # @FUNCTION: php-ext-source-r2_src_configure
282 # @DESCRIPTION:
283 # Takes care of standard configure for PHP extensions (modules).
284 #
285 # @VARIABLE: my_conf
286 # @DESCRIPTION:
287 # Set this in the ebuild to pass configure options to econf.
288 php-ext-source-r2_src_configure() {
289 local slot
290 for slot in $(php_get_slots); do
291 php_init_slot_env $slot
292 # Set the correct config options
293 # We cannot use econf here, phpize/php-config deals with setting
294 # --prefix etc to whatever the php slot was configured to use
295 ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile"
296 done
297 }
298
299 # @FUNCTION: php-ext-source-r2_src_compile
300 # @DESCRIPTION:
301 # Takes care of standard compile for PHP extensions (modules).
302 php-ext-source-r2_src_compile() {
303 # net-snmp creates this file #324739
304 addpredict /usr/share/snmp/mibs/.index
305 # shm extension createss a semaphore file #173574
306 addpredict /session_mm_cli0.sem
307 local slot
308 for slot in $(php_get_slots); do
309 php_init_slot_env $slot
310 emake || die "Unable to make code"
311
312 done
313 }
314
315 # @FUNCTION: php-ext-source-r1_src_install
316 # @DESCRIPTION:
317 # Takes care of standard install for PHP extensions (modules).
318
319 # @VARIABLE: DOCS
320 # @DESCRIPTION:
321 # Set in ebuild if you wish to install additional, package-specific documentation.
322 php-ext-source-r2_src_install() {
323 local slot
324 for slot in $(php_get_slots); do
325 php_init_slot_env $slot
326
327 # Let's put the default module away
328 insinto "${EXT_DIR}"
329 newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension"
330
331 for doc in ${DOCS} ; do
332 [[ -s ${doc} ]] && dodoc ${doc}
333 done
334
335 done
336 php-ext-source-r2_createinifiles
337 }
338
339
340 php_get_slots() {
341 local s
342 local slot
343 for slot in $USE_PHP; do
344 use php_targets_$slot && s+=" ${slot/-/.}"
345 done
346 echo $s
347 }
348
349 php_init_slot_env() {
350 libdir=$(get_libdir)
351
352 PHPIZE="/usr/${libdir}/$1/bin/phpize"
353 PHPCONFIG="/usr/${libdir}/$1/bin/php-config"
354 PHPCLI="/usr/${libdir}/$1/bin/php"
355 PHPCGI="/usr/${libdir}/$1/bin/php-cgi"
356 PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
357 PHPPREFIX="/usr/${libdir}/$slot"
358 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
359
360 S="${WORKDIR}/$1"
361 cd $S
362 }
363
364 php-ext-source-r2_buildinilist() {
365 # Work out the list of <ext>.ini files to edit/add to
366 if [[ -z "${PHPSAPILIST}" ]] ; then
367 PHPSAPILIST="apache2 cli cgi fpm"
368 fi
369
370 PHPINIFILELIST=""
371
372 for x in ${PHPSAPILIST} ; do
373 if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then
374 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
375 fi
376 done
377 }
378
379 # @FUNCTION: php-ext-source-r2_createinifiles
380 # @DESCRIPTION:
381 # Builds ini files for every enabled slot and SAPI
382 php-ext-source-r2_createinifiles() {
383 local slot
384 for slot in $(php_get_slots); do
385 php_init_slot_env $slot
386 # Pull in the PHP settings
387
388 # Build the list of <ext>.ini files to edit/add to
389 php-ext-source-r2_buildinilist $slot
390
391 # Add the needed lines to the <ext>.ini files
392 if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
393 php-ext-source-r2_addextension "${PHP_EXT_NAME}.so"
394 fi
395
396 # Symlink the <ext>.ini files from ext/ to ext-active/
397 for inifile in ${PHPINIFILELIST} ; do
398 inidir="${inifile/${PHP_EXT_NAME}.ini/}"
399 inidir="${inidir/ext/ext-active}"
400 dodir "/${inidir}"
401 dosym "/${inifile}" "/${inifile/ext/ext-active}"
402 done
403
404 # Add support for installing PHP files into a version dependant directory
405 PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}"
406 done
407 }
408
409 php-ext-source-r2_addextension() {
410 if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
411 # We need the full path for ZendEngine extensions
412 # and we need to check for debugging enabled!
413 if has_zts ; then
414 if has_debug ; then
415 ext_type="zend_extension_debug_ts"
416 else
417 ext_type="zend_extension_ts"
418 fi
419 ext_file="${EXT_DIR}/$1"
420 else
421 if has_debug ; then
422 ext_type="zend_extension_debug"
423 else
424 ext_type="zend_extension"
425 fi
426 ext_file="${EXT_DIR}/$1"
427 fi
428
429 # php-5.3 unifies zend_extension loading and just requires the
430 # zend_extension keyword with no suffix
431 # TODO: drop previous code and this check once <php-5.3 support is
432 # discontinued
433 if has_version '>=dev-lang/php-5.3' ; then
434 ext_type="zend_extension"
435 fi
436 else
437 # We don't need the full path for normal extensions!
438 ext_type="extension"
439 ext_file="$1"
440 fi
441
442 php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added"
443 }
444
445 # $1 - Setting name
446 # $2 - Setting value
447 # $3 - File to add to
448 # $4 - Sanitized text to output
449 php-ext-source-r2_addtoinifile() {
450 if [[ ! -d $(dirname $3) ]] ; then
451 mkdir -p $(dirname $3)
452 fi
453
454 # Are we adding the name of a section?
455 if [[ ${1:0:1} == "[" ]] ; then
456 echo "$1" >> "$3"
457 my_added="$1"
458 else
459 echo "$1=$2" >> "$3"
460 my_added="$1=$2"
461 fi
462
463 if [[ -z "$4" ]] ; then
464 einfo "Added '$my_added' to /$3"
465 else
466 einfo "$4 to /$3"
467 fi
468
469 insinto /$(dirname $3)
470 doins "$3"
471 }
472
473 # @FUNCTION: php-ext-source-r2_addtoinifiles
474 # @USAGE: <setting name> <setting value> [message to output]; or just [section name]
475 # @DESCRIPTION:
476 # Add value settings to php.ini file installed by the extension (module).
477 # You can also add a [section], see examples below.
478 #
479 # @CODE
480 # Add some settings for the extension:
481 #
482 # php-ext-source-r2_addtoinifiles "zend_optimizer.optimization_level" "15"
483 # php-ext-source-r2_addtoinifiles "zend_optimizer.enable_loader" "0"
484 # php-ext-source-r2_addtoinifiles "zend_optimizer.disable_licensing" "0"
485 #
486 # Adding values to a section in php.ini file installed by the extension:
487 #
488 # php-ext-source-r2_addtoinifiles "[Debugger]"
489 # php-ext-source-r2_addtoinifiles "debugger.enabled" "on"
490 # php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on"
491 # @CODE
492 php-ext-source-r2_addtoinifiles() {
493 for x in ${PHPINIFILELIST} ; do
494 php-ext-source-r2_addtoinifile "$1" "$2" "$x" "$3"
495 done
496 }