File apache2-mod_perl.spec of Package apache2-mod_perl

# vim: ft=apache
# spec file for package apache2-mod_perl
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via


Name:           apache2-mod_perl
BuildRequires:  apache2-devel
BuildRequires:  db-devel
BuildRequires:  ed
BuildRequires:  pcre-devel
BuildRequires:  perl
BuildRequires:  perl-BSD-Resource
BuildRequires:  perl-Compress-Zlib
BuildRequires:  perl-Tie-IxHash
BuildRequires:  perl-libwww-perl
BuildRequires:  sudo
%if 0%{sles_version} == 9
BuildRequires:  openldap2-devel
%define apxs /usr/sbin/apxs2
%define apache apache2
%define apache_libexecdir %(%{apxs} -q LIBEXECDIR)
%define apache_sysconfdir %(%{apxs} -q SYSCONFDIR)
%define apache_includedir %(%{apxs} -q INCLUDEDIR)
%define apache_serverroot %(%{apxs} -q PREFIX)
%define apache_mmn        %(MMN=$(%{apxs} -q LIBEXECDIR)_MMN; test -x $MMN && $MMN)
Summary:        Embedded Perl for Apache
License:        Apache-2.0
Group:          Productivity/Networking/Web/Servers
Requires:       %{apache_mmn}
Requires:       apache2
Requires:       perl = %{perl_version}
Requires:       perl-HTML-Parser
Requires:       perl-Tie-IxHash
Requires:       perl-URI
Requires:       perl-libwww-perl
Obsoletes:      mod_perl_2
Conflicts:      mod_perl
Version:        2.0.6
Release:        0
Patch:          %{name}-2.0.4-tests.diff
Patch1:         lfs-perl-5.14.patch 
# RT#77129
Patch2:         patch-PL_uid.diff
#%define apache_test_version 1_99_15
# cvs -d up -r MODPERL_%{apache_test_version}
#Source1:      Apache-Test-%{apache_test_version}.tar.bz2
Icon:         mod_perl.xpm
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

The Apache/Perl integration project brings together the full power of
the Perl programming language and the Apache HTTP server.

With mod_perl, it is possible to write Apache modules entirely in Perl.
The persistent interpreter embedded in the server avoids the overhead
of starting an external interpreter and the penalty of Perl start-up

Note that you do not need mod_perl to run perl scripts via the common
gateway interface (CGI). mod_perl enables you to run Perl scripts in an
embedded interpreter if the additional performance is needed, but may
require modifications to the scripts.


To load the module into Apache, run the command "a2enmod perl" as root.

To learn about the configuration, the best reference unequivocally is

For porting 1.0 applications to 2.0, the page should give
the required information.

Most mod_perl handlers use the perl-script handler. Scripts can run in
"mod_perl mode" (preconfigured for URLs starting with /perl/) or "perl
cgi mode" (preconfigured for URLs starting /cgi-perl). Plain CGI
scripts can be run via /cgi-bin/. In all these cases, the script would
be placed inside the /srv/www/cgi-bin/ directory. Refer to
/etc/apache2/conf.d/mod_perl.conf about this configuration.

%package devel
Summary:        Embedded Perl for Apache - Development package
Group:          Productivity/Networking/Web/Servers
Requires:       %{name} = %{version}
Provides:       apache2-mod_perl:/usr/include/apache2/modules/perl/modperl_cgi.h

%description devel
The Apache/Perl integration project brings together the full power of
the Perl programming language and the Apache HTTP server.

This package contains the include files useful for developing new
software depending on apache2-mod_perl.

#%setup -q -n modperl-2.0 -a 1
%setup -q -n mod_perl-%{version}
%patch1 -p1
find -name ".svn" -type d | xargs rm -rfv

perl Makefile.PL INSTALLDIRS=vendor MP_APXS=`which %{apxs}` MP_CCOPTS="$(%{apxs} -q CFLAGS)"
ln -s Apache-mod_perl_guide-1.29/bin bin
make %{?_smp_mflags}
# XXX mod_include/SSI does not include files when they are not named .shtml
mv t/htdocs/includes-registry/ t/htdocs/includes-registry/test.shtml
mv t/htdocs/includes-registry/ t/htdocs/includes-registry/cgipm.shtml
sed 's/\.pl/.shtml/' t/htdocs/includes/test.shtml > tmpfile && mv tmpfile t/htdocs/includes/test.shtml
%ifnarch %arm
# Run tests
# Don't use sendfile because most systems on which this package will be built don't run a 
# kernel that has it implemented, actually
# (Files smaller than 256 bytes will be delivered via conventional read/write, so most of the tests would pass nevertheless.)
echo -e '\n\nEnableSendfile off' >> t/conf/
# fix for bad_scripts.t in 1.99_12
# [Tue Mar 02 17:28:26 2004] [error] file permissions deny server execution/usr/src/packages/BUILD/modperl-2.0/ModPerl-Registry/t/cgi-bin/
if test -e ModPerl-Registry/t/cgi-bin/; then chmod +x ModPerl-Registry/t/cgi-bin/; fi
# 1.99_12_20040302 fix for t/hooks/cleanup.t and t/hooks/cleanup2.t
# [Tue Mar 02 18:38:41 2004] [error] [client] can't open /usr/src/packages/BUILD/modperl-2.0/t/htdocs/hooks/cleanup2: Permission denied at /usr/src/packages/BUILD/modperl-2.0/Apache-Test/lib/Apache/ line 82.
# enable more apache modules
# we can't simply use a2enmod, since we are not root.
cat >> t/conf/ <<-EOF
	LoadModule deflate_module    /usr/%_lib/apache2-prefork/
	LoadModule proxy_module      /usr/%_lib/apache2-prefork/
	LoadModule proxy_http_module /usr/%_lib/apache2-prefork/
