Subject: [alpine-aports] [PATCH] testing/apache2-mod-perl: patched to work with perl 5.22

From: Valery Kartel <[email-masked]>
Date: Wed, 4 Nov 2015 17:42:52 +0200

---
 testing/apache2-mod-perl/APKBUILD                  |  78 ++++-----
 .../apache2-mod-perl/apache2-mod-perl.apache2.conf |  11 --
 .../apache2-mod-perl/apache2-mod-perl.post-install |  10 --
 testing/apache2-mod-perl/env2.patch                | 176 +++++++++++++++++++++
 .../apache2-mod-perl/mod_perl-2.0.5-nolfs.patch    |  14 --
 .../apache2-mod-perl/mod_perl-2.0.6-nolfs.patch    |  13 --
 testing/apache2-mod-perl/mod_perl-remote-ip.patch  |  70 --------
 testing/apache2-mod-perl/mod_perl.conf             |   8 +
 8 files changed, 216 insertions(+), 164 deletions(-)
 delete mode 100644 testing/apache2-mod-perl/apache2-mod-perl.apache2.conf
 delete mode 100644 testing/apache2-mod-perl/apache2-mod-perl.post-install
 create mode 100644 testing/apache2-mod-perl/env2.patch
 delete mode 100644 testing/apache2-mod-perl/mod_perl-2.0.5-nolfs.patch
 delete mode 100644 testing/apache2-mod-perl/mod_perl-2.0.6-nolfs.patch
 delete mode 100644 testing/apache2-mod-perl/mod_perl-remote-ip.patch
 create mode 100644 testing/apache2-mod-perl/mod_perl.conf

diff --git a/testing/apache2-mod-perl/APKBUILD b/testing/apache2-mod-perl/APKBUILD
index 1be93cf..2d03e10 100644
--- a/testing/apache2-mod-perl/APKBUILD
+++ b/testing/apache2-mod-perl/APKBUILD
@@ -1,40 +1,41 @@
-# Contributor: Matt Smith <[email-masked]>
-# Maintainer: Matt Smith <[email-masked]>
+# Automatically generated by apkbuild-cpan, template 1
+# Contributor: Valery Kartel <[email-masked]>
+# Maintainer: Valery Kartel <[email-masked]>
 pkgname=apache2-mod-perl
-_realname=mod_perl
+_pkgreal=mod_perl
 pkgver=2.0.9
-_pkgver=${pkgver/_rc1/-rc1}
-pkgrel=1
+pkgrel=2
 pkgdesc="Perl Module for Apache2"
-url="http://perl.apache.org/"
+url="http://search.cpan.org/dist/mod_perl/"
 arch="all"
-license="ASL 2.0"
-depends="apache2 perl"
-depends_dev="$pkgname"
-makedepends="$depends_dev apache2-dev perl-dev perl-linux-pid apr-dev apr-util-dev"
-install="$pkgname.post-install"
+license="GPL PerlArtistic"
+makedepends="perl-dev apache2-dev perl-linux-pid apr-dev apr-util-dev"
 subpackages="$pkgname-doc $pkgname-dev"
-source="http://www.eu.apache.org/dist/perl/mod_perl-$pkgver.tar.gz
-	$pkgname.apache2.conf"
+source="http://search.cpan.org/CPAN/authors/id/S/SH/SHAY/$_pkgreal-$pkgver.tar.gz
+	mod_perl.conf
+	env2.patch"
+
+_builddir="$srcdir/$_pkgreal-$pkgver"
 
-_builddir="$srcdir"/${_realname}-${_pkgver}
 prepare() {
 	cd "$_builddir"
+
+	local i
 	for i in $source; do
 		case $i in
 		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
 		esac
 	done
+
+	export CFLAGS=`perl -MConfig -E 'say $Config{ccflags}'`
+	PERL_MM_USE_DEFAULT=1 perl Makefile.PL \
+		MP_CCOPTS=-fgnu89-inline
+		INSTALLDIRS=vendor
 }
 
 build() {
 	cd "$_builddir"
-	make source_scan
-	make xs_generate
-
-	PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor \
-		MP_APXS=/usr/bin/apxs \
-		MP_APR_CONFIG=/usr/bin/apr-1-config || return 1
+	export CFLAGS=`perl -MConfig -E 'say $Config{ccflags}'`
 	make || return 1
 }
 
