File tomcat6.spec of Package tomcat6

#
# spec file for package tomcat6 (Version 6.0.18)
#
# Copyright (c) 2010 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 http://bugs.opensuse.org/
#


%define section free
%define jspspec 2.1
%define major_version 6
%define minor_version 0
%define macro_version 18
%define packdname apache-tomcat-%{version}-src
%define servletspec 2.5
%define tcuid 91
# FHS 2.3 compliant tree structure - http://www.pathname.com/fhs/2.3/
%define appdir /srv/%{name}/webapps
%define bindir %{_datadir}/%{name}/bin
%define confdir %{_sysconfdir}/%{name}
%define homedir %{_datadir}/%{name}
%define libdir %{_javadir}/%{name}
%define logdir %{_localstatedir}/log/%{name}
%define tempdir %{_localstatedir}/cache/%{name}/temp
%define workdir %{_localstatedir}/cache/%{name}

Name:           tomcat6
Version:        %{major_version}.%{minor_version}.%{macro_version}
Release:        16.<RELEASE4>
Summary:        Apache Servlet/JSP Engine, RI for Servlet 2.5/JSP 2.1 API
Group:          Productivity/Networking/Web/Servers
License:        The Apache Software License
Url:            http://tomcat.apache.org
Source0:        http://www.apache.org/dist/tomcat/tomcat-6/v%{version}/src/%{packdname}.tar.bz2
Source1:        %{name}-%{major_version}.%{minor_version}.conf
Source2:        %{name}-%{major_version}.%{minor_version}.init
Source3:        %{name}-%{major_version}.%{minor_version}.sysconfig
Source4:        %{name}-%{major_version}.%{minor_version}.wrapper
Patch0:         %{name}-%{major_version}.%{minor_version}.bootstrap-MANIFEST.MF.patch
Patch1:         apache-tomcat-CVE-2009-0033.patch
Patch2:         apache-tomcat-CVE-2009-0580.patch
#apache-tomcat-CVE-2009-0783-1.patch is already part of 6.0.18
Patch3:         apache-tomcat-CVE-2009-0783-2.patch
Patch4:         apache-tomcat-CVE-2008-5515.patch
Patch5:         apache-tomcat-CVE-2009-0781.patch
#PATCH-FIX-UPSTREAM: bnc#575083
Patch6:         apache-tomcat-CVE-2009-2693-CVE-2009-2901-CVE-2009-2902.patch
#PATCH-FIX-UPSTREAM: http://svn.apache.org/viewvc?view=revision&revision=936540
Patch7:         apache-tomcat-CVE-2010-1157.patch
#PATCH-FIX-UPSTREAM: http://svn.apache.org/viewvc?view=revision&revision=958977
Patch8:         apache-tomcat-CVE-2010-2227.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
BuildRequires:  ant
BuildRequires:  ant-trax
BuildRequires:  ecj >= 3.2.2
BuildRequires:  findutils
BuildRequires:  jakarta-commons-collections
BuildRequires:  jakarta-commons-daemon
BuildRequires:  java-devel >= 1.5.0
BuildRequires:  jpackage-utils >= 1.7.0
BuildRequires:  junit
BuildRequires:  sed
%if %defined suse_version
BuildRequires:  unzip
BuildRequires:  jakarta-taglibs-standard >= 1.1
BuildRequires:  fdupes
PreReq:         %fillup_prereq
PreReq:         jpackage-utils
Recommends:     libtcnative-1-0
%endif
Requires(pre): %{_sbindir}/groupadd
Requires(pre): %{_sbindir}/useradd
Requires:       jakarta-commons-daemon
Requires:       jakarta-commons-logging
Requires:       %{name}-lib = %{version}-%{release}
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig

%description
Tomcat is the servlet container that is used in the official Reference
Implementation for the Java Servlet and JavaServer Pages technologies.
The Java Servlet and JavaServer Pages specifications are developed by
Sun under the Java Community Process.

