%define clamav_version 0.96

Summary: HAVP - HTTP Anti Virus Proxy
Name: havp
Version: 0.92a
Release: 1%{_dist_release}
License: GPL
Group: Applications/System
URL: http://www.server-side.de/
Source0: http://www.server-side.de/download/havp-%{version}.tar.gz
Patch0: havp.patch
BuildRequires: libstdc++-devel, zlib-devel, bzip2-devel, gmp-devel
BuildRequires: clamav-devel => %{clamav_version}
BuildRoot: %{_tmppath}/%{name}-%{version}-root/
#Requires: libstdc++, zlib, bzip2, gmp
Requires: clamav => %{clamav_version}
Vendor: Project Vine
Distribution: Vine Linux
Packager: tomop


%description
HAVP (HTTP AntiVirus proxy) is a proxy with an anti-virus filter.
It does not cache or filter content. At the moment the complete
traffic is scanned. The reason for this is the chance of malicious
code in nearly every filetype e.g. HTML (JavaScript) or Jpeg. I aim
to stop especially dialer or browser exploits. But writing a http
Anti Virus Proxy is a real dilemma! Huge downloads are a problem
for virus scanning proxies. A Client should not receive data which
is unchecked by the virus scanner, but big downloads should not timeout.

%prep

%setup -q
%patch0 -p0
#%patch1 -p1

%build
%configure --with-scanner=libclamav --enable-ssl-tunnel
make %{?_smp_mflags}

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_sysconfdir}/havp/templates
mkdir -p %{buildroot}%{_localstatedir}/log/havp
mkdir -p %{buildroot}%{_localstatedir}/tmp/havp
mkdir -p %{buildroot}%{_localstatedir}/run/havp
mkdir -p %{buildroot}%{_initdir}

install -m755 havp/havp %{buildroot}%{_sbindir}
install -m755 etc/init.d/havp %{buildroot}%{_initdir}
install -m644 etc/havp/havp.config %{buildroot}%{_sysconfdir}/havp/havp.config
install -m644 etc/havp/whitelist %{buildroot}%{_sysconfdir}/havp/whitelist
install -m644 etc/havp/blacklist %{buildroot}%{_sysconfdir}/havp/blacklist
cp -r etc/havp/templates/* %{buildroot}%{_sysconfdir}/havp/templates
chmod -R a+rX %{buildroot}/etc/havp/templates 

%clean
rm -rf %{buildroot}

%pre
if ! grep -q '^havp:' /etc/group; then
    /usr/sbin/groupadd -r havp
fi
if ! grep -q '^havp:' /etc/passwd; then
    /usr/sbin/useradd -M -r -s /sbin/nologin -g havp havp || :
fi

%postun
/sbin/ldconfig
if [ $1 = 0 ]; then
    if [ `grep havp /etc/passwd | wc -l` = 1 ]; then
        /usr/sbin/userdel havp
    fi
    if [ `grep havp /etc/group | wc -l` = 1 ]; then
        /usr/sbin/groupdel havp
    fi
fi

%post -p /sbin/ldconfig

%files 
%defattr(-,root,root,-)
%doc INSTALL COPYING ChangeLog
%{_initdir}/havp
%{_sbindir}/havp
%config(noreplace) %{_sysconfdir}/havp/havp.config
%config(noreplace) %{_sysconfdir}/havp/whitelist
%config(noreplace) %{_sysconfdir}/havp/blacklist
%{_sysconfdir}/havp/templates/*
%attr(750,havp,havp) %dir /var/log/havp
%attr(750,havp,havp) %dir /var/tmp/havp
%attr(750,havp,havp) %dir /var/run/havp 

%changelog
* Sun Dec 05 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.92a-1
- new upstream release.

* Sat Nov 06 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.92-1
- new upstream release.

* Thu Jun 11 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.90-1
- new upstream release.

* Tue Mar 24 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.89-1
- new upstream release.
- built with clamav-0.95.

* Tue Apr 15 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.87-2
- rebuild with clamav-0.93.

* Mon Apr 14 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.87-1
- rebuilt with VineSeed.

* Sat Mar  1 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.87-0vl1
- new upstream release.

* Sun Mar 11 2007 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.85-0vl2
- built with clamav-0.90.1.

* Mon Feb 26 2007 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.85-0vl1
- new upstream release.

* Thu Oct 19 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.82-0vl1
- new upstream release.

* Thu Jul 20 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.81-0vl1
- initial build.