%bcond_with systemd

%define contentdir %{_datadir}/apache2
%define docroot /var/www/apache2
%define suexec_caller www-data
%define mmn 20120211
%define mmnisa %{mmn}%{__isa_name}%{__isa_bits}
%define pkgname apache2
%define vstring Vine

Name: %{pkgname}
Summary: Apache HTTP Server
Version: 2.4.54
Release: 1%{_dist_release}%{?with_systemd:.systemd}
Group: servers
Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

License: Apache Software License
URL: https://httpd.apache.org/
Source0: https://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2
Source2: index.html
Source3: apache2.logrotate
Source4: apache2.init
Source6: poweredby-vine.png
Source7: apache2.tmpfiles
Source10: httpd.conf
Source11: 00-base.conf
Source12: 00-mpm.conf
Source13: 00-lua.conf
Source14: 01-cgi.conf
Source15: 00-dav.conf
Source16: 00-proxy.conf
Source17: 00-ssl.conf
Source18: 01-ldap.conf
Source19: 00-proxyhtml.conf
Source20: userdir.conf
Source21: ssl.conf
Source22: welcome.conf
Source23: manual.conf
Source25: 01-session.conf
Source28: 00-optional.conf
# Documentation
Source30: README.confd
Source31: README.confmod
# add vine entry to config.layout
Source100: vine-config.layout

Source105: httpd-ssl-pass-dialog
Source106: httpd.tmpfiles
Source107: httpd.service
Source125: 00-systemd.conf
Source128: httpd.socket
Source127: 10-listen443.conf
Source140: htcacheclean.service
Source141: htcacheclean.sysconf
Source142: httpd-init.service
Source143: httpd-ssl-gencerts
Source144: httpd@.service

# build/scripts patches
Patch2: httpd-2.4.43-apxs.patch
Patch3: httpd-2.4.43-deplibs.patch
# Needed for socket activation and mod_systemd patch
Patch19: httpd-2.4.53-detect-systemd.patch
# Features/functional changes
Patch21: httpd-2.4.48-r1842929+.patch
Patch22: httpd-2.4.43-mod_systemd.patch
Patch23: httpd-2.4.53-export.patch
Patch24: httpd-2.4.43-corelimit.patch
Patch25: httpd-2.4.43-selinux.patch
Patch26: httpd-2.4.43-gettid.patch
Patch27: httpd-2.4.43-icons.patch
Patch30: httpd-2.4.43-cachehardmax.patch
Patch31: httpd-2.4.43-sslmultiproxy.patch
Patch34: httpd-2.4.43-socket-activation.patch
Patch38: httpd-2.4.43-sslciphdefault.patch
Patch39: httpd-2.4.43-sslprotdefault.patch
Patch40: httpd-2.4.43-r1861269.patch
Patch41: httpd-2.4.43-r1861793+.patch
Patch42: httpd-2.4.43-r1828172+.patch
Patch45: httpd-2.4.43-logjournal.patch
Patch46: httpd-2.4.53-separate-systemd-fns.patch

# Bug fixes
# https://bugzilla.redhat.com/show_bug.cgi?id=1397243
Patch60: httpd-2.4.43-enable-sslv3.patch
Patch61: httpd-2.4.48-r1878890.patch
Patch63: httpd-2.4.46-htcacheclean-dont-break.patch
Patch65: httpd-2.4.51-r1894152.patch

# Security fixes

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: db4-devel, expat-devel, xmlto
BuildRequires: findutils, perl, openldap-devel, zlib-devel
BuildRequires: apr-devel, apr-util-devel
BuildRequires: pcre-devel, sqlite3-devel
BuildRequires: lua-devel, libxml2-devel
BuildRequires: libnghttp2-devel
BuildRequires: brotli-devel
BuildRequires: www-common
Requires: mailcap, gawk, file, findutils, apr, apr-util
Requires(pre): www-common
Requires(pre): mktemp, fileutils
%if %{with systemd}
BuildRequires: systemd-devel
%{?systemd_requires}
%else
Requires(pre): chkconfig
Requires(pre): sh-utils, textutils, shadow-utils
Requires(post): alternatives
%endif
Provides: webserver
Provides: httpd = %{version}
Provides: httpd-mmn = %{mmn}
Provides: apache2-mmn = %{mmn}
Obsoletes: apache2-apr, apache2-apr-devel
Obsoletes: apache < 2.0, apache-devel < 2.0

%description
Apache is a powerful, full-featured, efficient, and freely-available
Web server. Apache is also the most popular Web server on the
Internet.


%package devel
Group: programming
Summary: Development tools for the Apache HTTP server.
Requires: libtool, apache2 = %{version}
Requires: apr-devel, apr-util-devel

%description devel
The httpd-devel package contains the APXS binary and other files
that you need to build Dynamic Shared Objects (DSOs) for Apache.

If you are installing the Apache HTTP server and you want to be
able to compile or develop additional modules for Apache, you need
to install this package.


%package manual
Group: documentation
Summary: Documentation for the Apache HTTP server.

%description manual
The httpd-manual package contains the complete manual and
reference guide for the Apache HTTP server. The information can
also be found at http://httpd.apache.org/docs/.


