Gentoo Archives: gentoo-commits

From: Tobias Klausmann <klausman@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: www-apache/mod_perl/, www-apache/mod_perl/files/
Date: Tue, 29 Dec 2015 09:10:07
Message-Id: 1451380188.ff626b3e8835f83406c28bdfee3f213b75d192ab.klausman@gentoo
1 commit: ff626b3e8835f83406c28bdfee3f213b75d192ab
2 Author: Tobias Klausmann <klausman <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 29 09:08:13 2015 +0000
4 Commit: Tobias Klausmann <klausman <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 29 09:09:48 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ff626b3e
7
8 www-apache/mod_perl Fix Perl initialization
9
10 Newer (>=5.22) versions of Perl require initialization to be handled
11 differently. The added patch comes from mod_perl's SVN, commit #1717474,
12 plus a few adaptations to apply cleanly.
13
14 Gentoo-Bug: 554794
15
16 Package-Manager: portage-2.2.26
17
18 .../mod_perl/files/mod_perl_init_b554794.patch | 241 +++++++++++++++++++++
19 www-apache/mod_perl/mod_perl-2.0.8-r3.ebuild | 165 ++++++++++++++
20 2 files changed, 406 insertions(+)
21
22 diff --git a/www-apache/mod_perl/files/mod_perl_init_b554794.patch b/www-apache/mod_perl/files/mod_perl_init_b554794.patch
23 new file mode 100644
24 index 0000000..b33a34a
25 --- /dev/null
26 +++ b/www-apache/mod_perl/files/mod_perl_init_b554794.patch
27 @@ -0,0 +1,241 @@
28 +--- a/src/modules/perl/modperl_env.c.orig 2015-12-28 11:42:26.604632457 +0100
29 ++++ b/src/modules/perl/modperl_env.c 2015-12-28 12:36:35.305228288 +0100
30 +@@ -120,6 +120,7 @@
31 + const apr_array_header_t *array;
32 + apr_table_entry_t *elts;
33 +
34 ++ modperl_env_init(aTHX);
35 + modperl_env_untie(mg_flags);
36 +
37 + array = apr_table_elts(table);
38 +@@ -431,13 +432,11 @@
39 + }
40 +
41 + /* to store the original virtual tables
42 +- * these are global, not per-interpreter
43 ++ * handy access to perl's original virtual tables
44 + */
45 +-static MGVTBL MP_PERL_vtbl_env;
46 +-static MGVTBL MP_PERL_vtbl_envelem;
47 +
48 + #define MP_PL_vtbl_call(name, meth) \
49 +- MP_PERL_vtbl_##name.svt_##meth(aTHX_ sv, mg)
50 ++ PL_vtbl_##name.svt_##meth(aTHX_ sv, mg)
51 +
52 + #define MP_dENV_KEY \
53 + STRLEN klen; \
54 +@@ -534,6 +533,26 @@
55 + return 0;
56 + }
57 +
58 ++static int modperl_env_magic_copy(pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *name, I32 namlen)
59 ++{
60 ++ MP_TRACE_e(MP_FUNC, "setting up %%ENV element magic");
61 ++ sv_magicext(nsv, mg->mg_obj, toLOWER(mg->mg_type), &MP_vtbl_envelem, name, namlen);
62 ++
63 ++ return 1;
64 ++}
65 ++
66 ++static int modperl_env_magic_local_all(pTHX_ SV *nsv, MAGIC *mg)
67 ++{
68 ++ MAGIC *nmg;
69 ++ MP_TRACE_e(MP_FUNC, "localizing %%ENV");
70 ++ nmg = sv_magicext(nsv, mg->mg_obj, mg->mg_type, &MP_vtbl_env, (char*)NULL, 0);
71 ++ nmg->mg_ptr = mg->mg_ptr;
72 ++ nmg->mg_flags |= MGf_COPY;
73 ++ nmg->mg_flags |= MGf_LOCAL;
74 ++
75 ++ return 1;
76 ++}
77 ++
78 + static int modperl_env_magic_set(pTHX_ SV *sv, MAGIC *mg)
79 + {
80 + request_rec *r = (request_rec *)EnvMgObj;
81 +@@ -625,15 +644,18 @@
82 + #endif
83 +
84 + /* override %ENV virtual tables with our own */
85 +-static MGVTBL MP_vtbl_env = {
86 ++MGVTBL MP_vtbl_env = {
87 + 0,
88 + modperl_env_magic_set_all,
89 + 0,
90 + modperl_env_magic_clear_all,
91 +- 0
92 ++ 0,
93 ++ modperl_env_magic_copy,
94 ++ 0,
95 ++ modperl_env_magic_local_all
96 + };
97 +
98 +-static MGVTBL MP_vtbl_envelem = {
99 ++MGVTBL MP_vtbl_envelem = {
100 + 0,
101 + modperl_env_magic_set,
102 + 0,
103 +@@ -641,20 +663,62 @@
104 + 0
105 + };
106 +
107 +-void modperl_env_init(void)
108 ++void modperl_env_init(pTHX)
109 + {
110 +- /* save originals */
111 +- StructCopy(&PL_vtbl_env, &MP_PERL_vtbl_env, MGVTBL);
112 +- StructCopy(&PL_vtbl_envelem, &MP_PERL_vtbl_envelem, MGVTBL);
113 ++ MAGIC *mg;
114 +
115 +- /* replace with our versions */
116 +- StructCopy(&MP_vtbl_env, &PL_vtbl_env, MGVTBL);
117 +- StructCopy(&MP_vtbl_envelem, &PL_vtbl_envelem, MGVTBL);
118 ++ /* Find the 'E' magic on %ENV */
119 ++ if (!my_perl)
120 ++ return;
121 ++ if (!PL_envgv)
122 ++ return;
123 ++ if (!SvRMAGICAL(ENVHV))
124 ++ return;
125 ++ mg = mg_find((const SV *)ENVHV, PERL_MAGIC_env);
126 ++ if (!mg)
127 ++ return;
128 ++
129 ++ /* Ignore it if it isn't perl's original version */
130 ++ if (mg->mg_virtual != &PL_vtbl_env)
131 ++ return;
132 ++
133 ++ MP_TRACE_e(MP_FUNC, "env_init - ptr: %x obj: %x flags: %x",
134 ++ mg->mg_ptr, mg->mg_obj, mg->mg_flags);
135 ++
136 ++ /* Remove it */
137 ++ mg_free_type((SV*)ENVHV, PERL_MAGIC_env);
138 ++
139 ++ /* Add our version instead */
140 ++ mg = sv_magicext((SV*)ENVHV, (SV*)NULL, PERL_MAGIC_env, &MP_vtbl_env, (char*)NULL, 0);
141 ++ mg->mg_flags |= MGf_COPY;
142 ++ mg->mg_flags |= MGf_LOCAL;
143 + }
144 +
145 +-void modperl_env_unload(void)
146 ++void modperl_env_unload(pTHX)
147 + {
148 +- /* restore originals */
149 +- StructCopy(&MP_PERL_vtbl_env, &PL_vtbl_env, MGVTBL);
150 +- StructCopy(&MP_PERL_vtbl_envelem, &PL_vtbl_envelem, MGVTBL);
151 ++ MAGIC *mg;
152 ++
153 ++ /* Find the 'E' magic on %ENV */
154 ++ if (!my_perl)
155 ++ return;
156 ++ if (!PL_envgv)
157 ++ return;
158 ++ if (!SvRMAGICAL(ENVHV))
159 ++ return;
160 ++ mg = mg_find((const SV *)ENVHV, PERL_MAGIC_env);
161 ++ if (!mg)
162 ++ return;
163 ++
164 ++ /* Ignore it if it isn't our version */
165 ++ if (mg->mg_virtual != &MP_vtbl_env)
166 ++ return;
167 ++
168 ++ MP_TRACE_e(MP_FUNC, "env_unload - ptr: %x obj: %x flags: %x",
169 ++ mg->mg_ptr, mg->mg_obj, mg->mg_flags);
170 ++
171 ++ /* Remove it */
172 ++ mg_free_type((SV*)ENVHV, PERL_MAGIC_env);
173 ++
174 ++ /* Restore perl's original version */
175 ++ sv_magicext((SV*)ENVHV, (SV*)NULL, PERL_MAGIC_env, &PL_vtbl_env, (char*)NULL, 0);
176 + }
177 +--- a/src/modules/perl/modperl_env.h.orig 2015-12-28 11:42:34.868727490 +0100
178 ++++ b/src/modules/perl/modperl_env.h 2015-12-28 12:37:47.730041274 +0100
179 +@@ -28,7 +28,7 @@
180 + MP_magical_tie(ENVHV, mg_flags)
181 +
182 + #define modperl_envelem_tie(sv, key, klen) \
183 +- sv_magic(sv, (SV *)NULL, 'e', key, klen)
184 ++ sv_magicext(sv, (SV *)NULL, PERL_MAGIC_envelem, &MP_vtbl_envelem, key, klen)
185 +
186 + void modperl_env_hash_keys(pTHX);
187 +
188 +@@ -58,8 +58,11 @@
189 +
190 + void modperl_env_request_untie(pTHX_ request_rec *r);
191 +
192 +-void modperl_env_init(void);
193 ++void modperl_env_init(pTHX);
194 +
195 +-void modperl_env_unload(void);
196 ++void modperl_env_unload(pTHX);
197 ++
198 ++MGVTBL MP_vtbl_env;
199 ++MGVTBL MP_vtbl_envelem;
200 +
201 + #endif /* MODPERL_ENV_H */
202 +Index: trunk/src/modules/perl/modperl_perl.c
203 +===================================================================
204 +--- trunk/src/modules/perl/modperl_perl.c (revision 1717473)
205 ++++ trunk/src/modules/perl/modperl_perl.c (revision 1717474)
206 +@@ -181,6 +181,8 @@
207 + }
208 + }
209 +
210 ++ modperl_env_unload(perl);
211 ++
212 + perl_destruct(perl);
213 +
214 + /* XXX: big bug in 5.6.1 fixed in 5.7.2+
215 +Index: trunk/src/modules/perl/mod_perl.c
216 +===================================================================
217 +--- trunk/src/modules/perl/mod_perl.c (revision 1717473)
218 ++++ trunk/src/modules/perl/mod_perl.c (revision 1717474)
219 +@@ -262,6 +262,8 @@
220 + exit(1);
221 + }
222 +
223 ++ modperl_env_init(aTHX);
224 ++
225 + /* suspend END blocks to be run at server shutdown */
226 + endav = PL_endav;
227 + PL_endav = (AV *)NULL;
228 +@@ -576,9 +578,6 @@
229 + /* modifies PL_ppaddr */
230 + modperl_perl_pp_set_all();
231 +
232 +- /* modifies PL_vtbl_env{elem} */
233 +- modperl_env_init();
234 +-
235 + return APR_SUCCESS;
236 + }
237 +
238 +@@ -597,8 +596,6 @@
239 +
240 + MP_TRACE_i(MP_FUNC, "mod_perl sys term");
241 +
242 +- modperl_env_unload();
243 +-
244 + modperl_perl_pp_unset_all();
245 +
246 + PERL_SYS_TERM();
247 +Index: trunk/t/response/TestModperl/env.pm
248 +===================================================================
249 +--- trunk/t/response/TestModperl/env.pm (revision 1717473)
250 ++++ trunk/t/response/TestModperl/env.pm (revision 1717474)
251 +@@ -15,7 +15,7 @@
252 + sub handler {
253 + my $r = shift;
254 +
255 +- plan $r, tests => 23 + keys(%ENV);
256 ++ plan $r, tests => 23 + 3 * keys(%ENV);
257 +
258 + my $env = $r->subprocess_env;
259 +
260 +@@ -75,6 +75,8 @@
261 + for my $key (sort keys %ENV) {
262 + eval { delete $ENV{$key}; };
263 + ok t_cmp($@, '', $key);
264 ++ ok t_cmp($ENV{$key}, undef, "ENV{$key} is empty");
265 ++ ok t_cmp($env->get($key), undef, "subprocess_env($key) is empty");
266 + }
267 +
268 + Apache2::Const::OK;
269
270 diff --git a/www-apache/mod_perl/mod_perl-2.0.8-r3.ebuild b/www-apache/mod_perl/mod_perl-2.0.8-r3.ebuild
271 new file mode 100644
272 index 0000000..bdd6215
273 --- /dev/null
274 +++ b/www-apache/mod_perl/mod_perl-2.0.8-r3.ebuild
275 @@ -0,0 +1,165 @@
276 +# Copyright 1999-2015 Gentoo Foundation
277 +# Distributed under the terms of the GNU General Public License v2
278 +# $Id$
279 +
280 +EAPI="5"
281 +
282 +inherit depend.apache apache-module perl-module eutils
283 +
284 +DESCRIPTION="An embedded Perl interpreter for Apache2"
285 +HOMEPAGE="https://projects.apache.org/projects/mod_perl.html"
286 +SRC_URI="mirror://apache/perl/${P}.tar.gz"
287 +
288 +LICENSE="GPL-2"
289 +SLOT="1"
290 +KEYWORDS=""
291 +IUSE="debug"
292 +
293 +# Make sure we always use the latest Apache-Test version or even check the
294 +# version of the bundled Apache-Test!
295 +#
296 +# We need both, apache and perl but either apache without threads or perl with
297 +# ithreads, bug 373943
298 +DEPEND="
299 + >=dev-perl/Apache-Test-1.360
300 + >=dev-perl/CGI-3.08
301 + dev-lang/perl[ithreads]
302 + www-servers/apache
303 +"
304 +RDEPEND="${DEPEND}"
305 +PDEPEND=">=dev-perl/Apache-Reload-0.11
306 + >=dev-perl/Apache-SizeLimit-0.95"
307 +
308 +APACHE2_MOD_FILE="${S}/src/modules/perl/mod_perl.so"
309 +APACHE2_MOD_CONF="2.0.3/75_${PN}"
310 +APACHE2_MOD_DEFINE="PERL"
311 +
312 +SRC_TEST="do"
313 +
314 +DOCFILES="Changes INSTALL README STATUS"
315 +
316 +need_apache2_4
317 +
318 +src_prepare() {
319 + perl-module_src_prepare
320 +
321 + # I am not entirely happy with this solution, but here's what's
322 + # going on here if someone wants to take a stab at another
323 + # approach. When userpriv compilation is off, then the make
324 + # process drops to user "nobody" to run the test servers. This
325 + # server is closed, and then the socket is rebound using
326 + # SO_REUSEADDR. If the same user does this, there is no problem,
327 + # and the socket may be rebound immediately. If a different user
328 + # (yes, in my testing, even root) attempts to rebind, it fails.
329 + # Since the "is the socket available yet" code and the
330 + # second-batch bind call both run as root, this will fail.
331 +
332 + # The upstream settings on my test machine cause the second batch
333 + # of tests to fail, believing the socket to still be in use. I
334 + # tried patching various parts to make them run as the user
335 + # specified in $config->{vars}{user} using getpwnam, but found
336 + # this patch to be fairly intrusive, because the userid must be
337 + # restored and the patch must be applied to multiple places.
338 +
339 + # For now, we will simply extend the timeout in hopes that in the
340 + # non-userpriv case, the socket will clear from the kernel tables
341 + # normally, and the tests will proceed.
342 +
343 + # If anybody is still having problems, then commenting out "make
344 + # test" below should allow the software to build properly.
345 +
346 + # Robert Coie <rac@g.o> 2003.05.06
347 +# sed -i -e "s/sleep \$_/sleep \$_ << 2/" \
348 +# "${S}"/Apache-Test/lib/Apache/TestServer.pm \
349 +# || die "problem editing TestServer.pm"
350 +
351 + # rendhalver - this got redone for 2.0.1 and seems to fix the make test problems
352 + epatch "${FILESDIR}"/${PN}-2.0.1-sneak-tmpdir.patch
353 + epatch "${FILESDIR}"/${PN}-2.0.4-inline.patch #550244
354 +
355 + # bug 352724
356 + epatch "${FILESDIR}/${P}-bundled-Apache-Test.patch"
357 + rm -rf Apache-{Test,Reload,SizeLimit}/ lib/Bundle/
358 + sed -i \
359 + -e 's:^Apache-\(Reload\|SizeLimit\|Test\).*::' \
360 + -e 's:^lib/Bundle/Apache2.pm::' \
361 + MANIFEST || die
362 +
363 + # 410453
364 + epatch "${FILESDIR}/use-client_ip-client_add-instead-of-remote_ip-remote.patch"
365 + epatch "${FILESDIR}/use-log.level-instead-of-loglevel.patch"
366 +
367 + # 554794
368 + epatch "${FILESDIR}/mod_perl_init_b554794.patch"
369 +}
370 +
371 +src_configure() {
372 + local debug=$(usex debug 1 0)
373 + perl Makefile.PL \
374 + PREFIX="${EPREFIX}"/usr \
375 + INSTALLDIRS=vendor \
376 + MP_USE_DSO=1 \
377 + MP_APXS=${APXS} \
378 + MP_APR_CONFIG=/usr/bin/apr-1-config \
379 + MP_TRACE=${debug} \
380 + MP_DEBUG=${debug} \
381 + || die
382 +}
383 +
384 +src_test() {
385 + # make test notes whether it is running as root, and drops
386 + # privileges all the way to "nobody" if so, so we must adjust
387 + # write permissions accordingly in this case.
388 +
389 + # IF YOU SUDO TO EMERGE AND HAVE !env_reset set testing will fail!
390 + if [[ "$(id -u)" == "0" ]]; then
391 + chown nobody:nobody "${WORKDIR}" "${T}"
392 + fi
393 +
394 + # this does not || die because of bug 21325. kudos to smark for
395 + # the idea of setting HOME.
396 + TMPDIR="${T}" HOME="${T}/" perl-module_src_test
397 +}
398 +
399 +src_install() {
400 + apache-module_src_install
401 +
402 + default
403 +#emake DESTDIR="${D}" install || die
404 +
405 + # TODO: add some stuff from docs/ back?
406 +
407 + # rendhalver - fix the perllocal.pod that gets installed
408 + # it seems to me that this has been getting installed for ages
409 + perl_delete_localpod
410 + # Remove empty .bs files as well
411 + perl_delete_packlist
412 +
413 + insinto "${APACHE_MODULES_CONFDIR}"
414 + doins "${FILESDIR}"/2.0.3/apache2-mod_perl-startup.pl
415 +
416 + # this is an attempt to get @INC in line with /usr/bin/perl.
417 + # there is blib garbage in the mainstream one that can only be
418 + # useful during internal testing, so we wait until here and then
419 + # just go with a clean slate. should be much easier to see what's
420 + # happening and revert if problematic.
421 +
422 + # Sorry for this evil hack...
423 + perl_set_version # just to be sure...
424 + sed -i \
425 + -e "s,-I${S}/[^[:space:]\"\']\+[[:space:]]\?,,g" \
426 + -e "s,-typemap[[:space:]]${S}/[^[:space:]\"\']\+[[:space:]]\?,,g" \
427 + -e "s,${S}\(/[^[:space:]\"\']\+\)\?,/,g" \
428 + "${D}/${VENDOR_ARCH}/Apache2/BuildConfig.pm" || die
429 +
430 + for fname in $(find "${D}" -type f -not -name '*.so'); do
431 + grep -q "\(${D}\|${S}\)" "${fname}" && ewarn "QA: File contains a temporary path ${fname}"
432 + sed -i -e "s:\(${D}\|${S}\):/:g" ${fname}
433 + done
434 + # All the rest
435 + perl_remove_temppath
436 +}
437 +
438 +pkg_postinst() {
439 + apache-module_pkg_postinst
440 +}