kernel-2.eclass: avoid lexicographical compare on versions, bug #705246
[gentoo.git] / eclass / php-ext-pecl-r3.eclass
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: php-ext-pecl-r3.eclass
5 # @MAINTAINER:
6 # Gentoo PHP team <php-bugs@gentoo.org>
7 # @BLURB: A uniform way to install PECL extensions
8 # @DESCRIPTION:
9 # This eclass should be used by all dev-php/pecl-* ebuilds as a uniform
10 # way of installing PECL extensions. For more information about PECL,
11 # see https://pecl.php.net/
12
13 # @ECLASS-VARIABLE: PHP_EXT_PECL_PKG
14 # @DESCRIPTION:
15 # Set in ebuild before inheriting this eclass if the tarball name
16 # differs from ${PN/pecl-/} so that SRC_URI and HOMEPAGE get set
17 # correctly by the eclass.
18 #
19 # Setting this variable manually also affects PHP_EXT_NAME and ${S}
20 # unless you override those in ebuild. If that is not desired, please
21 # use PHP_EXT_PECL_FILENAME instead.
22 [[ -z "${PHP_EXT_PECL_PKG}" ]] && PHP_EXT_PECL_PKG="${PN/pecl-/}"
23
24 # @ECLASS-VARIABLE: PHP_EXT_PECL_FILENAME
25 # @DEFAULT_UNSET
26 # @DESCRIPTION:
27 # Set in ebuild before inheriting this eclass if the tarball name
28 # differs from "${PN/pecl-/}-${PV}.tgz" so that SRC_URI gets set
29 # correctly by the eclass.
30 #
31 # Unlike PHP_EXT_PECL_PKG, setting this variable does not affect
32 # HOMEPAGE, PHP_EXT_NAME or ${S}.
33
34
35 # Set PHP_EXT_NAME for php-ext-source-r3.eclass.
36 [[ -z "${PHP_EXT_NAME}" ]] && PHP_EXT_NAME="${PHP_EXT_PECL_PKG}"
37
38 # Try to guess the upstream name of the package/version. We only use
39 # this variable temporarily before unsetting it.
40 PHP_EXT_PECL_PKG_V="${PHP_EXT_PECL_PKG}-${PV/_/}"
41
42 # It's important that we determine and set $S before we inherit below.
43 S="${WORKDIR}/${PHP_EXT_PECL_PKG_V}"
44
45 inherit php-ext-source-r3
46
47 EXPORT_FUNCTIONS src_install src_test
48
49 if [[ -z "${PHP_EXT_PECL_FILENAME}" ]] ; then
50         SRC_URI="https://pecl.php.net/get/${PHP_EXT_PECL_PKG_V}.tgz"
51 else
52         SRC_URI="https://pecl.php.net/get/${PHP_EXT_PECL_FILENAME}"
53 fi
54
55 # Don't leave this laying around in the environment.
56 unset PHP_EXT_PECL_PKG_V
57
58 HOMEPAGE="https://pecl.php.net/${PHP_EXT_PECL_PKG}"
59
60
61 # @FUNCTION: php-ext-pecl-r3_src_install
62 # @DESCRIPTION:
63 # Install a standard PECL package. First we delegate to
64 # php-ext-source-r3.eclass, and then we attempt to install examples
65 # found in a standard location.
66 php-ext-pecl-r3_src_install() {
67         php-ext-source-r3_src_install
68
69         if in_iuse examples && use examples ; then
70                 dodoc -r examples
71         fi
72 }
73
74
75 # @FUNCTION: php-ext-pecl-r3_src_test
76 # @DESCRIPTION:
77 # Run tests delivered with the PECL package. Phpize will have generated
78 # a run-tests.php file to be executed by `make test`. We only need to
79 # force the test suite to run in non-interactive mode.
80 php-ext-pecl-r3_src_test() {
81         for slot in $(php_get_slots); do
82                 php_init_slot_env "${slot}"
83                 NO_INTERACTION="yes" emake test
84         done
85 }