File dba-apache2-mod_perl.spec of Package dba-apache2-mod_perl

%define vers    208
%define version 2.0.8
%define prefix  /DBA/apache/WWW/2.2.x
%define apavers 2.2.29
%define apapack 2229
%define apahome /DBA/apache/WWW/%{apavers}
%define apxs    %{apahome}/bin/apxs
%define modname mod_perl
%define apache_serverroot %(%{apxs} -q PREFIX)
%define maketest 0


Name:           dba-apache2-%{modname}-%{vers}
Summary:        Embedded Perl for Apache
Group:          Productivity/Networking/Web/Servers
Url:            http://perl.apache.org/
AutoReqProv:    on
License:        The Apache Software License
Version:        %{version}
Release:        1
Source0:        http://apache.openmirror.de/perl/%{modname}-%{version}.tar.gz
Source1:        dba-apache2-mod_perl-rpmlintrc
Source2:        filter-requires-modperl.sh
Patch1:		mod_perl.fixsles11.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%define _use_internal_dependency_generator 0
%define __find_requires %{SOURCE2}

BuildRequires:  dba-apache-%{apapack}
Requires:  	dba-apache-base

#!BuildIgnore:  dba-postgresql-839 dba-postgresql-842 dba-postgresql-845 dba-postgresql-846
#!BuildIgnore:  dba-postgresql-901 dba-postgresql-902 dba-postgresql-904 dba-postgresql-910
#!BuildIgnore:  dba-openssl-098o dba-openssl-098r dba-openssl-098x

%if 0%{?fedora_version}
BuildRequires:  perl-devel
%endif

%if %{?suse_version:1}0
PreReq:         permissions
BuildRequires:  db-devel openldap2 openldap2-devel
BuildRequires:  perl(Module::Build)
%else
BuildRequires:  openldap openldap-devel
BuildRequires:  perl(ExtUtils::Embed)
%if 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
BuildRequires:  perl(Module::Build)
%endif
%if 0%{?rhel_version} >= 700 || 0%{?centos_version} >= 700
BuildRequires:  libdb
%else
BuildRequires:  db4-devel
BuildRequires:  perl(BSD::Resource)
%endif
%endif

BuildRequires:  ed pcre-devel perl-libwww-perl sudo
BuildRequires:  perl(ExtUtils::MakeMaker)

%if 0%{?suse_version}
# BuildRequires:  libapr-util1-devel >= 1.3 libapr1-devel >= 1.3
%else
# BuildRequires:  apr-util-devel apr-devel which
BuildRequires:  which
%endif

%if 0%{?suse_version}
BuildRequires:  perl-Tie-IxHash
BuildRequires:  perl-Compress-Zlib

%if 0%{sles_version} == 9
BuildRequires:  openldap2-devel
%endif

%if 0%{?suse_version} >= 1100
BuildRequires:          -post-build-checks
%endif
%endif


Requires:       perl-HTML-Parser perl-Tie-IxHash 
Requires:       perl-URI perl-libwww-perl
Conflicts:      apache2-mod_perl


%description
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
time.

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.

Usage:

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

To learn about the configuration, the best reference unequivocally is
http://perl.apache.org/docs/

For porting 1.0 applications to 2.0, the page
http://perl.apache.org/docs/2.0/user/porting/compat.html 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.




%prep
%setup -q -n %{modname}-%{version}
%{__chmod} +x %{SOURCE2}

find -name ".svn" -type d | xargs rm -rfv
%if 0%{?sles_version} == 11
%patch1 -p1
%endif

%build
%if 0%{?suse_version} >= 1100
export MP_USE_MY_EXTUTILS_EMBED=1
%endif
perl Makefile.PL MP_APXS=`which %{apxs}` MP_CCOPTS="$(%{apxs} -q CFLAGS)"
# ln -s Apache-mod_perl_guide-1.29/bin bin
make
# XXX mod_include/SSI does not include files when they are not named .shtml
mv t/htdocs/includes-registry/test.pl t/htdocs/includes-registry/test.shtml
mv t/htdocs/includes-registry/cgipm.pl t/htdocs/includes-registry/cgipm.shtml
sed 's/\.pl/.shtml/' t/htdocs/includes/test.shtml > tmpfile && mv tmpfile t/htdocs/includes/test.shtml
%if %maketest
%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/extra.conf.in
#
# 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/r_inherited.pl
if test -e ModPerl-Registry/t/cgi-bin/r_inherited.pl; then chmod +x ModPerl-Registry/t/cgi-bin/r_inherited.pl; 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 127.0.0.1] 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/TestUtil.pm line 82.
#
# enable more apache modules
# we can't simply use a2enmod, since we are not root.
cat >> t/conf/extra.conf.in <<-EOF
	LoadModule deflate_module    /usr/%_lib/apache2-prefork/mod_deflate.so
	LoadModule proxy_module      /usr/%_lib/apache2-prefork/mod_proxy.so
	LoadModule proxy_http_module /usr/%_lib/apache2-prefork/mod_proxy_http.so