%package -n mod_ssl-apache2
Group: servers
Summary: SSL/TLS module for the Apache HTTP server
Epoch: 1
BuildRequires: openssl-devel
Requires(pre): net-tools, openssl, dev, /bin/cat
Requires: apache2, make, apache2-mmn = %{mmn}

%description -n mod_ssl-apache2
The mod_ssl module provides strong cryptography for the Apache Web
server via the Secure Sockets Layer (SSL) and Transport Layer
Security (TLS) protocols.


%debug_package


%prep
%setup -q -n httpd-%{version}

%patch2 -p1 -b .apxs
%patch3 -p1 -b .deplibs
%if %{with systemd}
%patch19 -p1 -b .detectsystemd
%endif
%patch21 -p1 -b .r1842929+
%if %{with systemd}
%patch22 -p1 -b .mod_systemd
%patch23 -p1 -b .export
%endif
%patch24 -p1 -b .corelimit
%patch25 -p1 -b .selinux
%patch26 -p1 -b .gettid
%patch27 -p1 -b .icons
%patch30 -p1 -b .cachehardmax
#patch31 -p1 -b .sslmultiproxy
%if %{with systemd}
%patch34 -p1 -b .socketactivation
%endif
%patch38 -p1 -b .sslciphdefault
%patch39 -p1 -b .sslprotdefault
%patch40 -p1 -b .r1861269
%patch41 -p1 -b .r1861793+
%patch42 -p1 -b .r1828172+

%patch60 -p1 -b .enable-sslv3
%patch61 -p1 -b .r1878890
%patch63 -p1 -b .htcacheclean-dont-break
%patch65 -p1 -b .r1894152
%if %{with systemd}
#patch45 -p1 -b .logjournal
%patch46 -p1 -b .separatesystemd
%endif

perl -pi -e 's|/httpd/build|/apache2/build|' support/apxs.in

# Patch in the vendor string
sed -i '/^#define PLATFORM/s/Unix/%{vstring}/' os/unix/os.h

# Prevent use of setcap in "install-suexec-caps" target.
sed -i '/suexec/s,setcap ,echo Skipping setcap for ,' Makefile.in

# add Vine configure's option to config.layout
sed -e "s|${prefix}/lib|${prefix}/%{_lib}|" \
  < $RPM_SOURCE_DIR/vine-config.layout >> config.layout


%build
# remove bundled apr, apr-util, pcre
rm -rf srclib/{apr,apr-util,pcre}

# regenerate configure scripts
autoheader && autoconf || exit 1

export CFLAGS="$RPM_OPT_FLAGS"
export LDFLAGS="-Wl,-z,relro,-z,now"
%if %{with systemd}
export HTTPD_LIBS="-lsystemd"
%endif

./configure \
	--prefix=%{_sysconfdir}/apache2 \
	--exec-prefix=%{_prefix} \
	--bindir=%{_bindir} \
	--sbindir=%{_sbindir} \
	--mandir=%{_mandir} \
	--libdir=%{_libdir} \
	--sysconfdir=%{_sysconfdir}/apache2/conf \
	--includedir=%{_includedir}/apache2 \
	--libexecdir=%{_libdir}/apache2/modules \
	--datadir=%{contentdir} \
	--with-installbuilddir=%{_libdir}/apache2/build \
	--enable-layout=Vine \
 	--with-program-name=apache2 \
	--with-ldap \
	--enable-ldap --enable-authnz-ldap \
	--enable-mods-shared=all \
	--enable-cache=shared \
	--enable-cgi=shared \
	--enable-cgid=shared \
	--enable-rewrite=shared \
	--enable-disk-cache=shared \
	--enable-file-cache=shared \
	--enable-mem-cache=shared \
	--enable-authn-anon --enable-authn-alias \
	--with-apr=%{_prefix} --with-apr-util=%{_prefix} \
	--enable-suexec --with-suexec \
	--enable-suexec-capabilities \
	--with-suexec-caller=%{suexec_caller} \
	--with-suexec-docroot=%{docroot} \
	--with-suexec-logfile=%{_localstatedir}/log/apache2/suexec.log \
	--with-suexec-bin=%{_sbindir}/suexec \
	--with-suexec-uidmin=500 --with-suexec-gidmin=500 \
	--with-brotli \
	--enable-pie \
	--with-pcre \
	--enable-ssl --with-ssl \
	--enable-deflate \
	--enable-proxy --enable-proxy-connect \
	--enable-proxy-http --enable-proxy-ftp \
	--enable-case-filter --enable-case-filter-in \
	--enable-http2 \
%if %{with systemd}
	--enable-systemd \
%endif
	--enable-mpms-shared=all

make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT install

%if %{with systemd}
# Install systemd service files
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
for s in httpd.service htcacheclean.service httpd.socket \
         httpd@.service httpd-init.service; do
  install -p -m 644 $RPM_SOURCE_DIR/${s} \
                    $RPM_BUILD_ROOT%{_unitdir}/${s}