@@ -42,34 +43,19 @@ package() {
 	cd "$_builddir"
 	make DESTDIR="$pkgdir" install || return 1
 	find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete
-
-	# install the apache2 config
-	install -Dm644 "$srcdir"/$pkgname.apache2.conf \
-		"$pkgdir"/etc/apache2/conf.d/perl-module.conf || return 1
-}
-
-doc() {
-	arch="noarch"
-
-	# man pages
-	mkdir -p "$subpkgdir"/usr/share/man || return 1
-	mv "$pkgdir"/usr/share/man/man* "$subpkgdir"/usr/share/man/ \
-		|| return 1
-
-	# doc files
-	_docs="BRANCHING Changes INSTALL LICENSE MANIFEST NOTICE README \
-	README-SVN RELEASE STATUS SVN-MOVE"
-	for _doc in $_docs; do
-		install -Dm644 "$_builddir"/$_doc \
-			"$subpkgdir"/usr/share/doc/$pkgname/$_doc || return 1
-	done
-	cp -ra "$_builddir"/docs/ "$subpkgdir"/usr/share/doc/$pkgname/ \
-		|| return 1
+	install -Dm644 "$srcdir"/mod_perl.conf \
+		"$pkgdir"/etc/apache2/conf.d/mod_perl.conf
+	mv "$pkgdir"/usr/local/lib/perl5/site_perl "$pkgdir"/usr/lib/perl5
+	mv "$pkgdir"/usr/local/share "$pkgdir"/usr
+	rm -fr "$pkgdir"/usr/local "$pkgdir"/usr/lib/perl5/core_perl
 }
 
 md5sums="fdab9a145bf35f54fce997c96c76f8e2  mod_perl-2.0.9.tar.gz
-86b84bb56b49a95772a7f773fc019043  apache2-mod-perl.apache2.conf"
+326cad2b2324c4a59fde4c232e8465b1  mod_perl.conf
+8d0c0d4d5f95cc9ef383df9a9baad91d  env2.patch"
 sha256sums="0260f26ab771c1c95fadc67544b3400e420bb30b8a77565d2d02ad05498ef52b  mod_perl-2.0.9.tar.gz
-92dfc84c1506f34fc55cb65f4f2b0399254d811a03c5bcea1e6cf010e60a5227  apache2-mod-perl.apache2.conf"
+02b359afff4da0c4a94cc2c253505f301f8b4fca5a14655fdd846f07cbd33530  mod_perl.conf
+f13abc1a5ef918031b5de15ce7da443233f26f157d9811928bab0d4534d2e5c1  env2.patch"
 sha512sums="421d385f0d5d04cbe8c1e9559960eea86a017fa1bed88e614009143550baf852e2345001faff1fb849d9b3e6383786e0011f45ebc3e7d26ad57651fbad4e2f2c  mod_perl-2.0.9.tar.gz