mkdir -p t/htdocs/hooks
chmod 2770 t/htdocs/hooks
# run test suite:
#	ps aufx | grep "/usr/sbin/httpd2-prefork -d /usr/src/packages/BUILD/modperl-2.0" \
#	| grep -v grep | awk '{print $2}' | xargs -r kill
#	exit 1
t/TEST -start-httpd -port select -startup_timeout 720
t/TEST -run-tests || true
#t/TEST -run-tests || {
#	t/TEST -stop-httpd
#	exit 1
t/TEST -stop-httpd
# in case of failures, see
# then, debug like this:
# t/TEST -start-httpd
# tail -F t/logs/*&
# t/TEST -run-tests -verbose $failed_test
# t/TEST -stop-httpd

### since 11.4 perl_process_packlist
### removes .packlist, perllocal.pod files
%if 0%{?suse_version} > 1130
# do not perl_process_packlist
# remove .packlist file
find $RPM_BUILD_ROOT%perl_vendorarch/auto -name .packlist -print0 | xargs -0 -r rm ;
# remove perllocal.pod file
%{__rm} -f $RPM_BUILD_ROOT%perl_archlib/perllocal.pod

#mkdir -p $RPM_BUILD_ROOT/%{apache_libexecdir}
#cp -p src/modules/perl/ $RPM_BUILD_ROOT/%{apache_libexecdir}
%{__install} -D src/modules/perl/ \

#mkdir -p $RPM_BUILD_ROOT/%{apache_includedir}/modules/perl
%{__install} -d $RPM_BUILD_ROOT/%{apache_includedir}/modules/perl
%{__cp} src/modules/perl/*.h $RPM_BUILD_ROOT/%{apache_includedir}/modules/perl/

#mkdir -p $RPM_BUILD_ROOT/%{apache_sysconfdir}/conf.d
%{__install} -d $RPM_BUILD_ROOT/%{apache_sysconfdir}/conf.d

cat > $RPM_BUILD_ROOT/%{apache_sysconfdir}/ <<-EOF
  # Taken from
  if ( ! \$ENV{MOD_PERL}) { die "GATEWAY_INTERFACE not Perl!"; }
  use lib qw(/srv/www/perl-lib);
  # enable if the mod_perl 1.0 compatibility is needed
  # use Apache2::compat ();
  # preload all mp2 modules
  # use ModPerl::MethodLookup;
  # ModPerl::MethodLookup::preload_all_modules();
  use ModPerl::Util (); #for CORE::GLOBAL::exit
  use Apache2::RequestRec ();
  use Apache2::RequestIO ();
  use Apache2::RequestUtil ();
  use Apache2::ServerRec ();
  use Apache2::ServerUtil ();
  use Apache2::Connection ();
  use Apache2::Log ();
  use APR::Table ();
  use ModPerl::Registry ();
  use Apache2::Const -compile => ':common';
  use APR::Const -compile => ':common';

#mkdir -p $RPM_BUILD_ROOT/%{apache_serverroot}/perl-lib
%{__install} -d $RPM_BUILD_ROOT/%{apache_serverroot}/perl-lib

cat > $RPM_BUILD_ROOT/%{apache_sysconfdir}/conf.d/mod_perl.conf <<EOF
<Directory "%{apache_serverroot}/perl-lib">
    AllowOverride None
    Options None
    Order allow,deny
    Deny from all
<IfModule mod_perl.c>
    PerlRequire "/etc/apache2/"
    ScriptAlias /perl/ "%{apache_serverroot}/cgi-bin/"
    <Location /perl/>
	# mod_perl mode
	SetHandler perl-script
	PerlResponseHandler ModPerl::Registry
	PerlOptions +ParseHeaders
	Options +ExecCGI
    ScriptAlias /cgi-perl/ "%{apache_serverroot}/cgi-bin/"
    <Location /cgi-perl>
	# perl cgi mode
	SetHandler  perl-script
	PerlResponseHandler ModPerl::PerlRun
	PerlOptions +ParseHeaders
	Options +ExecCGI
    # The /cgi-bin/ ScriptAlias is already set up in httpd.conf
# install documentation files alongside perl modules, where applicable
%{__cp} -av docs/api/*.pod $RPM_BUILD_ROOT/%{perl_vendorarch}/
%{__cp} -av docs/api/APR/*.pod $RPM_BUILD_ROOT/%{perl_vendorarch}/APR/
%{__cp} -av docs/api/Apache2/*.pod $RPM_BUILD_ROOT/%{perl_vendorarch}/Apache2/
%{__cp} -av docs/api/ModPerl/*.pod $RPM_BUILD_ROOT/%{perl_vendorarch}/ModPerl/

%doc docs
%dir %{apache_libexecdir}
%config(noreplace) %{apache_sysconfdir}/
%config(noreplace) %{apache_sysconfdir}/conf.d/mod_perl.conf
%dir %{apache_serverroot}/perl-lib
#%dir %{perl_sitearch}/auto

%files devel