done
# install systemd override drop directory
# Web application packages can drop snippets into this location if
# they need ExecStart[pre|post].
mkdir $RPM_BUILD_ROOT%{_unitdir}/httpd.service.d
mkdir $RPM_BUILD_ROOT%{_unitdir}/httpd.socket.d

install -m 644 -p $RPM_SOURCE_DIR/10-listen443.conf \
      $RPM_BUILD_ROOT%{_unitdir}/httpd.socket.d/10-listen443.conf
mkdir $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
install -m 644 -p $RPM_SOURCE_DIR/htcacheclean.sysconf \
   $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/htcacheclean
# tmpfiles.d configuration
mkdir -p $RPM_BUILD_ROOT%{_tmpfilesdir}
install -m 644 -p $RPM_SOURCE_DIR/httpd.tmpfiles \
   $RPM_BUILD_ROOT%{_tmpfilesdir}/httpd.conf

# install http-ssl-pass-dialog
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
install -m755 $RPM_SOURCE_DIR/httpd-ssl-pass-dialog \
        $RPM_BUILD_ROOT%{_libexecdir}/httpd-ssl-pass-dialog
# install http-ssl-gencerts
install -m755 $RPM_SOURCE_DIR/httpd-ssl-gencerts \
        $RPM_BUILD_ROOT%{_libexecdir}/httpd-ssl-gencerts
%else
# install SYSV init stuff
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
install -m755 $RPM_SOURCE_DIR/apache2.init \
	$RPM_BUILD_ROOT/etc/rc.d/init.d/apache2
%{__perl} -pi -e "s:\@docdir\@:%{_docdir}/%{name}-%{version}:g" \
	$RPM_BUILD_ROOT/etc/rc.d/init.d/apache2	
%endif

# create apache2ctl symlink
ln -sf apachectl $RPM_BUILD_ROOT%{_sbindir}/apache2ctl

# install conf file/directory
mkdir $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.d \
      $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.modules.d \
      $RPM_BUILD_ROOT%{_sysconfdir}/apache2/sites.d
install -m 644 $RPM_SOURCE_DIR/README.confd \
   $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.d/README
install -m 644 $RPM_SOURCE_DIR/README.confmod \
   $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.modules.d/README

for f in 00-base.conf 00-mpm.conf 00-lua.conf 01-cgi.conf 00-dav.conf \
         00-proxy.conf 00-ssl.conf 01-ldap.conf 00-proxyhtml.conf \
         01-ldap.conf 01-session.conf 00-optional.conf; do
  install -m 644 -p $RPM_SOURCE_DIR/$f \
                    $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.modules.d/$f
done
%if %{with systemd}
  install -m 644 -p %{SOURCE125} \
                    $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.modules.d/
%endif

for f in welcome.conf ssl.conf manual.conf userdir.conf; do
  install -m 644 -p $RPM_SOURCE_DIR/$f \
     $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.d/$f
done

# Split-out extra config shipped as default in conf.d:
for f in autoindex; do
  install -m 644 docs/conf/extra/httpd-${f}.conf \
     $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf.d/${f}.conf
done

# Extra config trimmed:
rm -v docs/conf/extra/httpd-{ssl,userdir}.conf