-716650058af077b0494833301f3dfdf517499bdb2021427431cacc7f63e5fe520cd6f5f7daee44bed15e257c9a2d1fb7d18a75954455fa894dd24a8ef32af50b  apache2-mod-perl.apache2.conf"
+15a430ce597e370997a08d6aa1b5e55d4fa723ecac031fe39906c8cc767b90d5bf63e3026dfaa8b10ae8b09a17832f4f07cb8b2fdcd6c9ef427edfaf4e8a48b0  mod_perl.conf
+500d74e8a75604f6996a2fe78b0e695b2f29fd3466aad1dab2b3edff83c8a9041423992f0ef0a5d84c21c153d2ae34c6fcabe700a4bc3991c5b93d2aff1a73f4  env2.patch"
diff --git a/testing/apache2-mod-perl/apache2-mod-perl.apache2.conf b/testing/apache2-mod-perl/apache2-mod-perl.apache2.conf
deleted file mode 100644
index c1a75c7..0000000
--- a/testing/apache2-mod-perl/apache2-mod-perl.apache2.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-LoadModule perl_module modules/mod_perl.so
-
-# For mod_perl 1.0 compatibility, uncomment:
-#PerlModule Apache2::compat
-
-<Location /cgi-bin>
-    AddHandler perl-script .pl
-    PerlResponseHandler ModPerl::Registry
-    PerlOptions +ParseHeaders
-    Options +ExecCGI
-</Location>
diff --git a/testing/apache2-mod-perl/apache2-mod-perl.post-install b/testing/apache2-mod-perl/apache2-mod-perl.post-install
deleted file mode 100644
index 8cfc5a8..0000000
--- a/testing/apache2-mod-perl/apache2-mod-perl.post-install
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-echo "*" >&2
-echo "* To finish installing apache2-mod-perl:" >&2
-echo "*     1) See if you need to modify the apache2 config:" >&2
-echo "*            /etc/apache2/conf.d/perl-module.conf" >&2
-echo "*     2) Restart apache2 when done." >&2
-echo "*" >&2
-
-exit 0
diff --git a/testing/apache2-mod-perl/env2.patch b/testing/apache2-mod-perl/env2.patch
new file mode 100644
index 0000000..8d87594
--- /dev/null
+++ b/testing/apache2-mod-perl/env2.patch
@@ -0,0 +1,176 @@
+Index: src/modules/perl/mod_perl.c

+===================================================================

+--- old/src/modules/perl/mod_perl.c	(revision 1711313)

++++ new/src/modules/perl/mod_perl.c	(working copy)

+@@ -262,6 +262,8 @@

+         exit(1);
+     }
+ 
++    modperl_env_init(aTHX);
++
+     /* suspend END blocks to be run at server shutdown */
+     endav = PL_endav;
+     PL_endav = (AV *)NULL;
+@@ -576,9 +578,6 @@

+     /* modifies PL_ppaddr */
+     modperl_perl_pp_set_all();
+ 
+-    /* modifies PL_vtbl_env{elem} */
+-    modperl_env_init();
+-
+     return APR_SUCCESS;
+ }
+ 
+@@ -597,8 +596,6 @@

+ 
+     MP_TRACE_i(MP_FUNC, "mod_perl sys term");
+ 
+-    modperl_env_unload();
+-
+     modperl_perl_pp_unset_all();
+ 
+     PERL_SYS_TERM();
+Index: src/modules/perl/modperl_env.c

+===================================================================

+--- old/src/modules/perl/modperl_env.c	(revision 1711313)

++++ new/src/modules/perl/modperl_env.c	(working copy)

+@@ -612,6 +612,9 @@

