1 |
commit: 1db6f6ef37158bde0e248c5c84cc9c7f2aa10b93 |
2 |
Author: Brian Evans <grknight <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Mar 2 14:55:54 2017 +0000 |
4 |
Commit: Brian Evans <grknight <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Mar 2 14:55:54 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1db6f6ef |
7 |
|
8 |
eclass: new eclass php-pear-r2 to replace php-pear* |
9 |
|
10 |
eclass/php-pear-r2.eclass | 122 ++++++++++++++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 122 insertions(+) |
12 |
|
13 |
diff --git a/eclass/php-pear-r2.eclass b/eclass/php-pear-r2.eclass |
14 |
new file mode 100644 |
15 |
index 00000000000..48ff30355f9 |
16 |
--- /dev/null |
17 |
+++ b/eclass/php-pear-r2.eclass |
18 |
@@ -0,0 +1,122 @@ |
19 |
+# Copyright 1999-2017 Gentoo Foundation |
20 |
+# Distributed under the terms of the GNU General Public License v2 |
21 |
+ |
22 |
+# @ECLASS: php-pear-r2.eclass |
23 |
+# @MAINTAINER: |
24 |
+# Gentoo PHP Team <php-bugs@g.o> |
25 |
+# @AUTHOR: |
26 |
+# Author: Brian Evans <grknight@g.o> |
27 |
+# @BLURB: Provides means for an easy installation of PEAR packages. |
28 |
+# @DESCRIPTION: |
29 |
+# This eclass provides means for an easy installation of PEAR packages. |
30 |
+# For more information on PEAR, see https://pear.php.net/ |
31 |
+# Note that this eclass doesn't handle dependencies of PEAR packages |
32 |
+# on purpose; please use (R)DEPEND to define them correctly! |
33 |
+ |
34 |
+EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm |
35 |
+ |
36 |
+case "${EAPI:-0}" in |
37 |
+ 6) |
38 |
+ ;; |
39 |
+ *) |
40 |
+ die "Unsupported EAPI=${EAPI} for ${ECLASS}" |
41 |
+ ;; |
42 |
+esac |
43 |
+ |
44 |
+RDEPEND=">=dev-php/pear-1.8.1" |
45 |
+ |
46 |
+# @ECLASS-VARIABLE: PHP_PEAR_PKG_NAME |
47 |
+# @DESCRIPTION: |
48 |
+# Set this if the PEAR package name differs from ${PN/PEAR-/} |
49 |
+# (generally shouldn't be the case). |
50 |
+: ${PHP_PEAR_PKG_NAME:=${PN/PEAR-/}} |
51 |
+ |
52 |
+# @ECLASS-VARIABLE: PEAR_PV |
53 |
+# @DESCRIPTION: |
54 |
+# Set in ebuild if the ${PV} breaks SRC_URI for alpha/beta/rc versions |
55 |
+: ${PEAR_PV:=${PV}} |
56 |
+ |
57 |
+PEAR_P="${PHP_PEAR_PKG_NAME}-${PEAR_PV}" |
58 |
+ |
59 |
+# @ECLASS-VARIABLE: PHP_PEAR_DOMAIN |
60 |
+# @DESCRIPTION: |
61 |
+# Set in ebuild to the domain name of the channel if not pear.php.net |
62 |
+# When the domain is not pear.php.net, setting the SRC_URI is required |
63 |
+: ${PHP_PEAR_DOMAIN:=pear.php.net} |
64 |
+ |
65 |
+# @ECLASS-VARIABLE: PHP_PEAR_CHANNEL |
66 |
+# @DEFAULT_UNSET |
67 |
+# @DESCRIPTION: |
68 |
+# Set in ebuild to the path of channel.xml file which is necessary for |
69 |
+# 3rd party pear channels (besides pear.php.net) to be added to PEAR |
70 |
+# Default is unset to do nothing |
71 |
+ |
72 |
+# set default SRC_URI for pear.php.net packages |
73 |
+if [[ "${PHP_PEAR_DOMAIN}" == "pear.php.net" ]] ; then |
74 |
+ SRC_URI="https://pear.php.net/get/${PEAR_P}.tgz" |
75 |
+fi |
76 |
+ |
77 |
+: ${HOMEPAGE:=https://${PHP_PEAR_DOMAIN}/package/${PHP_PEAR_PKG_NAME}} |
78 |
+ |
79 |
+S="${WORKDIR}/${PEAR_P}" |
80 |
+ |
81 |
+# @FUNCTION php-pear-r2_install_packagexml |
82 |
+# @DESCRIPTION: |
83 |
+# Copies the package2.xml or package.xml file and, optionally, the channel.xml |
84 |
+# file to a Gentoo-specific location so that pkg_postinst can install the package |
85 |
+# to the local PEAR database |
86 |
+php-pear-r2_install_packagexml() { |
87 |
+ insinto /usr/share/php/.packagexml |
88 |
+ if [[ -f "${WORKDIR}/package2.xml" ]] ; then |
89 |
+ newins "${WORKDIR}/package2.xml" "${PEAR_P}.xml" |
90 |
+ elif [[ -f "${WORKDIR}/package.xml" ]] ; then |
91 |
+ newins "${WORKDIR}/package.xml" "${PEAR_P}.xml" |
92 |
+ fi |
93 |
+ |
94 |
+ if [[ -f "${PHP_PEAR_CHANNEL}" ]] ; then |
95 |
+ newins "${PHP_PEAR_CHANNEL}" "${PEAR_P}-channel.xml" |
96 |
+ fi |
97 |
+} |
98 |
+ |
99 |
+# @FUNCTION: php-pear-r2_src_install |
100 |
+# @DESCRIPTION: |
101 |
+# Takes care of standard install for PEAR packages. |
102 |
+# Override src_install if the package installs more than "${PHP_PEAR_PKG_NAME}.php" |
103 |
+# or "${PHP_PEAR_PKG_NAME%%_*}/" as a directory |
104 |
+php-pear-r2_src_install() { |
105 |
+ insinto /usr/share/php |
106 |
+ [[ -f "${PHP_PEAR_PKG_NAME}.php" ]] && doins "${PHP_PEAR_PKG_NAME}.php" |
107 |
+ [[ -d "${PHP_PEAR_PKG_NAME%%_*}" ]] && doins -r "${PHP_PEAR_PKG_NAME%%_*}/" |
108 |
+ php-pear-r2_install_packagexml |
109 |
+ einstalldocs |
110 |
+} |
111 |
+ |
112 |
+# @FUNCTION: php-pear-r2_pkg_postinst |
113 |
+# @DESCRIPTION: |
114 |
+# Register package with the local PEAR database. |
115 |
+php-pear-r2_pkg_postinst() { |
116 |
+ # Add unknown channels |
117 |
+ if [[ -f "${EROOT}usr/share/php/.packagexml/${PEAR_P}-channel.xml" ]] ; then |
118 |
+ if "${EROOT}usr/bin/peardev" channel-info "${PHP_PEAR_DOMAIN}" &> /dev/null; then |
119 |
+ "${EROOT}usr/bin/peardev" channel-add \ |
120 |
+ "${EROOT}usr/share/php/.packagexml/${PEAR_PN}-channel.xml" \ |
121 |
+ || einfo "Ignore any errors about existing channels" |
122 |
+ fi |
123 |
+ fi |
124 |
+ |
125 |
+ # Register the package from the package{,2}.xml file |
126 |
+ # It is not critical to complete so only warn on failure |
127 |
+ if [[ -f "${EROOT}usr/share/php/.packagexml/${PEAR_P}.xml" ]] ; then |
128 |
+ "${EROOT}usr/bin/peardev" install -nrO --force \ |
129 |
+ "${EROOT}usr/share/php/.packagexml/${PEAR_P}.xml" 2> /dev/null \ |
130 |
+ || ewarn "Failed to insert package into local PEAR database" |
131 |
+ fi |
132 |
+} |
133 |
+ |
134 |
+# @FUNCTION: php-pear-r2_pkg_postrm |
135 |
+# @DESCRIPTION: |
136 |
+# Deregister package from the local PEAR database |
137 |
+php-pear-r2_pkg_postrm() { |
138 |
+ # Uninstall known dependency |
139 |
+ "${EROOT}usr/bin/peardev" uninstall -nrO "${PHP_PEAR_DOMAIN}/${PHP_PEAR_PKG_NAME}" |
140 |
+} |