rm $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf/*.conf
install -m 644 -p $RPM_SOURCE_DIR/httpd.conf \
   $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf/httpd.conf
ln -sf httpd.conf $RPM_BUILD_ROOT%{_sysconfdir}/apache2/conf/apache2.conf

# Other directories
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/dav \
         $RPM_BUILD_ROOT/run/apache2/htcacheclean

# Create cache directory
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/apache2 \
         $RPM_BUILD_ROOT%{_localstatedir}/cache/apache2/proxy \
         $RPM_BUILD_ROOT%{_localstatedir}/cache/apache2/ssl

# Make the MMN accessible to module packages
echo %{mmnisa} > $RPM_BUILD_ROOT%{_includedir}/apache2/.mmn
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
cat > $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.apache2 <<EOF
%%_httpd_mmn %{mmnisa}
%%_httpd_apxs %%{_bindir}/apxs
%%_httpd_modconfdir %%{_sysconfdir}/apache2/conf.modules.d
%%_httpd_confdir %%{_sysconfdir}/apache2/conf.d
%%_httpd_contentdir %{contentdir}
%%_httpd_moddir %%{_libdir}/apache2/modules
%%_apache2_mmn %{mmnisa}
%%_apache2_apxs %%{_bindir}/apxs
%%_apache2_modconfdir %%{_sysconfdir}/apache2/conf.modules.d
%%_apache2_confdir %%{_sysconfdir}/apache2/conf.d
%%_apache2_contentdir %{contentdir}
%%_apache2_moddir %%{_libdir}/apache2/modules
EOF

# Handle contentdir
mkdir $RPM_BUILD_ROOT%{contentdir}/noindex
install -m 644 -p $RPM_SOURCE_DIR/index.html \
        $RPM_BUILD_ROOT%{contentdir}/noindex/index.html
install -m 644 -p $RPM_SOURCE_DIR/poweredby-vine.png \
        $RPM_BUILD_ROOT%{contentdir}/icons/
rm -rf %{contentdir}/htdocs

# remove manual sources
find $RPM_BUILD_ROOT%{contentdir}/manual \( \
    -name \*.xml -o -name \*.xml.* -o -name \*.ent -o -name \*.xsl -o -name \*.dtd \
    \) -print0 | xargs -0 rm -f

# Strip the manual down just to English and replace the typemaps with flat files:
set +x
for f in `find $RPM_BUILD_ROOT%{contentdir}/manual -name \*.html -type f`; do
   if test -f ${f}.en; then
      cp ${f}.en ${f}
      rm ${f}.*
   fi
done
set -x

# Clean Document Root
rm -v $RPM_BUILD_ROOT%{docroot}/html/*.html
rm -v $RPM_BUILD_ROOT/var/www/cgi-bin/*

# symlinks for /etc/apache2
ln -s ../..%{_localstatedir}/log/apache2 $RPM_BUILD_ROOT/etc/apache2/logs
ln -s /run/apache2 $RPM_BUILD_ROOT/etc/apache2/run
ln -s ../..%{_libdir}/apache2/modules $RPM_BUILD_ROOT/etc/apache2/modules

# Install logrotate config
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
install -m 644 -p $RPM_SOURCE_DIR/apache2.logrotate \
	$RPM_BUILD_ROOT/etc/logrotate.d/apache2

# fix man page paths
sed -e "s|/usr/local/apache2/conf/httpd.conf|/etc/apache2/conf/httpd.conf|" \
    -e "s|/usr/local/apache2/conf/mime.types|/etc/mime.types|" \
    -e "s|/usr/local/apache2/conf/magic|/etc/apache2/conf/magic|" \
    -e "s|/usr/local/apache2/logs/error_log|/var/log/apache2/error_log|" \
    -e "s|/usr/local/apache2/logs/access_log|/var/log/apache2/access_log|" \
    -e "s|/usr/local/apache2/logs/httpd.pid|/run/apache2/apache2.pid|" \
    -e "s|/usr/local/apache2|/etc/httpd|" < docs/man/httpd.8 \
  > $RPM_BUILD_ROOT%{_mandir}/man8/httpd.8

# Make ap_config_layout.h libdir-agnostic
sed -i '/.*DEFAULT_..._LIBEXECDIR/d;/DEFAULT_..._INSTALLBUILDDIR/d' \
    $RPM_BUILD_ROOT%{_includedir}/apache2/ap_config_layout.h

# Fix path to instdso in special.mk
sed -i '/instdso/s,top_srcdir,top_builddir,' \
    $RPM_BUILD_ROOT%{_libdir}/apache2/build/special.mk

# Remove unpackaged files
rm -vf \
      $RPM_BUILD_ROOT%{_libdir}/*.exp \
      $RPM_BUILD_ROOT/etc/apache2/conf/mime.types \
      $RPM_BUILD_ROOT%{_libdir}/apache2/modules/*.exp \
      $RPM_BUILD_ROOT%{_libdir}/apache2/build/config.nice \
      $RPM_BUILD_ROOT%{_bindir}/{ap?-config,dbmmanage} \
      $RPM_BUILD_ROOT%{_sbindir}/{checkgid,envvars*} \
      $RPM_BUILD_ROOT%{contentdir}/htdocs/* \
      $RPM_BUILD_ROOT%{_mandir}/man1/dbmmanage.* \
      $RPM_BUILD_ROOT%{contentdir}/cgi-bin/*

rm -rf $RPM_BUILD_ROOT/etc/apache2/conf/{original,extra}


%clean
rm -rf $RPM_BUILD_ROOT


%triggerpostun -- apache < 2.0
/sbin/chkconfig --add apache2

%post
%if %{with systemd}
%systemd_post httpd.service htcacheclean.service httpd.socket
%else
/sbin/chkconfig --add apache2
%endif

%preun
%if %{with systemd}
%systemd_preun httpd.service htcacheclean.service httpd.socket
%else
if [ $1 = 0 -o -x /bin/systemctl ]; then
	/sbin/service apache2 stop > /dev/null 2>&1
	/sbin/chkconfig --del apache2
fi
%endif

%postun
%if %{with systemd}
%systemd_postun httpd.service htcacheclean.service httpd.socket
%else
if [ "$1" -ge 1 ]; then
	/sbin/service apache2 condrestart
fi
%endif

%define sslcert %{_sysconfdir}/pki/tls/certs/localhost.crt
%define sslkey %{_sysconfdir}/pki/tls/private/localhost.key

%post -n mod_ssl-apache2
umask 077

if [ -f %{sslkey} -o -f %{sslcert} ]; then
  exit 0
fi

%{_bindir}/openssl genrsa \
  -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime \
  2048 > %{sslkey} 2> /dev/null ||:

FQDN=`hostname` ||:
if [ "x${FQDN}" = "x" ]; then
   FQDN=localhost.localdomain
fi
   
cat << EOF | %{_bindir}/openssl req -new -key %{sslkey} \
         -x509 -sha256 -days 3650 -set_serial $RANDOM -extensions v3_req \
         -out %{sslcert} 2>/dev/null ||:
--
SomeState
SomeCity
SomeOrganization
SomeOrganizationalUnit
${FQDN}
root@${FQDN}
EOF


%files
%defattr(-,root,root)
%license LICENSE
%doc ABOUT_APACHE README CHANGES LAYOUT
%doc docs/conf/extra/*.conf

%dir %{_sysconfdir}/apache2
%{_sysconfdir}/apache2/modules
%{_sysconfdir}/apache2/logs
%{_sysconfdir}/apache2/run
%dir %{_sysconfdir}/apache2/conf
%config(noreplace) %{_sysconfdir}/apache2/conf/httpd.conf
%config(noreplace) %{_sysconfdir}/apache2/conf/apache2.conf
%config(noreplace) %{_sysconfdir}/apache2/conf/magic

%config(noreplace) %{_sysconfdir}/logrotate.d/apache2

%if %{with systemd}
%{_unitdir}/httpd.service
%{_unitdir}/httpd@.service
%{_unitdir}/htcacheclean.service
%{_unitdir}/*.socket
%attr(755,root,root) %dir %{_unitdir}/httpd.service.d
%attr(755,root,root) %dir %{_unitdir}/httpd.socket.d
%config(noreplace) %{_sysconfdir}/sysconfig/htcacheclean
%{_tmpfilesdir}/httpd.conf
%else
%config %{_sysconfdir}/rc.d/init.d/apache2
%endif

%dir %{_sysconfdir}/apache2/conf.d
%{_sysconfdir}/apache2/conf.d/README
%config(noreplace) %{_sysconfdir}/apache2/conf.d/*.conf
%exclude %{_sysconfdir}/apache2/conf.d/ssl.conf
%exclude %{_sysconfdir}/apache2/conf.d/manual.conf

%dir %{_sysconfdir}/apache2/conf.modules.d
%{_sysconfdir}/apache2/conf.modules.d/README
%config(noreplace) %{_sysconfdir}/apache2/conf.modules.d/*.conf
%exclude %{_sysconfdir}/apache2/conf.modules.d/00-ssl.conf

%dir %{_sysconfdir}/apache2/sites.d

%{_bindir}/ab
%{_bindir}/ht*
%{_bindir}/logresolve
%{_sbindir}/ht*
%{_sbindir}/apache2
%{_sbindir}/apachectl
%{_sbindir}/apache2ctl
%{_sbindir}/rotatelogs
%{_sbindir}/fcgistarter
%attr(4510,root,%{suexec_caller}) %{_sbindir}/suexec

%dir %{_libdir}/apache2
%dir %{_libdir}/apache2/modules
%{_libdir}/apache2/modules/mod_*.so
%exclude %{_libdir}/apache2/modules/mod_ssl.so

%dir %{contentdir}
%dir %{contentdir}/icons
%dir %{contentdir}/error
%dir %{contentdir}/error/include
%dir %{contentdir}/noindex
%{contentdir}/icons/*
%{contentdir}/error/README
%{contentdir}/error/*.var
%{contentdir}/error/include/*.html
%{contentdir}/noindex/index.html

%dir %{docroot}/html
%dir /var/www/cgi-bin

%attr(0710,root,www-data) %dir /run/apache2
%attr(0700,www-data,www-data) %dir /run/apache2/htcacheclean

%attr(0700,root,root) %dir %{_localstatedir}/log/apache2
%attr(0700,www-data,www-data) %dir %{_localstatedir}/lib/dav
%attr(0700,www-data,www-data) %dir %{_localstatedir}/cache/apache2
%attr(0700,www-data,www-data) %dir %{_localstatedir}/cache/apache2/proxy

%{_mandir}/man1/*
%exclude %{_mandir}/man1/apxs*
%{_mandir}/man8/*

%files manual
%defattr(-,root,root)
%{contentdir}/manual
%config(noreplace) %{_sysconfdir}/apache2/conf.d/manual.conf

%files -n mod_ssl-apache2
%defattr(-,root,root)
%{_libdir}/apache2/modules/mod_ssl.so
%config(noreplace) %{_sysconfdir}/apache2/conf.modules.d/00-ssl.conf
%config(noreplace) %{_sysconfdir}/apache2/conf.d/ssl.conf
%attr(0700,www-data,www-data) %dir %{_localstatedir}/cache/apache2/ssl
%if %{with systemd}
%{_libexecdir}/httpd-ssl-pass-dialog
%{_libexecdir}/httpd-ssl-gencerts
%{_unitdir}/httpd-init.service
%{_unitdir}/httpd.socket.d/10-listen443.conf
%endif

%files devel
%defattr(-,root,root)
%{_includedir}/apache2
%{_bindir}/apxs
%{_mandir}/man1/apxs*
%dir %{_libdir}/apache2/build
%{_libdir}/apache2/build/*.mk
%{_libdir}/apache2/build/*.sh
%{_sysconfdir}/rpm/macros.apache2


%changelog
* Sat Jun 18 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.54-1
- new upstream release.
- updated Patch19 and 22-23.
- imported Patch45-46 and 61.

* Wed Jan 05 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.52-1
- new upstream release.

* Wed Oct 13 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.51-1
- new upstream release.
- built with openssl-3.0.0.

* Tue Sep 28 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.49-1
- new upstream release.
- dropped Patch1000: fixed in upstream.

* Thu Aug 26 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.48-2
- imported Patch1000 from upstream to fix CVE-2021-33193.
 
* Thu Jun 17 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.48-1
- new upstream release.
- dropped ldconfig scriptlets.
- updated Patch21 and 23.
- dropped Patch43, 44 and 62.
- imported Patch61 and 63 from rawhide.

* Wed Aug 19 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.46-1
- new upstream release.
- added systemd support (disabled as default).

* Thu Aug 29 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.41-1
- new upstream release.
- dropped Patch1 and 5.
- updated Patch23, 36 and 39.
- imported Patch21 and 40-42 from rawhide.

* Tue Nov 06 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.37-1
- new upstream release.
- updated patches.

* Sun Apr 01 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.33-1
- new upstream release.
- updated Patch35 and 58.
- disabled Patch31.
- dropped Patch23: fixed in upstream.
- imported Patch23 from rawhide.

* Mon Dec 18 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.29-1
- new upstream release.
- fixed apxs.
- dropped Patch56,60 and 61: fixed in upstream.

* Sun Oct 15 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.28-1
- new upstream release.

* Fri Mar 17 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.25-1
- new upstream release.
- dropped Patch55: fixed in upstream.

* Fri Jul  8 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.23-1
- new upstream release.

* Tue Jun  7 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.20-2
- enabled HTTP/2.

* Sun May 29 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.20-1
- updated to 2.4.20.
- updated Patch58.
- fixed %%files.
- fixed location of suexec (BTS#3007).

* Thu Mar 10 2016 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.4.18-2
- rebuilt with openssl 1.0.2g

* Thu Feb  4 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.18-1
- updated to 2.4.18.
- fixed 00-base.conf.
- updated Patch31.

* Mon Dec  7 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.17-2
- fixed configuration files.

* Fri Dec  4 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.17-1
- update to 2.4.17.
- fixed dependency.

* Wed Jun 25 2014 Daisuke SUZUKI <daisuke@vinelinux.org> 2.4.9-2
- modify dependency

* Wed Jun 25 2014 Daisuke SUZUKI <daisuke@vinelinux.org> 2.4.9-1
- update to 2.4.9
- remove suffix '2' from {htdigest,htpasswd,rotatelogs}2
- use /run instead of /var/run
- remove /etc/apache2/conf/ssl* , use /etc/pki now.
- move suexec from %%{_libdir}/apache2 to %%{_sbindir}
- split all LoadModules to conf.modules.d/*.conf
- split module configs to conf.d/*.conf
- cleanup docroot, move apache specific files to %%{_datadir}/apache2
- add BR: lua-devel, libxml2-devel
- add /etc/apache2/sites.d for virtual host settings.

* Wed Dec 25 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.2.25-2
- merge VineSeed spec file
  * Wed Oct 24 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.23-2
  - rebuild with pcre-8.31

  * Wed Mar 21 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.23-1
  - update to 2.2.23
  - add R(pre): www-common, BR: www-common
  - move apache contents to %{contentdir}

* Sat Sep 28 2013 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.25-1
- new upstream release with security fix (CVE-2013-1862,1896)
- drop patch100 (is included in new release)

* Fri May 17 2013 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.24-2
- add patch100 for fix CVE-2013-1862 (mod_rewrite)

* Wed Feb 27 2013 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.24-1
- new upstream release with security fix (CVE-2012-3499, 4558)

* Sun Sep 16 2012 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.23-1
- new upstream release with security fix (CVE-2012-3502,CVE-2012-2687)
- update patch22 to fit new release
- update man filename convert list

* Wed Mar 21 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.22-1
- update to 2.2.22
  - CVE-2012-0021 (mod_log_config)
  - CVE-2012-0031
  - CVE-2012-0053
- remove upstreamed patches

* Fri Dec  9 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.21-5
- add patch120 for fix CVE-2011-4317 (mod_rewrite/mod_proxy)

* Fri Nov 18 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.21-4
- add patch110 for fix CVE-2011-3607-4415 (ModSetEnvIf)

* Wed Oct 12 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.21-3
- add patch70 for fix byterange filter

* Tue Oct 11 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.21-2
- add Patch100 for fix CVE-2011-3368 (mod_proxy)

* Wed Sep 14 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.21-1
- new upstream release with security fix (CVE-2011-3348)
- regression fixes of CVE-2011-3192 byterange fix in 2.2.20

* Tue Sep  6 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.20-3
- update Patch101 (Thanks to debian team)

* Sat Sep  3 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.20-2
- add Patch101 for fix CVE-2011-3192 regression

* Thu Sep  1 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.20-1
- new upstream release with security fix (CVE-2011-3192)
- drop patch100 (is included in new release)

* Thu Aug 25 2011 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.19-2
- add patch100 for fix CVE-2011-3192 (Range Header DoS)

* Mon May 23 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.19-1
- update to 2.2.19

* Sat Apr 30 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.14-9
- remove old Obsoletes/Conflicts

* Tue Jan 11 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.2.14-8
- rebuild with openssl-1.0.0c

* Sat Aug 21 2010 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.14-7
- add  patch120 for fix CVE-2010-1452 (mod_dav/mod_cache) from mdk2010

* Wed Aug 18 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.14-6
- add R(post): alternatives

* Sat Mar 20 2010 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> - 2.2.14-5
- add patch110 for fix CVE-2010-0434 from mdk 2010

* Sun Mar  7 2010 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> - 2.2.14-4
- add patch100 for fix CVE-2010-0408 (mod_proxy_ajp)

* Fri Feb  5 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.2.14-3
- rebuilt with rpm-4.8.0-3 (on ppc)

* Tue Feb 02 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.14-2
- rebuild with db4-4.8.0

* Tue Jan 05 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.14-1
- new upstream release with security fix
  (CVE-2009-2699, CVE-2009-3095, CVE-2009-3094)
- fix ssl.conf (2.2.13-1 includes wrong file)

* Sun Aug 09 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.13-1
- new upstream release

* Wed Jul 29 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.12-1
- new upstream release 
  (including security fix for CVE-2009-1890, CVE-2009-1191,
   CVE-2009-1195, CVE-2009-1955, CVE-2009-1956, CVE-2009-0023)

* Fri Jan 09 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.11-2
- rebuilt with openldap-2.4.11

* Fri Jan  2 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.11-1
- new upstream release

* Sat Oct 18 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.10-1
- new upstream release (including security fix for CVE-2008-2939)

* Fri Jun 20 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.9-1
- new upstream release (including security fix for CVE-2008-2364, CVE-2007-6420)
- built with db4-4.6.21, apr 1.3.0

* Sun Apr 27 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 2.2.8-1
- add Patch60 (to fix bug#31418).

* Thu Feb 21 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.2.8-0vl2
- rebuild with expat-2.0.1

* Tue Jan 22 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.8-0vl1
- new upstream release

* Sat Nov  3 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.6-0vl2
- added postun script from VinePlus/4.0 package
  * Tue Sep 11 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.2.3-0vl3.2
  - add postun script to restart daemon with message

* Sun Jul 01 2007 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.3-0vl8
- updated Patch2: httpd-2.2.3-apxs.patch

* Sun Jun 24 2007 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.3-0vl7
- modified libdir in config.layout for lib64 architecture

* Sun May 27 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.3-0vl6
- rebuilt with openssl-0.9.8e

* Thu May 10 2007 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.2.3-0vl5
- rebuilt with new toolchain and db4-4.3.x

* Wed Feb  7 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.3-0vl4
- added BuildRequires: pcre-devel, sqlite3-devel <BTS:VineLinux:474>

* Mon Sep 11 2006 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 2.2.3-0vl3
- change manual Group to Applications/Documentation. <BTS:VineLinux:163>

* Sun Aug 27 2006 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.3-0vl2
- rebuilt with openldap-2.3.27-0vl1

* Sat Jul 29 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.3-0vl1
- new upstream release including security fix (CVE-2006-3747)

* Sun May 28 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.2-0vl1
- new upstream release
  - update to 2.2.2
- remove apr/apr-devel subpackage, 
  use external apr/apr-util instead of internal one.

* Sun May 28 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0.58-0vl1
- new upstream release
- use apache2.prefork as default.

* Thu Mar 23 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0.55-0vl3
- rebuild to use new _localstatedir (rpm-4.4.2-0vl11)
- remove unpackaged files in %%install section

* Fri Jan 27 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0.55-0vl2
- fix logrotate configuration (use apache2.pid instead of httpd.pid)
  (BTS:10)
- use Epoch instead of Serial

* Sat Oct 15 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0.55-0vl1
- new upstream release
- drop obsolete security patches which is merged in upstream

* Sat Oct 08 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0.54-0vl1
- new upstream release

* Sun Sep 11 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.0.53-0vl2
- added Patch122 to 125 for secutiry fix
  (CAN-2004-{1268,2088,2700,2728})
- fix %install section

* Sun Apr 10 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.0.53-0vl1
- new upstream release

* Sat Nov 06 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0.52-0vl1
- new upstream release

* Sun Oct 24 2004 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.0.50-0vl4
- rebuilt with db4-4.2.52

* Sat Sep  4 2004 USAMI Kosuke <usami-k@yc5.so-net.ne.jp> - 2.0.50-0vl3
- separate apr, apr-devel packages
- add BuildPreReq: zlib-devel

* Sun Jul 11 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0.50-0vl2
- fix %%files to include instdso.sh
  thanks to jax <jax AT morejams DOT no-ip DOT com>
- add %%{?_smp_mflags} to make option.

* Sun Jul  4 2004 IWAI, Masaharu <iwai@alib.jp> 2.0.50-0vl1
- new upstream version

* Sun Nov 23 2003 IWAI, Masaharu <iwai@alib.jp> 2.0.48-0vl1
- new upstream version

* Mon Sep 15 2003 IWAI, Masaharu <iwai@alib.jp> 2.0.47-0vl1
- new upstream version
- update apxs patch (Patch101)
- fix dependency:
    - change file name to package name in Requires and {Build,}Prereq
- add BuildPrereq: openldap-devel
- update %%files section
- rename httpd.8 manpage

* Mon May 12 2003 Satoshi MACHINO <machino@vinelinux.org> 2.0.45-0vl1
- new upstream version
- used vine-config.layout in srclib

* Mon May 12 2003 Satoshi MACHINO <machino@vinelinux.org> 2.0.44-0vl9
- rebuild

* Sun Apr  6 2003 Kazuhisa TAKEI <takei@vinelinux.org> 2.0.44-0vl8
- change pkg name from mod_ssl to mod_ssl-apache2
- remove "apache-manual" entry from Obsoletes:

* Thu Apr  3 2003 Kazuhisa TAKEI <takei@vinelinux.org> 2.0.44-0vl7
- remove "mod_dav" and "apache-devel" from Obsoletes: 
- enable MPMS(worker %mpms )

* Sun Mar 30 2003 Kazuhisa TAKEI <takei@vinelinux.org> 2.0.44-0vl6
- add correct config_vars.mk

* Sun Mar 30 2003 Kazuhisa TAKEI <takei@vinelinux.org> 2.0.44-0vl5
- apply apxs's patch ( from Debian)

* Sun Mar 30 2003 Kazuhisa TAKEI <takei@vinelinux.org> 2.0.44-0vl4
- add apr-config,apu-config to devel's %file 

* Sun Mar 30 2003 Kazuhisa TAKEI <takei@vinelinux.org> 2.0.44-0vl3
- change apxs path ( /usr/sbin -> /usr/bin
- add symlink under /etc/apache2/conf
  (logs, run), httpd.conf -> apache2.conf
- fixed apache2 initscript.

* Sat Mar 29 2003 Kazuhisa TAKEI <takei@vinelinux.org> 2.0.44-0vl2
- build Vine Linux
- new upstream version
- sharing with apache1

* Wed Sep  4 2002 Nalin Dahyabhai <nalin@redhat.com> 2.0.40-8
- link httpd with libssl to avoid library loading/unloading weirdness

* Tue Sep  3 2002 Joe Orton <jorton@redhat.com> 2.0.40-7
- add LoadModule lines for proxy modules in httpd.conf (#73349)
- fix permissions of conf/ssl.*/ directories; add Makefiles for
  certificate management (#73352)

* Mon Sep  2 2002 Joe Orton <jorton@redhat.com> 2.0.40-6
- provide "httpd-mmn" to manage module ABI compatibility

* Sun Sep  1 2002 Joe Orton <jorton@redhat.com> 2.0.40-5
- fix SSL session cache (#69699)
- revert addition of LDAP support to apr-util

* Mon Aug 26 2002 Joe Orton <jorton@redhat.com> 2.0.40-4
- set SIGXFSZ disposition to "ignored" (#69520)
- make dummy connections to the first listener in config (#72692)

* Mon Aug 26 2002 Joe Orton <jorton@redhat.com> 2.0.40-3
- allow "apachectl configtest" on a 1.3 httpd.conf
- add mod_deflate
- enable LDAP support in apr-util
- don't package everything in /var/www/error as config(noreplace)

* Wed Aug 21 2002 Bill Nottingham <notting@redhat.com> 2.0.40-2
- add trigger (#68657)

* Mon Aug 12 2002 Joe Orton <jorton@redhat.com> 2.0.40-1
- update to 2.0.40

* Wed Jul 24 2002 Joe Orton <jorton@redhat.com> 2.0.36-8
- improve comment on use of UserDir in default config (#66886)

* Wed Jul 10 2002 Joe Orton <jorton@redhat.com> 2.0.36-7
- use /sbin/nologin as shell for apache user (#68371)
- add patch from CVS to fix possible infinite loop when processing
  internal redirects

* Wed Jun 26 2002 Gary Benson <gbenson@redhat.com> 2.0.36-6
- modify init script to detect 1.3.x httpd.conf's and direct users
  to the migration guide

* Tue Jun 25 2002 Gary Benson <gbenson@redhat.com> 2.0.36-5
- patch apachectl to detect 1.3.x httpd.conf's and direct users
  to the migration guide
- ship the migration guide

* Fri Jun 21 2002 Joe Orton <jorton@redhat.com>
- move /etc/httpd2 back to /etc/httpd
- add noindex.html page and poweredby logo; tweak default config
  to load noindex.html if no default "/" page is present.
- add patch to prevent mutex errors on graceful restart

* Fri Jun 21 2002 Tim Powers <timp@redhat.com> 2.0.36-4
- automated rebuild

* Wed Jun 12 2002 Joe Orton <jorton@redhat.com> 2.0.36-3
- add patch to fix SSL mutex handling

* Wed Jun 12 2002 Joe Orton <jorton@redhat.com> 2.0.36-2
- improved config directory patch

* Mon May 20 2002 Joe Orton <jorton@redhat.com>
- initial build; based heavily on apache.spec and mod_ssl.spec
- fixes: #65214, #58490, #57376, #61265, #65518, #58177, #57245