Tomcat is developed in an open and participatory environment and
released under the Apache Software License version 2.0. Tomcat is
intended to be a collaboration of the best-of-breed developers from
around the world.



%package admin-webapps
License:        The Apache Software License
Group:          Productivity/Networking/Web/Servers
Summary:        The host-manager and manager web applications for Apache Tomcat
Requires:       %{name} = %{version}-%{release}

%description admin-webapps
The host-manager and manager web applications for Apache Tomcat



%package docs-webapp
License:        The Apache Software License
Group:          Productivity/Networking/Web/Servers
Summary:        The docs web application for Apache Tomcat
Requires:       %{name} = %{version}-%{release}

%description docs-webapp
The docs web application for Apache Tomcat



%package javadoc
License:        The Apache Software License
Group:          Productivity/Networking/Web/Servers
Summary:        Javadoc generated documentation for Apache Tomcat

%description javadoc
Javadoc generated documentation for Apache Tomcat



%package jsp-2_1-api
License:        The Apache Software License
Group:          Productivity/Networking/Web/Servers
Summary:        Apache Tomcat JSP API implementation classes
Provides:       %{name}-jsp-2.1-api
Requires:       %{name}-servlet-2_5-api = %{version}-%{release}
Requires(post): %{_sbindir}/update-alternatives
Requires(postun): %{_sbindir}/update-alternatives

%description jsp-2_1-api
Apache Tomcat JSP API implementation classes



%package lib
License:        The Apache Software License
Group:          Productivity/Networking/Web/Servers
Summary:        Libraries needed to run the Tomcat Web container
Requires:       %{name}-jsp-2_1-api = %{version}-%{release}
Requires:       %{name}-servlet-2_5-api = %{version}-%{release}
Requires(post): ecj >= 3.2.2
Requires(post): jakarta-commons-collections-tomcat5
Requires(post): jakarta-commons-dbcp-tomcat5
Requires(post): jakarta-commons-pool-tomcat5
Requires(preun): %{__rm}

%description lib
Libraries needed to run the Tomcat Web container



%package servlet-2_5-api
License:        The Apache Software License
Group:          Productivity/Networking/Web/Servers
Summary:        Apache Tomcat Servlet API implementation classes
Provides:       %{name}-servlet-2.5-api
Requires(post): %{_sbindir}/update-alternatives
Requires(postun): %{_sbindir}/update-alternatives

%description servlet-2_5-api
Apache Tomcat Servlet API implementation classes



%package webapps
License:        The Apache Software License
Group:          Productivity/Networking/Web/Servers
Summary:        The ROOT and examples web applications for Apache Tomcat
Requires:       %{name} = %{version}-%{release}
Requires(post): jakarta-taglibs-standard >= 1.1

%description webapps
The ROOT and examples web applications for Apache Tomcat



%prep
%{__rm} -rf ${RPM_BUILD_DIR}/%{name}-%{version}
%setup -q -c -T -a 0
%patch0
%patch1 -b .CVE-2009-0033
%patch2 -b .CVE-2009-0580
%patch3 -b .CVE-2009-0783-2
%patch4 -b .CVE-2008-5515
%patch5 -p1 -b .CVE-2009-0781
%patch6 -p1 -b .bnc575083
%patch7 -p1
%patch8 -p1

%build
pushd ${RPM_BUILD_DIR}/%{name}-%{version}/%{packdname}
    # remove pre-built binaries and windows files
    find . \( -name "*.bat" -o -name "*.class" -o -name "*.gz" -o \
              -name "*.jar" -o -name "*.zip" \) | xargs -t %{__rm} -f
    # we don't care about the tarballs and we're going to replace
    # tomcat-dbcp.jar with jakarta-commons-{collections,dbcp,pool}-tomcat5.jar
    # so just create a dummy file for later removal
    touch HACK
%if %defined suse_version
    export CLASSPATH="$(build-classpath xalan-j2-serializer)"
    export ANT_OPTS=-Xmx500M
