1 |
W dniu 28.02.2017, wto o godzinie 10∶43 -0500, użytkownik Brian Evans |
2 |
napisał: |
3 |
> # Copyright 1999-2017 Gentoo Foundation |
4 |
> # Distributed under the terms of the GNU General Public License v2 |
5 |
> # $Id$ |
6 |
> |
7 |
> # @ECLASS: php-pear-r2.eclass |
8 |
> # @MAINTAINER: |
9 |
> # Gentoo PHP Team <php-bugs@g.o> |
10 |
> # @AUTHOR: |
11 |
> # Author: Brian Evans <grknight@g.o> |
12 |
> # @BLURB: Provides means for an easy installation of PEAR packages. |
13 |
> # @DESCRIPTION: |
14 |
> # This eclass provides means for an easy installation of PEAR packages. |
15 |
> # For more information on PEAR, see https://pear.php.net/ |
16 |
> # Note that this eclass doesn't handle dependencies of PEAR packages |
17 |
> # on purpose; please use (R)DEPEND to define them correctly! |
18 |
> |
19 |
> EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm |
20 |
> |
21 |
> case "${EAPI:-0}" in |
22 |
|
23 |
You don't have to quote arguments to 'case', it's a builtin. |
24 |
|
25 |
> 6) |
26 |
> ;; |
27 |
> *) |
28 |
> die "Unsupported EAPI=${EAPI} for ${ECLASS}" |
29 |
> ;; |
30 |
> esac |
31 |
> |
32 |
> RDEPEND=">=dev-php/pear-1.8.1" |
33 |
> |
34 |
> # @ECLASS-VARIABLE: PHP_PEAR_PKG_NAME |
35 |
> # @DESCRIPTION: |
36 |
> # Set this if the PEAR package name differs from ${PN/PEAR-/} |
37 |
> # (generally shouldn't be the case). |
38 |
> [[ -z "${PHP_PEAR_PKG_NAME}" ]] && PHP_PEAR_PKG_NAME="${PN/PEAR-/}" |
39 |
|
40 |
: ${PHP_PEAR_PKG_NAME:=${PN/PEAR-/}} |
41 |
|
42 |
Funny thing is, you're already using that syntax below ;-). |
43 |
|
44 |
> |
45 |
> # @ECLASS-VARIABLE: PEAR_PV |
46 |
> # @DESCRIPTION: |
47 |
> # Set in ebuild if the ${PV} breaks SRC_URI for alpha/beta/rc versions |
48 |
> : ${PEAR_PV:=${PV}} |
49 |
> |
50 |
> PEAR_PN="${PHP_PEAR_PKG_NAME}-${PEAR_PV}" |
51 |
|
52 |
Why do you name it 'PN' if it includes version? That's a bit confusing. |
53 |
|
54 |
> |
55 |
> # @ECLASS-VARIABLE: PHP_PEAR_URI |
56 |
> # @DESCRIPTION: |
57 |
> # Set in ebuild to the domain name of the channel if not pear.php.net |
58 |
> : ${PHP_PEAR_URI:=pear.php.net} |
59 |
|
60 |
Why do you name it 'URI' if it is just the domain? Definitely confusing. |
61 |
|
62 |
> |
63 |
> : ${SRC_URI:=https://${PHP_PEAR_URI}/get/${PEAR_PN}.tgz} |
64 |
> : ${HOMEPAGE:=https://${PHP_PEAR_URI}/package/${PHP_PEAR_PKG_NAME}} |
65 |
|
66 |
This triggers undefined behavior since SRC_URI is stacked. The 'if |
67 |
unset' part is not really meaningful. Depending on the package manager |
68 |
implementation, the variable will be always set (because the PM will |
69 |
unset SRC_URI on inherit), or may be randomly unset (e.g. if another |
70 |
eclass put something in SRC_URI before this one). |
71 |
|
72 |
> |
73 |
> S="${WORKDIR}/${PEAR_PN}" |
74 |
> |
75 |
> # @FUNCTION php-pear-r2_install_packagexml |
76 |
> # @DESCRIPTION: |
77 |
> # Copies the package{,2}.xml file and, optionally, the channel.xml file |
78 |
> # to a hidden directory so that pkg_postinst can install the package |
79 |
> # to the local PEAR database |
80 |
|
81 |
This description is confusing. 'package{,2}.xml' suggests that both will |
82 |
be installed, not either of the two. Also, this 'hidden directory' |
83 |
sounds like a lot of magic. Maybe that should be 'Gentoo-specific |
84 |
location' or something like that? |
85 |
|
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_PN}.xml" |
90 |
> elif [[ -f "${WORKDIR}/package.xml" ]] ; then |
91 |
> newins "${WORKDIR}/package.xml" "${PEAR_PN}.xml" |
92 |
> fi |
93 |
> |
94 |
> if [[ -f "${PHP_PEAR_CHANNEL}" ]] ; then |
95 |
|
96 |
Unless I'm mistaken, you are not setting this variable. |
97 |
|
98 |
> newins "${PHP_PEAR_CHANNEL}" "${PEAR_PN}-channel.xml" |
99 |
> fi |
100 |
> } |
101 |
> |
102 |
> # @FUNCTION: php-pear-r2_src_install |
103 |
> # @DESCRIPTION: |
104 |
> # Takes care of standard install for PEAR packages. |
105 |
> # Override src_install if the package installs more than "${PHP_PEAR_PKG_NAME}.php" |
106 |
> # or "${PHP_PEAR_PKG_NAME%%_*}/" as a directory |
107 |
> php-pear-r2_src_install() { |
108 |
> insinto /usr/share/php |
109 |
> [[ -f "${PHP_PEAR_PKG_NAME}.php" ]] && doins "${PHP_PEAR_PKG_NAME}.php" |
110 |
> [[ -d "${PHP_PEAR_PKG_NAME%%_*}" ]] && doins -r "${PHP_PEAR_PKG_NAME%%_*}/" |
111 |
> php-pear-r2_install_packagexml |
112 |
> einstalldocs |
113 |
> } |
114 |
> |
115 |
> # @FUNCTION: php-pear-r2_pkg_postinst |
116 |
> # @DESCRIPTION: |
117 |
> # Register package with the local PEAR database. |
118 |
> php-pear-r2_pkg_postinst() { |
119 |
> # Add unknown channels |
120 |
> if [[ -f "${EROOT}usr/share/php/.packagexml/${PEAR_PN}-channel.xml" ]] ; then |
121 |
> "${EROOT}usr/bin/peardev" channel-info "${PHP_PEAR_URI}" &> /dev/null |
122 |
> if [[ "$?x" != "0x" ]] ; then |
123 |
|
124 |
Err, we don't do 'the x-thing' in bash. Much better: |
125 |
|
126 |
if ! "${EROOT}usr/bin/peardev" ... &> /dev/null; then |
127 |
|
128 |
> "${EROOT}usr/bin/peardev" channel-add \ |
129 |
> "${EROOT}usr/share/php/.packagexml/${PEAR_PN}-channel.xml" \ |
130 |
> || einfo "Ignore any errors about existing channels" |
131 |
> fi |
132 |
> fi |
133 |
> |
134 |
> # Register the package from the package{,2}.xml file |
135 |
> # It is not critical to complete so only warn on failure |
136 |
> if [[ -f "${EROOT}usr/share/php/.packagexml/${PEAR_PN}.xml" ]] ; then |
137 |
> "${EROOT}usr/bin/peardev" install -nrO --force \ |
138 |
> "${EROOT}usr/share/php/.packagexml/${PEAR_PN}.xml" 2> /dev/null \ |
139 |
> || ewarn "Failed to insert package into local PEAR database" |
140 |
> fi |
141 |
> } |
142 |
> |
143 |
> # @FUNCTION: php-pear-r2_pkg_postrm |
144 |
> # @DESCRIPTION: |
145 |
> # Deregister package from the local PEAR database |
146 |
> php-pear-r2_pkg_postrm() { |
147 |
> # Uninstall known dependency |
148 |
> "${EROOT}usr/bin/peardev" uninstall -nrO "${PHP_PEAR_URI}/${PHP_PEAR_PKG_NAME}" |
149 |
> } |
150 |
|
151 |
-- |
152 |
Best regards, |
153 |
Michał Górny |