1 |
On Thu, 2 Jun 2016 08:27:06 -0400 |
2 |
Michael Orlitzky <mjo@g.o> wrote: |
3 |
|
4 |
> Thanks for the detailed review. I followed every suggestion except the |
5 |
> doexe thing for *.so files (only because I don't understand the |
6 |
> reasoning yet). The new version is attached. |
7 |
|
8 |
Next time, please inline and don't attach. It's awfully hard to reply |
9 |
to both the reply and the attachment. |
10 |
|
11 |
> >> + # Let's put the default module away. Strip $EPREFIX from |
12 |
> >> + # $EXT_DIR before calling newins (which handles EPREFIX itself). |
13 |
> >> + insinto "${EXT_DIR#$EPREFIX}" |
14 |
> >> + newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" |
15 |
> > |
16 |
> > Wouldn't it be more appropriate to use exeinto/doexe to have the shared |
17 |
> > libs +x? |
18 |
> |
19 |
> I'd never heard this before... why? I suppose the only trade-off is that |
20 |
> having them -x prevents them from showing up in bash's tab-completion |
21 |
> for executables. |
22 |
|
23 |
To be honest, I never dived into figuring out why it's like that -- but |
24 |
all libraries on my system are +x, and that's how the compiler creates |
25 |
them. So I'd rather follow that. |
26 |
|
27 |
> >> + # Add support for installing PHP files into a version dependent |
28 |
> >> + # directory |
29 |
> >> + PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}" |
30 |
> > |
31 |
> > Should this be repeated inside the loop? |
32 |
> |
33 |
> There's a longer answer to that question, but the fact that it's outside |
34 |
> of the loop is intentional and consistent with -r2. |
35 |
|
36 |
Sorry, I wasn't clear. I was asking why it's inside the outer loop, |
37 |
rather than at the end of the function, after both loops? |
38 |
|
39 |
> >> +# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0" |
40 |
> > |
41 |
> > Hmm... just to make it clear... is there any reason you use two |
42 |
> > arguments instead of the more obvious 'foo=15'? |
43 |
> |
44 |
> It's weird, but it's not wrong, and that's the way -r2 did it. There are |
45 |
> a few ebuilds (not maintained by the PHP team) that call |
46 |
> *addtoinifiles() themselves, and I don't want to annoy those people too |
47 |
> much for cosmetic changes. |
48 |
|
49 |
I'd say you could support both, and prefer the simpler ;-). |
50 |
|
51 |
|
52 |
Now, for the code: |
53 |
|
54 |
> # @FUNCTION: php-ext-source-r3_src_unpack |
55 |
> # @DESCRIPTION: |
56 |
> # Runs the default src_unpack and then makes a copy for each PHP slot. |
57 |
> php-ext-source-r3_src_unpack() { |
58 |
> default |
59 |
> |
60 |
> local slot orig_s="${PHP_EXT_S}" |
61 |
> for slot in $(php_get_slots); do |
62 |
> cp -r "${orig_s}" "${WORKDIR}/${slot}" || \ |
63 |
> die "failed to copy sources from ${orig_s} to ${WORKDIR}/${slot}" |
64 |
|
65 |
Not sure if this is relevant but I think this breaks mtime guarantees. |
66 |
In other words, output files may end up being 'earlier' than input files |
67 |
depending on copy order. |
68 |
|
69 |
In multibuild.eclass, I used 'cp -p -R' to preserve timestamps and modes. |
70 |
|
71 |
> done |
72 |
> } |
73 |
> |
74 |
> |
75 |
> # @FUNCTION: php-ext-source-r3_src_prepare |
76 |
> # @DESCRIPTION: |
77 |
> # For each PHP slot, we initialize the environment, run the default |
78 |
> # src_prepare() for PATCHES/eapply_user support, and then call |
79 |
> # php-ext-source-r3_phpize. |
80 |
> php-ext-source-r3_src_prepare() { |
81 |
> for slot in $(php_get_slots); do |
82 |
> php_init_slot_env "${slot}" |
83 |
> default |
84 |
> php-ext-source-r3_phpize |
85 |
> done |
86 |
> } |
87 |
|
88 |
Thinking about it... wouldn't it be better to: |
89 |
|
90 |
a. stop overriding unpack, |
91 |
|
92 |
b. run 'default' on ${S}, |
93 |
|
94 |
c. then copy sources in src_prepare()? |
95 |
|
96 |
In other words, apply patches first, then copy; rather than copying, then |
97 |
applying patches to each copy separately. |
98 |
|
99 |
> # @ECLASS-VARIABLE: PHP_EXT_ECONF_ARGS |
100 |
> # @DEFAULT_UNSET |
101 |
> # @DESCRIPTION: |
102 |
> # Set this in the ebuild to pass additional configure options to |
103 |
> # econf. Formerly called my_conf. |
104 |
> |
105 |
> # @FUNCTION: php-ext-source-r3_src_configure |
106 |
> # @DESCRIPTION: |
107 |
> # Takes care of standard configure for PHP extensions (modules). |
108 |
> php-ext-source-r3_src_configure() { |
109 |
> # net-snmp creates these, bug #385403. |
110 |
> addpredict /usr/share/snmp/mibs/.index |
111 |
> addpredict /var/lib/net-snmp/mib_indexes |
112 |
> |
113 |
> local slot |
114 |
> for slot in $(php_get_slots); do |
115 |
> php_init_slot_env "${slot}" |
116 |
> # Set the correct config options |
117 |
> econf --with-php-config=${PHPCONFIG} ${PHP_EXT_ECONF_ARGS} |
118 |
|
119 |
I think PHPCONFIG would be better off quoted, and it would be good to |
120 |
support PHP_EXT_ECONF_ARGS as an array in case someone needs to pass |
121 |
whitespace there. |
122 |
|
123 |
> done |
124 |
> } |
125 |
|
126 |
> # @FUNCTION: php-ext-source-r3_src_install |
127 |
> # @DESCRIPTION: |
128 |
> # Install a standard standalone PHP extension. Uses einstalldocs() |
129 |
> # to support the DOCS variable/array. |
130 |
> php-ext-source-r3_src_install() { |
131 |
> local slot |
132 |
> for slot in $(php_get_slots); do |
133 |
> php_init_slot_env "${slot}" |
134 |
> |
135 |
> # Let's put the default module away. Strip $EPREFIX from |
136 |
> # $EXT_DIR before calling newins (which handles EPREFIX itself). |
137 |
> insinto "${EXT_DIR#$EPREFIX}" |
138 |
> newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" |
139 |
|
140 |
Wouldn't doins/doexe do the same btw? It seems to be that the name is |
141 |
not changed. |
142 |
|
143 |
> |
144 |
> INSTALL_ROOT="${D}" emake install-headers |
145 |
> done |
146 |
> einstalldocs |
147 |
> php-ext-source-r3_createinifiles |
148 |
> } |
149 |
> |
150 |
> # @FUNCTION: php_get_slots |
151 |
> # @DESCRIPTION: |
152 |
> # Get a list of PHP slots contained in both the ebuild's USE_PHP and the |
153 |
> # user's PHP_TARGETS. |
154 |
> php_get_slots() { |
155 |
> local s="" |
156 |
> local slot |
157 |
> for slot in ${USE_PHP}; do |
158 |
> use php_targets_${slot} && s+=" ${slot/-/.}" |
159 |
> done |
160 |
> echo $s |
161 |
> } |
162 |
> |
163 |
> # @FUNCTION: php_init_slot_env |
164 |
> # @USAGE: <slot> |
165 |
> # @DESCRIPTION: |
166 |
> # Takes a slot name, and initializes some global variables to values |
167 |
> # corresponding to that slot. For example, it sets the path to the "php" |
168 |
> # and "phpize" binaries, which will differ for each slot. This function |
169 |
> # is intended to be called while looping through a list of slots |
170 |
> # obtained from php_get_slots(). |
171 |
> # |
172 |
> # Calling this function will change the working directory to the |
173 |
> # temporary build directory for the given slot. |
174 |
> php_init_slot_env() { |
175 |
> local libdir=$(get_libdir) |
176 |
> |
177 |
> PHPIZE="${EPREFIX}/usr/${libdir}/${1}/bin/phpize" |
178 |
> PHPCONFIG="${EPREFIX}/usr/${libdir}/${1}/bin/php-config" |
179 |
> PHPCLI="${EPREFIX}/usr/${libdir}/${1}/bin/php" |
180 |
> PHPCGI="${EPREFIX}/usr/${libdir}/${1}/bin/php-cgi" |
181 |
> PHP_PKG="$(best_version =dev-lang/php-${1:3}*)" |
182 |
> PHPPREFIX="${EPREFIX}/usr/${libdir}/${slot}" |
183 |
|
184 |
A reason why you are using ${1} before, and ${slot} here? |
185 |
|
186 |
> EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
187 |
> PHP_CURRENTSLOT=${1:3} |
188 |
> |
189 |
> PHP_EXT_S="${WORKDIR}/${1}" |
190 |
> cd "${PHP_EXT_S}" || die "failed to change directory to ${PHP_EXT_S}" |
191 |
> } |
192 |
|
193 |
> # @FUNCTION: php-ext-source-r3_addtoinifile |
194 |
> # @USAGE: <relative-ini-path> <setting-or-section-name> [setting-value] |
195 |
> # @INTERNAL |
196 |
> # @DESCRIPTION: |
197 |
> # Add a setting=value to one INI file. The first argument is the |
198 |
> # relative path to the INI file. The second argument is the setting |
199 |
> # name, and the third argument is its value. |
200 |
> # |
201 |
> # You can also pass "[Section]" as the second parameter, to create a new |
202 |
> # section in the INI file. In that case, the third parameter (which |
203 |
> # would otherwise be the value of the setting) is ignored. |
204 |
> php-ext-source-r3_addtoinifile() { |
205 |
> local inifile="${WORKDIR}/${1}" |
206 |
> local inidir="${inifile%/*}" |
207 |
> |
208 |
> mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}" |
209 |
> |
210 |
> # Are we adding the name of a section? Assume not by default. |
211 |
> local my_added="${2}=${3}" |
212 |
> if [[ ${2:0:1} == "[" ]] ; then |
213 |
> # Ok, it's a section name. |
214 |
> my_added="${2}" |
215 |
> fi |
216 |
|
217 |
How about: |
218 |
|
219 |
my_added=${2}${3+=${3}} |
220 |
|
221 |
? |
222 |
|
223 |
> echo "${my_added}" >> "${inifile}" || die "failed to append to ${inifile}" |
224 |
> einfo "Added '${my_added}' to /${1}" |
225 |
> |
226 |
> insinto "/${1%/*}" |
227 |
> doins "${inifile}" |
228 |
|
229 |
Not that I like re-doinsing the files every time a line is inserted, |
230 |
but I guess improving this is not worth the effort. |
231 |
|
232 |
> } |
233 |
|
234 |
|
235 |
-- |
236 |
Best regards, |
237 |
Michał Górny |
238 |
<http://dev.gentoo.org/~mgorny/> |