%endif
    # who needs a build.properties file anyway
    ant -Dbase.path="${RPM_BUILD_DIR}/%{name}-%{version}/%{packdname}" \
        -Dbuild.compiler="modern" \
        -Dcommons-collections.jar="$(build-classpath commons-collections)" \
        -Dcommons-daemon.jar="$(build-classpath commons-daemon)" \
        -Dcommons-daemon.jsvc.tar.gz="HACK" \
        -Djasper-jdt.jar="$(build-classpath ecj)" \
        -Djdt.jar="$(build-classpath ecj)" \
        -Dtomcat-dbcp.jar="HACK" \
        -Dtomcat-native.tar.gz="HACK" \
        -Dversion="%{version}" \
        -Dversion.build="%{macro_version}"
    # javadoc generation
    ant -f dist.xml dist-prepare
    ant -f dist.xml dist-source
    ant -f dist.xml dist-javadoc
    # remove some jars that we'll replace with symlinks later
    %{__rm} output/build/bin/commons-daemon.jar \
            output/build/lib/ecj.jar
    # remove the cruft we created
    %{__rm} output/build/bin/HACK \
            output/build/bin/tomcat-native.tar.gz \
            output/build/lib/HACK
popd

%install
%if %defined suse_version
	export NO_BRP_CHECK_BYTECODE_VERSION=true
