Gentoo Archives: gentoo-dev

From: Michael Orlitzky <mjo@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6.
Date: Thu, 02 Jun 2016 12:27:18
Message-Id: 5750261A.2030807@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6. by "Michał Górny"
1 Thanks for the detailed review. I followed every suggestion except the
2 doexe thing for *.so files (only because I don't understand the
3 reasoning yet). The new version is attached.
4
5
6
7 On 06/01/2016 01:47 PM, Michał Górny wrote:
8 >> +DEPEND=">=sys-devel/m4-1.4.3
9 >> + >=sys-devel/libtool-1.5.18"
10 >> +RDEPEND=""
11 >
12 > Please move all of this below EAPI check. And I think *DEPEND would be
13 > better set in one place.
14
15 I moved them all after the REQUIRED_USE mess.
16
17
18 >> +case ${EAPI} in
19 >> + 6) ;;
20 >> + *)
21 >> + die "php-ext-source-r3 is not compatible with EAPI=${EAPI}"
22 >
23 > I think you can use ${ECLASS} here btw.
24
25 Done.
26
27
28 >> +# @DESCRIPTION:
29 >> +# Lists the PHP slots compatibile the extension is compatibile with
30 >
31 > typo: compatible, and also appears twice ;-).
32
33 Fixed.
34
35
36 >> +# @ECLASS-VARIABLE: PHP_EXT_SAPIS
37 >> +# @DESCRIPTION:
38 >> +# A list of SAPIs for which we'll install this extension. Formerly
39 >> +# called PHPSAPILIST.
40 >> +[[ -z "${PHP_EXT_SAPIS}" ]] && PHP_EXT_SAPIS="apache2 cli cgi fpm embed phpdbg"
41 >
42 > Is this default something that might get extended in the future? I
43 > think it might be worth noting that here.
44
45 Yeah, I think we'll keep every SAPI currently used in the tree in the
46 list by default. We added "phpdbg" even though php:5.5 doesn't support
47 it. I documented that.
48
49
50 >> +# Make sure at least one target is installed. First, start a USE
51 >> +# conditional like "php?", but only when PHP_EXT_OPTIONAL_USE is
52 >> +# non-null. The option group "|| (..." is always started here.
53 >> +REQUIRED_USE="${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }|| ( "
54 >> +for target in ${USE_PHP}; do
55 >
56 > Environment pollution! unset target, or make this local.
57
58 I renamed it to _php_target and unset it after the loop.
59
60
61 >> + # Now loop through each USE_PHP target and add the corresponding
62 >> + # dev-lang/php slot to PHPDEPEND.
63 >> + IUSE="${IUSE} php_targets_${target}"
64 >
65 > Any reason not to use += here as well?
66
67 Nope, and likewise with PHPDEPEND in the same loop. I changed them both.
68
69
70 >> +# @ECLASS-VARIABLE: PHP_EXT_EXTRA_ECONF
71 >> +# @DESCRIPTION:
72 >> +# Set this in the ebuild to pass configure options to econf. Formerly
73 >> +# called my_conf.
74 >
75 > Please don't name this *EXTRA_ECONF. EXTRA_ECONF is a Portage variable
76 > that's meant to be set by user in make.conf/env, and not ebuilds.
77
78 It's PHP_EXT_ECONF_ARGS now, and I updated the migration guide.
79
80
81 >> + # Let's put the default module away. Strip $EPREFIX from
82 >> + # $EXT_DIR before calling newins (which handles EPREFIX itself).
83 >> + insinto "${EXT_DIR#$EPREFIX}"
84 >> + newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
85 >
86 > Wouldn't it be more appropriate to use exeinto/doexe to have the shared
87 > libs +x?
88
89 I'd never heard this before... why? I suppose the only trade-off is that
90 having them -x prevents them from showing up in bash's tab-completion
91 for executables.
92
93
94 >> +# @FUNCTION: php_init_slot_env
95 >> +# @DESCRIPTION:
96 >> +# Takes a slot name, and initializes some global variables to values
97 >> +# corresponding to that slot. For example, it sets the path to the "php"
98 >> +# and "phpize" binaries, which will differ for each slot. This function
99 >> +# is intended to be called while looping through a list of slots
100 >> +# obtained from php_get_slots().
101 >
102 > Please make it explicit that it changes working directory.
103
104 Done.
105
106
107 >> +# @FUNCTION: php_slot_ini_files
108 >> +# @INTERNAL
109 >> +# @DESCRIPTION:
110 >> +# Output a list of relative paths to INI files for the given
111 >> +# slot. Usually there will be one INI file per SAPI.
112 >
113 > Please add @USAGE to make clear what ${1} is. In fact, many functions
114 > seem to miss @USAGE.
115
116 I added USAGE for every function that takes an argument. I also figured
117 out where the eclass manpages come from and made sure that the other doc
118 issues (like DEFAULT_UNSET) are fixed w.r.t. eclass-to-manpage.sh.
119
120
121 >> + cat "${FILESDIR}/${PHP_EXT_INIFILE}" >> "${ED}/${file}"
122 >
123 > || die
124
125 Fixed all of these.
126
127
128 >> + # Add support for installing PHP files into a version dependent
129 >> + # directory
130 >> + PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
131 >
132 > Should this be repeated inside the loop?
133
134 There's a longer answer to that question, but the fact that it's outside
135 of the loop is intentional and consistent with -r2.
136
137
138 >> +php-ext-source-r3_addextension() {
139 >> + if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
140 >> + ext_type="zend_extension"
141 >> + ext_file="${EXT_DIR}/${1}" # Zend extensions need the path...
142 >> + else
143 >> + ext_type="extension"
144 >> + ext_file="${1}"
145 >> + fi
146 >
147 > I think you want those variables local.
148
149 Fixed all of the local variable issues.
150
151
152 >> +php-ext-source-r3_addtoinifile() {
153 >> + local inifile="${WORKDIR}/${1}"
154 >> + local inidir="$(dirname ${inifile})"
155 >
156 > I would suggest avoiding external tools like dirname when simple bash
157 > subst can do the work (e.g. ${inifile%/*}).
158
159 Fixed both `dirname` calls.
160
161
162 >> + if [[ ! -d "${inidir}" ]] ; then
163 >> + mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}"
164 >
165 > 'mkdir -p' is safe to call when the directory exists, so I don't think
166 > you need the conditional.
167
168 Fixed.
169
170
171 > All above considered, wouldn't it be simpler to set my_added first,
172 > and then just echo it to the file outside the conditional?
173
174 Yes, good catch. I cleaned that up.
175
176
177 >> +# @FUNCTION: php-ext-source-r3_addtoinifiles
178 >> +# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
179 >
180 > I think you are mixing '[]' meaning optional and meaning literal '[]'
181 > here.
182
183 Yeah, I changed the first parameter to <setting-or-section-name> and
184 made the other two optional.
185
186
187 >> +# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
188 >
189 > Hmm... just to make it clear... is there any reason you use two
190 > arguments instead of the more obvious 'foo=15'?
191
192 It's weird, but it's not wrong, and that's the way -r2 did it. There are
193 a few ebuilds (not maintained by the PHP team) that call
194 *addtoinifiles() themselves, and I don't want to annoy those people too
195 much for cosmetic changes.

Attachments

File name MIME type
php-ext-source-r3.eclass text/plain

Replies