EOF
mkdir -p t/htdocs/hooks
chmod 2770 t/htdocs/hooks
#
# run test suite:
#
#make TEST_VERBOSE=1 APACHE_TEST_PORT=select APACHE_TEST_STARTUP_TIMEOUT=360 test  || { 
#	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 http://perl.apache.org/docs/2.0/user/help/help.html#_C_make_test___Failures
# then, debug like this:
# t/TEST -start-httpd
# tail -F t/logs/*&
# t/TEST -run-tests -verbose $failed_test
# t/TEST -stop-httpd
%endif

%endif

%install
# prevent rpath problem on suse
export NO_BRP_CHECK_RPATH=true

rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install_vendor
mkdir -p %{buildroot}%{prefix}/modules/
cp -p src/modules/perl/%{modname}.so %{buildroot}%{prefix}/modules/
# mkdir -p $RPM_BUILD_ROOT/%{apache_includedir}/modules/perl
# cp src/modules/perl/*.h $RPM_BUILD_ROOT/%{apache_includedir}/modules/perl/
%if 0%{?suse_version}
%perl_process_packlist
%endif
# mkdir -p $RPM_BUILD_ROOT/%{apache_sysconfdir}/conf.d
# cat > $RPM_BUILD_ROOT/%{apache_sysconfdir}/mod_perl-startup.pl <<-EOF
mkdir -p %{buildroot}%{prefix}/bin/
cat > %{buildroot}%{prefix}/bin/mod_perl-startup.pl <<-EOF
  # Taken from http://perl.apache.org/docs/2.0/user/handlers/server.html#Startup_File
  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';
  1;
EOF
# mkdir -p $RPM_BUILD_ROOT/%{apache_serverroot}/perl-lib
mkdir -p %{buildroot}%{prefix}/conf/
# cat > $RPM_BUILD_ROOT/%{apache_sysconfdir}/conf.d/mod_perl.conf <<EOF
cat > %{buildroot}%{prefix}/conf/mod_perl.conf <<EOF
<Directory "%{apache_serverroot}/perl-lib">
    AllowOverride None
    Options None
    Order allow,deny
    Deny from all
</Directory>
<IfModule mod_perl.c>
    PerlRequire "/etc/apache2/mod_perl-startup.pl"
    ScriptAlias /perl/ "%{apache_serverroot}/cgi-bin/"
    <Location /perl/>
	# mod_perl mode
	SetHandler perl-script
	PerlResponseHandler ModPerl::Registry
	PerlOptions +ParseHeaders
	Options +ExecCGI
    </Location>
    ScriptAlias /cgi-perl/ "%{apache_serverroot}/cgi-bin/"
    <Location /cgi-perl>
	# perl cgi mode
	SetHandler  perl-script
	PerlResponseHandler ModPerl::PerlRun
	PerlOptions +ParseHeaders
	Options +ExecCGI
    </Location>
    # The /cgi-bin/ ScriptAlias is already set up in httpd.conf
</IfModule>
# vim: ft=apache
EOF
# 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/
# remove unwanted files
find %{buildroot}/usr -name "perllocal.pod" -o -name ".packlist" -o -name "*.bs" |xargs --no-run-if-empty rm -fv {}
%{__rm} -f %{buildroot}/var/adm/perl-modules/*

# move include files
if test -d %{buildroot}%{apahome}/include; then
  %{__mv} %{buildroot}%{apahome}/include %{buildroot}%{prefix}/
fi
%{__rm} -rfv %{buildroot}%{apahome}


%files
%defattr(-,root,root)
%doc Changes INSTALL LICENSE README RELEASE STATUS
%doc docs
# %dir %{apache_libexecdir}
%dir %{prefix}
%{prefix}/conf
%{prefix}/include
%{prefix}/modules/%{modname}.so
%config(noreplace) %{prefix}/bin/mod_perl-startup.pl
%config(noreplace) %{prefix}/conf/mod_perl.conf
# %config(noreplace) %{apache_sysconfdir}/mod_perl-startup.pl
# %config(noreplace) %{apache_sysconfdir}/conf.d/mod_perl.conf
# %dir %{apache_serverroot}/perl-lib
%{_mandir}/man3/*
%{perl_vendorarch}/Apache
%{perl_vendorarch}/Apache2
%{perl_vendorarch}/APR
%{perl_vendorarch}/APR.pm
%{perl_vendorarch}/Bundle
%{perl_vendorarch}/ModPerl
#%dir %{perl_sitearch}/auto
%{perl_vendorarch}/auto/*
%{perl_vendorarch}/mod_perl2.pm
%{perl_vendorarch}/*.pod
/usr/bin/mp2bug


%clean
if ! test -f /.buildenv; then
	rm -rf $RPM_BUILD_ROOT
fi

%changelog
* Tue May 26 2015 Holger Manthey <holger.manthey@bertelsmann.de>
- add filter-requires-modperl.sh
* Fri May 22 2015 Holger Manthey <holger.manthey@bertelsmann.de>
- upgrade to 2.0.8
* Fri Feb 10 2012 Holger Manthey <holger.manthey@bertelsmann.de>
- upgrade to 2.0.5
* Mon Jan 11 2010 Holger Manthey <holger.manthey@bertelsmann.de>
- inital version
openSUSE Build Service is sponsored by