+ }
+ #endif
+ 
++static int modperl_env_magic_copy(pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *name, I32 namlen);
++static int modperl_env_magic_local_all(pTHX_ SV *nsv, MAGIC *mg);
++
+ /* override %ENV virtual tables with our own */
+ static MGVTBL MP_vtbl_env = {
+     0,
+@@ -618,7 +621,10 @@

+     modperl_env_magic_set_all,
+     0,
+     modperl_env_magic_clear_all,
+-    0
++    0,
++    modperl_env_magic_copy,
++    0,
++    modperl_env_magic_local_all
+ };
+ 
+ static MGVTBL MP_vtbl_envelem = {
+@@ -629,24 +635,77 @@

+     0
+ };
+ 
+-void modperl_env_init(void)
++static int modperl_env_magic_copy(pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *name, I32 namlen)
+ {
+-    /* save originals */
+-    StructCopy(&PL_vtbl_env, &MP_PERL_vtbl_env, MGVTBL);
+-    StructCopy(&PL_vtbl_envelem, &MP_PERL_vtbl_envelem, MGVTBL);
++    MAGIC *nmg = NULL;
++    sv_magic(nsv, mg->mg_obj,
++                        toLOWER(mg->mg_type),
++                        name, namlen);
++    nmg = mg_find(nsv, toLOWER(mg->mg_type));
++    if (mg->mg_virtual == &MP_vtbl_env) {
++        MP_TRACE_d(MP_FUNC, "copying magic to %%ENV element");
++        nmg->mg_virtual = &MP_vtbl_envelem;
++    } else {
++        MP_TRACE_d(MP_FUNC, "no %%ENV magic found to copy");
++    }
++    return 1;
++}
+ 
+-    /* replace with our versions */
+-    StructCopy(&MP_vtbl_env, &PL_vtbl_env, MGVTBL);
+-    StructCopy(&MP_vtbl_envelem, &PL_vtbl_envelem, MGVTBL);
++static int modperl_env_magic_local_all(pTHX_ SV *nsv, MAGIC *mg)
++{
++    MAGIC *nmg;
++    MP_TRACE_e(MP_FUNC, "localizing %%ENV");
++    sv_magic(nsv, mg->mg_obj,
++                        mg->mg_type,
++                        NULL, 0);
++    nmg = mg_find(nsv, mg->mg_type);
++    nmg->mg_ptr = mg->mg_ptr;
++    if (mg->mg_virtual == &MP_vtbl_env) {
++        nmg->mg_virtual = &MP_vtbl_env;
++        nmg->mg_flags |= MGf_COPY;
++        nmg->mg_flags |= MGf_LOCAL;
++    } else {
++        MP_TRACE_d(MP_FUNC, "no %%ENV magic found to localize");
++     }
++     return 1;
+ }
+ 
+-void modperl_env_unload(void)
++void modperl_env_init(pTHX)
+ {
+-    /* restore originals */
+-    StructCopy(&MP_PERL_vtbl_env, &PL_vtbl_env, MGVTBL);
+-    StructCopy(&MP_PERL_vtbl_envelem, &PL_vtbl_envelem, MGVTBL);
++    /* Remove existing 'E' magic from %ENV */
++    /* TODO: Should check there is not multiple 'E' magic! */
++    if (!my_perl)
++        return;
++    if (!PL_envgv)
++        return;
++    if (!SvRMAGICAL(ENVHV))
++        return;
++    if (!mg_find((const SV *)ENVHV, PERL_MAGIC_env))
++        return;
++    mg_free_type((SV*)ENVHV, PERL_MAGIC_env);
++ 
++    /* Add our version instead */
++    sv_magicext((SV*)ENVHV, (SV*)NULL, PERL_MAGIC_env, &MP_vtbl_env, (char*)NULL, 0);
+ }
+ 
++void modperl_env_unload(pTHX)
++{
++    /* Remove our 'E' magic from %ENV */
++    /* TODO: Should check there is not multiple 'E' magic! */
++    if (!my_perl)
++        return;
++    if (!PL_envgv)
++        return;
++    if (!SvRMAGICAL(ENVHV))
++        return;
++    if (!mg_find((const SV *)ENVHV, PERL_MAGIC_env))
++        return;
++    mg_free_type((SV*)ENVHV, PERL_MAGIC_env);
++
++    /* Restore original */
++    sv_magicext((SV*)ENVHV, (SV*)NULL, PERL_MAGIC_env, &PL_vtbl_env, (char*)NULL, 0);
++}
++
+ /*
+  * Local Variables:
+  * c-basic-offset: 4
+Index: src/modules/perl/modperl_env.h

+===================================================================

+--- old/src/modules/perl/modperl_env.h	(revision 1711313)

++++ new/src/modules/perl/modperl_env.h	(working copy)

+@@ -58,9 +58,9 @@

+ 
+ void modperl_env_request_untie(pTHX_ request_rec *r);
+ 
+-void modperl_env_init(void);
++void modperl_env_init(pTHX);
+ 
+-void modperl_env_unload(void);
++void modperl_env_unload(pTHX);
+ 
+ #endif /* MODPERL_ENV_H */
+ 
+Index: src/modules/perl/modperl_perl.c

