Add www-apache/mod_perl from ::gentoo.
[mjo-overlay.git] / www-apache / mod_perl / mod_perl-2.0.8.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit depend.apache apache-module perl-module eutils
8
9 DESCRIPTION="An embedded Perl interpreter for Apache2"
10 SRC_URI="mirror://apache/perl/${P}.tar.gz"
11 HOMEPAGE="https://projects.apache.org/projects/mod_perl.html"
12
13 LICENSE="GPL-2"
14 KEYWORDS="alpha amd64 ~hppa ia64 ppc ppc64 sparc x86"
15 IUSE="debug"
16 SLOT="1"
17
18 # Make sure we always use the latest Apache-Test version or even check the
19 # version of the bundled Apache-Test!
20 #
21 # We need both, apache and perl but either apache without threads or perl with
22 # ithreads, bug 373943
23 DEPEND="<www-servers/apache-2.4
24 >=dev-perl/Apache-Test-1.360
25 >=dev-perl/CGI-3.08
26 dev-lang/perl
27 www-servers/apache
28 || ( www-servers/apache[-threads] dev-lang/perl[ithreads] )"
29 RDEPEND="${DEPEND}"
30 PDEPEND=">=dev-perl/Apache-Reload-0.11
31 >=dev-perl/Apache-SizeLimit-0.95"
32
33 APACHE2_MOD_FILE="${S}/src/modules/perl/mod_perl.so"
34 APACHE2_MOD_CONF="2.0.3/75_${PN}.2.2"
35 APACHE2_MOD_DEFINE="PERL"
36
37 SRC_TEST="do"
38
39 DOCFILES="Changes INSTALL README STATUS"
40
41 need_apache2
42
43 src_prepare() {
44 perl-module_src_prepare
45
46 # I am not entirely happy with this solution, but here's what's
47 # going on here if someone wants to take a stab at another
48 # approach. When userpriv compilation is off, then the make
49 # process drops to user "nobody" to run the test servers. This
50 # server is closed, and then the socket is rebound using
51 # SO_REUSEADDR. If the same user does this, there is no problem,
52 # and the socket may be rebound immediately. If a different user
53 # (yes, in my testing, even root) attempts to rebind, it fails.
54 # Since the "is the socket available yet" code and the
55 # second-batch bind call both run as root, this will fail.
56
57 # The upstream settings on my test machine cause the second batch
58 # of tests to fail, believing the socket to still be in use. I
59 # tried patching various parts to make them run as the user
60 # specified in $config->{vars}{user} using getpwnam, but found
61 # this patch to be fairly intrusive, because the userid must be
62 # restored and the patch must be applied to multiple places.
63
64 # For now, we will simply extend the timeout in hopes that in the
65 # non-userpriv case, the socket will clear from the kernel tables
66 # normally, and the tests will proceed.
67
68 # If anybody is still having problems, then commenting out "make
69 # test" below should allow the software to build properly.
70
71 # Robert Coie <rac@gentoo.org> 2003.05.06
72 # sed -i -e "s/sleep \$_/sleep \$_ << 2/" \
73 # "${S}"/Apache-Test/lib/Apache/TestServer.pm \
74 # || die "problem editing TestServer.pm"
75
76 # rendhalver - this got redone for 2.0.1 and seems to fix the make test problems
77 epatch "${FILESDIR}"/mod_perl-2.0.1-sneak-tmpdir.patch
78
79 # bug 352724
80 epatch "${FILESDIR}/${P}-bundled-Apache-Test.patch"
81 rm -rf Apache-{Test,Reload,SizeLimit}/ lib/Bundle/
82 sed -i -e 's:^Apache-\(Reload\|SizeLimit\|Test\).*::' \
83 -e 's:^lib/Bundle/Apache2.pm::' MANIFEST || die
84 }
85
86 src_configure() {
87 local myargs=
88
89 if use debug; then
90 myargs="MP_TRACE=1 MP_DEBUG=1"
91 else
92 myargs="MP_TRACE=0 MP_DEBUG=0"
93 fi
94
95 perl Makefile.PL \
96 PREFIX="${EPREFIX}"/usr \
97 INSTALLDIRS=vendor \
98 MP_USE_DSO=1 \
99 MP_APXS=${APXS} \
100 ${myargs} || die
101 }
102
103 src_test() {
104 # make test notes whether it is running as root, and drops
105 # privileges all the way to "nobody" if so, so we must adjust
106 # write permissions accordingly in this case.
107
108 # IF YOU SUDO TO EMERGE AND HAVE !env_reset set testing will fail!
109 if [[ "$(id -u)" == "0" ]]; then
110 chown nobody:nobody "${WORKDIR}"
111 chown nobody:nobody "${T}"
112 fi
113
114 # this does not || die because of bug 21325. kudos to smark for
115 # the idea of setting HOME.
116 TMPDIR="${T}" HOME="${T}/" perl-module_src_test
117 }
118
119 src_install() {
120 apache-module_src_install
121
122 emake DESTDIR="${D}" install || die
123
124 # TODO: add some stuff from docs/ back?
125
126 # rendhalver - fix the perllocal.pod that gets installed
127 # it seems to me that this has been getting installed for ages
128 perl_delete_localpod
129 # Remove empty .bs files as well
130 perl_delete_packlist
131
132 insinto "${APACHE_MODULES_CONFDIR}"
133 doins "${FILESDIR}"/2.0.3/apache2-mod_perl-startup.pl || die
134
135 # this is an attempt to get @INC in line with /usr/bin/perl.
136 # there is blib garbage in the mainstream one that can only be
137 # useful during internal testing, so we wait until here and then
138 # just go with a clean slate. should be much easier to see what's
139 # happening and revert if problematic.
140
141 # Sorry for this evil hack...
142 perl_set_version # just to be sure...
143 sed -i -e "s,-I${S}/[^[:space:]\"\']\+[[:space:]]\?,,g" \
144 -e "s,-typemap[[:space:]]${S}/[^[:space:]\"\']\+[[:space:]]\?,,g" \
145 -e "s,${S}\(/[^[:space:]\"\']\+\)\?,/,g" "${D}/${VENDOR_ARCH}/Apache2/BuildConfig.pm" || die
146
147 for fname in $(find "${D}" -type f -not -name '*.so'); do
148 grep -q "\(${D}\|${S}\)" "${fname}" && ewarn "QA: File contains a temporary path ${fname}"
149 sed -i -e "s:\(${D}\|${S}\):/:g" ${fname}
150 done
151 # All the rest
152 perl_remove_temppath
153 }
154
155 pkg_postinst() {
156 apache-module_pkg_postinst
157 }