%endif
%{__rm} -rf $RPM_BUILD_ROOT
# build initial path structure
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{_javadocdir}/%{name}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{_sysconfdir}/init.d
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{appdir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{bindir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{confdir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{libdir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{logdir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{homedir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{tempdir}
%{__install} -d -m 0755 ${RPM_BUILD_ROOT}%{workdir}
# move things into place
pushd ${RPM_BUILD_DIR}/%{name}-%{version}/%{packdname}/output/build
    %{__mv} bin/*.{jar,xml} ${RPM_BUILD_ROOT}%{bindir}
    %{__mv} conf/*.{policy,properties,xml} ${RPM_BUILD_ROOT}%{confdir}
    %{__mv} lib/*.jar ${RPM_BUILD_ROOT}%{libdir}
    %{__mv} webapps/* ${RPM_BUILD_ROOT}%{appdir}
popd
# javadoc
pushd ${RPM_BUILD_DIR}/%{name}-%{version}/%{packdname}/output/dist/webapps
    %{__mv} docs/api/* ${RPM_BUILD_ROOT}%{_javadocdir}/%{name}
popd
%{__sed} -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \
         -e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" %{SOURCE1} \
%if %defined suse_version
         -e "s|\@\@\@JAVAHOME\@\@\@|/etc/alternatives/jre|g" \
%endif
    > ${RPM_BUILD_ROOT}%{confdir}/%{name}.conf
%if %defined suse_version
mkdir -p ${RPM_BUILD_ROOT}/var/adm/fillup-templates
cp %{SOURCE3} ${RPM_BUILD_ROOT}/var/adm/fillup-templates/sysconfig.%{name}
%else
%{__sed} -e "s|\@\@\@TCHOME\@\@\@|%{homedir}|g" \
         -e "s|\@\@\@TCTEMP\@\@\@|%{tempdir}|g" %{SOURCE3} \
    > ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/%{name}
%endif
%{__install} -m 0644 %{SOURCE2} \
    ${RPM_BUILD_ROOT}%{_sysconfdir}/init.d/%{name}
%{__install} -m 0644 %{SOURCE4} \
    ${RPM_BUILD_ROOT}%{_bindir}/d%{name}
# create jsp and servlet API symlinks
pushd ${RPM_BUILD_ROOT}%{_javadir}
    %{__mv} %{name}/jsp-api.jar %{name}-jsp-%{jspspec}-api-%{version}.jar
    %{__mv} %{name}/servlet-api.jar \
        %{name}-servlet-%{servletspec}-api-%{version}.jar
    %{__ln_s} %{name}-jsp-%{jspspec}-api-%{version}.jar \
        %{name}-jsp-%{jspspec}-api.jar
    %{__ln_s} %{name}-servlet-%{servletspec}-api-%{version}.jar \
        %{name}-servlet-%{servletspec}-api.jar
popd
pushd ${RPM_BUILD_ROOT}%{libdir}
    # fix up jars to include version number
    for i in *.jar; do
        j="$(echo $i | %{__sed} -e 's,\.jar$,,')"
        %{__mv} ${j}.jar ${j}-%{version}.jar
        %{__ln_s} ${j}-%{version}.jar ${j}.jar
    done
    # symlink JSP and servlet API jars
    %{__ln_s} ../%{name}-jsp-%{jspspec}-api-%{version}.jar .
    %{__ln_s} ../%{name}-servlet-%{servletspec}-api-%{version}.jar .
popd
pushd ${RPM_BUILD_ROOT}%{bindir}
    # fix up jars to include version number
    for i in *.jar; do
        j="$(echo $i | %{__sed} -e 's,\.jar$,,')"
        %{__mv} ${j}.jar ${j}-%{version}.jar
        %{__ln_s} ${j}-%{version}.jar ${j}.jar
    done
popd
# symlink to the FHS locations where we've installed things
pushd ${RPM_BUILD_ROOT}%{homedir}
    %{__ln_s} %{appdir} webapps
    %{__ln_s} %{confdir} conf
    %{__ln_s} %{libdir} lib
    %{__ln_s} %{logdir} logs
    %{__ln_s} %{tempdir} temp
    %{__ln_s} %{workdir} work
popd
# bnc#424675
install -d -m 0755 ${RPM_BUILD_ROOT}%{workdir}/Catalina
%{__ln_s} %{workdir}/Catalina ${RPM_BUILD_ROOT}/%{confdir}/Catalina 
# bnc#418664
install -d -m 0755 ${RPM_BUILD_ROOT}/%{_sysconfdir}/ant.d/
echo "tomcat6/catalina-ant" > ${RPM_BUILD_ROOT}/%{_sysconfdir}/ant.d/catalina-ant
%if %defined suse_version
%fdupes $RPM_BUILD_ROOT /srv/%{name}
install -d -m 755 $RPM_BUILD_ROOT/%{_sbindir}
ln -sf %{_sysconfdir}/init.d/%{name} $RPM_BUILD_ROOT/%{_sbindir}/rc%{name}
#bnc#565901
ln -sf %{_bindir}/d%{name} %{buildroot}/%{bindir}/catalina.sh
%endif

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%pre
# add the tomcat user and group
%if %defined suse_version
%{_sbindir}/groupadd -r tomcat 2>/dev/null || :
%{_sbindir}/useradd -c "Apache Tomcat" -g tomcat \
    -s /bin/sh -r -d %{homedir} tomcat 2>/dev/null || :
%else
%{_sbindir}/groupadd -g %{tcuid} -r tomcat 2>/dev/null || :
%{_sbindir}/useradd -c "Apache Tomcat" -u %{tcuid} -g tomcat \
    -s /bin/sh -r -d %{homedir} tomcat 2>/dev/null || :
%endif

%post
%if %defined suse_version
%{fillup_only}
%else
# install but don't activate
/sbin/chkconfig --add %{name}
%endif

%post jsp-2_1-api
%{_sbindir}/update-alternatives --install %{_javadir}/jsp.jar jsp \
    %{_javadir}/%{name}-jsp-%{jspspec}-api.jar 20100

%post lib
# HACK! The commons-dbcp-tomcat5 needs the tomcat6-lib to build, but tomcat6
# needs this only as post/un dependency to create a symlink, not for build of
# itself. This is mainly for succesfully build, in the production case it
# should not happen!
build-jar-repository %{libdir} \
        commons-collections-tomcat5 \
        commons-dbcp-tomcat5 \
        commons-pool-tomcat5 \
        ecj 2>&1 || exit 0

%post servlet-2_5-api
%{_sbindir}/update-alternatives --install %{_javadir}/servlet.jar servlet \
    %{_javadir}/%{name}-servlet-%{servletspec}-api.jar 20500

%post webapps
build-jar-repository %{appdir}/examples/WEB-INF/lib \
    taglibs-core.jar taglibs-standard.jar 2>&1

%preun
# clean tempdir and workdir on removal or upgrade
## % {__rm} -fr %{workdir}/* # %{tempdir}/*
%if %defined suse_version
%stop_on_removal %{name}
%else
if [ "$1" = "0" ]; then
    [ -f /var/lock/subsys/%{name} ] && %{_sysconfdir}/init.d/%{name} stop
    [ -f %{_sysconfdir}/init.d/%{name} ] && /sbin/chkconfig --del %{name}
fi
%endif

%preun lib
if [ "$1" = "0" ]; then
    %{__rm} -f \
        %{libdir}/\[commons-collections-tomcat5\].jar \
        %{libdir}/\[commons-dbcp-tomcat5\].jar \
        %{libdir}/\[commons-pool-tomcat5\].jar \
        %{libdir}/\[ecj\].jar >/dev/null 2>&1
fi
%if %defined suse_version

%postun
%restart_on_update %{name}
%insserv_cleanup
%endif

%postun jsp-2_1-api
if [ "$1" = "0" ]; then
    %{_sbindir}/update-alternatives --remove jsp \
        %{_javadir}/%{name}-jsp-%{jspspec}-api.jar
fi

%postun servlet-2_5-api
if [ "$1" = "0" ]; then
    %{_sbindir}/update-alternatives --remove servlet \
        %{_javadir}/%{name}-servlet-%{servletspec}-api.jar
fi

%files
%defattr(0644,root,root,0755)
%doc %{packdname}/{LICENSE,NOTICE,RELEASE*}
%attr(755,root,root) %{_bindir}/d%{name}
%attr(0770,root,tomcat) %dir %{_localstatedir}/log/%{name}
%attr(755,root,root) %{_sysconfdir}/init.d/%{name}
%if %defined suse_version
%{_var}/adm/fillup-templates/*
#bnc#565901
%attr(0755,root,root) %{bindir}/catalina.sh
%else
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%endif
%attr(0775,root,tomcat) %dir %{appdir}
%dir %{confdir}
%config(noreplace) %{confdir}/%{name}.conf
%config(noreplace) %{confdir}/*.policy
%config(noreplace) %{confdir}/*.properties
%config(noreplace) %{confdir}/context.xml
%config(noreplace) %{confdir}/server.xml
%attr(660,root,tomcat) %config(noreplace) %{confdir}/tomcat-users.xml
%config(noreplace) %{confdir}/web.xml
%attr(0775,root,tomcat) %dir %{tempdir}
%attr(0775,root,tomcat) %dir %{workdir}
%{homedir}
%dir /srv/%{name}
%{_sbindir}/rc%{name}
#bnc#424675
%attr(0775,root,tomcat) %dir %{workdir}/Catalina
%{confdir}/Catalina

%files admin-webapps
%defattr(0644,root,root,0755)
%{appdir}/host-manager
%{appdir}/manager

%files docs-webapp
%defattr(0644,root,root,0755)
%{appdir}/docs

%files javadoc
%defattr(0644,root,root,0755)
%{_javadocdir}/%{name}

%files jsp-2_1-api
%defattr(0644,root,root,0755)
%{_javadir}/%{name}-jsp*.jar

%files lib
%defattr(0644,root,root,0755)
%{libdir}
# bnc#418664
%config %{_sysconfdir}/ant.d

%files servlet-2_5-api
%defattr(0644,root,root,0755)
%{_javadir}/%{name}-servlet*.jar

%files webapps
%defattr(0644,root,root,0755)
%{appdir}/ROOT
%{appdir}/examples

%changelog
openSUSE Build Service is sponsored by