+===================================================================

+--- old/src/modules/perl/modperl_perl.c	(revision 1711313)

++++ new/src/modules/perl/modperl_perl.c	(working copy)

+@@ -181,6 +181,8 @@

+         }
+     }
+ 
++    modperl_env_unload(perl);
++
+     perl_destruct(perl);
+ 
+     /* XXX: big bug in 5.6.1 fixed in 5.7.2+
diff --git a/testing/apache2-mod-perl/mod_perl-2.0.5-nolfs.patch b/testing/apache2-mod-perl/mod_perl-2.0.5-nolfs.patch
deleted file mode 100644
index 3eb345b..0000000
--- a/testing/apache2-mod-perl/mod_perl-2.0.5-nolfs.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-Index: mod_perl-2.0.5/lib/Apache2/Build.pm
-===================================================================
---- mod_perl-2.0.5.orig/lib/Apache2/Build.pm	2011-02-02 21:23:47.000000000 +0100
-+++ mod_perl-2.0.5/lib/Apache2/Build.pm	2011-05-26 17:12:46.276946520 +0200
-@@ -2147,7 +2147,8 @@ sub has_large_files_conflict {
-     # with it is that we didn't have such a case yet, but may need to
-     # deal with it later
- 
--    return $perl_lfs64 ^ $apr_lfs64;
-+    return 0;
-+    # $perl_lfs64 ^ $apr_lfs64;
- }
- 
- # if perl is built with uselargefiles, but apr not, the build won't
diff --git a/testing/apache2-mod-perl/mod_perl-2.0.6-nolfs.patch b/testing/apache2-mod-perl/mod_perl-2.0.6-nolfs.patch
deleted file mode 100644
index 13e5ccc..0000000
--- a/testing/apache2-mod-perl/mod_perl-2.0.6-nolfs.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -upr mod_perl-2.0.6.orig/lib/Apache2/Build.pm mod_perl-2.0.6/lib/Apache2/Build.pm
---- mod_perl-2.0.6.orig/lib/Apache2/Build.pm	2012-05-26 22:31:00.000000000 +0300
-+++ mod_perl-2.0.6/lib/Apache2/Build.pm	2012-05-26 22:31:32.000000000 +0300
-@@ -2207,7 +2207,8 @@ sub has_large_files_conflict {
-     # with it is that we didn't have such a case yet, but may need to
-     # deal with it later
- 
--    return $perl_lfs64 ^ $apr_lfs64;
-+    return 0;
-+    # $perl_lfs64 ^ $apr_lfs64;
- }
- 
- # if perl is built with uselargefiles, but apr not, the build won't
diff --git a/testing/apache2-mod-perl/mod_perl-remote-ip.patch b/testing/apache2-mod-perl/mod_perl-remote-ip.patch
deleted file mode 100644
index e39d629..0000000
--- a/testing/apache2-mod-perl/mod_perl-remote-ip.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-Index: xs/tables/current/Apache2/StructureTable.pm
-===================================================================
---- a/xs/tables/current/Apache2/StructureTable.pm	(revision 1324590)
-+++ b/xs/tables/current/Apache2/StructureTable.pm	(working copy)
-@@ -2708,11 +2708,11 @@
-       },
-       {
-         'type' => 'apr_sockaddr_t *',
--        'name' => 'remote_addr'
-+        'name' => 'client_addr'
-       },
-       {
-         'type' => 'char *',
--        'name' => 'remote_ip'
-+        'name' => 'client_ip'
-       },
-       {
-         'type' => 'char *',
-@@ -2955,6 +2955,14 @@
-       },
-       {
-         'type' => 'char *',
-+        'name' => 'useragent_ip'
-+      },
-+      {
-+        'type' => 'apr_sockaddr_t *',
-+        'name' => 'useragent_addr'
-+      },
-+      {
-+        'type' => 'char *',
-         'name' => 'the_request'
-       },
-       {
-@@ -3245,10 +3253,6 @@
-       },
-       {
-         'type' => 'int',
--        'name' => 'loglevel'
--      },
--      {
--        'type' => 'int',
-         'name' => 'is_virtual'
-       },
-       {
-Index: Apache-Reload/Makefile.PL
-===================================================================
---- a/Apache-Reload/Makefile.PL	(revision 1324590)
-+++ b/Apache-Reload/Makefile.PL	(working copy)
-@@ -11,7 +11,7 @@
- # MOD_PERL_2_BUILD is set from building from mod_perl Makefile.PL which should
- # also set MP_APXS
- if ($ENV{MOD_PERL_2_BUILD}) {
--    push @ARGV, "-apxs", $ENV{MP_APXS};
-+    push @ARGV, "-apxs $ENV{MP_APXS}";
-     my $mp_gen = satisfy_mp_generation(2);
- }
- else {
-Index: Apache-SizeLimit/Makefile.PL
-===================================================================
---- a/Apache-SizeLimit/Makefile.PL	(revision 1324590)
-+++ b/Apache-SizeLimit/Makefile.PL	(working copy)
-@@ -11,7 +11,7 @@
- # MOD_PERL_2_BUILD is set from building from mod_perl Makefile.PL which should
- # also set MP_APXS
- if ($ENV{MOD_PERL_2_BUILD}) {
--    push @ARGV, "-apxs", $ENV{MP_APXS};
-+    push @ARGV, "-apxs $ENV{MP_APXS}";
-     my $mp_gen = satisfy_mp_generation(2);
- }
- else {
diff --git a/testing/apache2-mod-perl/mod_perl.conf b/testing/apache2-mod-perl/mod_perl.conf
new file mode 100644
index 0000000..b33be95
--- /dev/null
+++ b/testing/apache2-mod-perl/mod_perl.conf
@@ -0,0 +1,8 @@
+LoadModule perl_module modules/mod_perl.so
+
+<Location /cgi-bin>
+    AddHandler perl-script .pl
+    PerlResponseHandler ModPerl::Registry
+    PerlOptions +ParseHeaders
+    Options +ExecCGI
+</Location>
-- 
2.6.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Mon, 30 Nov 2015 10:03:19 +0100

On Wed,  4 Nov 2015 17:42:52 +0200

>  create mode 100644 testing/apache2-mod-perl/mod_perl.conf

It does not apply.

Applying: testing/apache2-mod-perl: patched to work with perl 5.22
.git/rebase-apply/patch:182: trailing whitespace.
 
.git/rebase-apply/patch:192: trailing whitespace.
 
.git/rebase-apply/patch:198: trailing whitespace.
 
.git/rebase-apply/patch:201: trailing whitespace.
 
.git/rebase-apply/patch:203: trailing whitespace.
 
fatal: corrupt patch at line 370
Patch failed at 0001 testing/apache2-mod-perl: patched to work with perl 5.22
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

-nc

---

---

From: Valery Kartel <[email-masked]>
Date: Mon, 30 Nov 2015 14:28:28 +0200

This patch should be canceled, because it was replaced by accepted one
http://patchwork.alpinelinux.org/patch/1050/

In 1050 patch I made a note about it.

"This patch is replaces the previous one:
http://patchwork.alpinelinux.org/patch/851/"

2015-11-30 11:03 GMT+02:00 Natanael Copa <[email-masked]>:

> >  delete mode 100644
> testing/apache2-mod-perl/apache2-mod-perl.apache2.conf
> >  delete mode 100644
> testing/apache2-mod-perl/apache2-mod-perl.post-install