%define dbdir %{_localstatedir}/lib/clamav

%if %{?_dist_release}!="vl5"
%define milter 1
%else
%define milter 0
%endif

Summary: Clam AntiVirus
Summary(ja): Clamアンチウィルススキャナ
Name: clamav
Version: 0.97.1
Release: 1%{?_dist_release}
License: GPL
Group: Applications/System
URL: http://www.clamav.net/
Source0: http://clamav.elektrapro.com/stable/%{name}-%{version}.tar.gz
Source1: clamd.init
Source2: freshclam.init
Source3: clamav-milter.init
Source4: clamav.logrotate
Source5: clamav-milter.logrotate

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: bzip2-devel, curl-devel > 7.10.0, gmp-devel, ncurses-devel
BuildRequires: openssl-devel, zlib-devel
%if %{?milter}
BuildRequires: sendmail-devel
%endif
Requires: bzip2, curl > 7.10.0, gmp, ncurses, openssl, zlib, logrotate
Requires(pre): shadow-utils, grep

Vendor: Project Vine
Distribution: Vine Linux
Packager: tomop, inagaki

%description
Clam Antivirus is a powerful anti-virus scanner for Unix. It supports
AMaViS, compressed files, uses the virus database from
OpenAntivirus.org, and includes a program for auto-updating. The scanner
is multithreaded, written in C, and POSIX compliant.

%description -l ja
Clamアンチウィルスは強力なUNIX向けのアンチウィルススキャナです。
AMaViS、圧縮ファイルをサポートし、OpenAntivirus.orgのウィルスデータ
ベースを利用しています。またウィルスデータベースの自動アップデート
プログラムを含んでいます。 このCで書かれたスキャナはマルチスレッド化
されており、 POSIXに準拠しています。

%if %{?milter}
%package milter
Summary: Virus scanner for sendmail/postfix
Group: Applications/System

%description milter
clamav-milter is a milter module to scan mails using Clam AntiVirus.

%endif

%package devel
Group: Development/Libraries
Summary: headers and libraries for development using Clam AntiVirus
Summary(ja): Clam AntiVirus を用いた開発に必要なヘッダ・ライブラリ
Requires: %{name} = %{version}-%{release}
Requires: zlib-devel bzip2-devel gmp-devel

%description devel
 clamav-devel provides headers and libraries for development using
Clam AntiVirus.

%description -l ja devel
　clamav-devel パッケージは、Clam AntiVirus を用いた開発を行うための
ヘッダファイルやライブラリファイルを提供します。

%prep
%setup -q

perl -pi -e 's|^#PidFile .+$|PidFile /var/run/clamav/clamd.pid|' etc/clamd.conf
perl -pi -e 's|^#LogFile .+$|LogFile /var/log/clamav/clamd.log|' etc/clamd.conf
perl -pi -e 's|^#PidFile .+$|PidFile /var/run/clamav/freshclam.pid|' etc/freshclam.conf
perl -pi -e 's|^#UpdateLogFile .+$|UpdateLogFile /var/log/clamav/freshclam.log|' etc/freshclam.conf
perl -pi -e 's|^#PidFile .+$|PidFile /var/run/clamav/clamav-milter.pid|' etc/clamav-milter.conf
perl -pi -e 's|^#LogFile .+$|LogFile /var/log/clamav/clamav-milter.log|' etc/clamav-milter.conf

%build
%if %{?milter}
%configure --disable-clamav --enable-milter --with-dbdir=%{dbdir}
%else
%configure --disable-clamav --with-dbdir=%{dbdir}
%endif

make %{?_smp_mflags}

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
mkdir -p %{buildroot}%{_initdir}
mkdir -p %{buildroot}%{_localstatedir}/run/clamav
mkdir -p %{buildroot}%{_localstatedir}/log/clamav
make install DESTDIR=%{buildroot} transform='s,x,x,'
install -m755 %{SOURCE1} %{buildroot}%{_initdir}/clamd
install -m755 %{SOURCE2} %{buildroot}%{_initdir}/freshclam
%if %{?milter}
install -m755 %{SOURCE3} %{buildroot}%{_initdir}/clamav-milter
install -m644 %{SOURCE5} %{buildroot}%{_sysconfdir}/logrotate.d/clamav-milter
%endif
install -m644 %{SOURCE4} %{buildroot}%{_sysconfdir}/logrotate.d/clamav
install etc/clamd.conf %{buildroot}%{_sysconfdir}
install etc/freshclam.conf %{buildroot}%{_sysconfdir}

rm -f %{buildroot}%{_libdir}/lib*a

%clean
rm -rf %{buildroot}

%pre
if ! grep -q '^clamav:' /etc/group; then
    /usr/sbin/groupadd -r clamav
fi
if ! grep -q '^clamav:' /etc/passwd; then
    /usr/sbin/useradd -M -r -s /bin/false -g clamav -c "Clam Antivirus" clamav || :
fi

%post
/sbin/ldconfig
/sbin/chkconfig --add clamd
/sbin/chkconfig --add freshclam

%preun
if [ "$1" = 0 ]; then
    [ ! -f /var/run/clamav/clamd.pid ] || /etc/init.d/clamd stop
    [ ! -f /var/run/clamav/freshclam.pid ] || /etc/init.d/freshclam stop
    /sbin/chkconfig --del clamd
    /sbin/chkconfig --del freshclam
fi

%postun
/sbin/ldconfig
if [ "$1" = 0 ]; then
    if [ `grep clamav /etc/passwd | wc -l` = 1 ]; then
        /usr/sbin/userdel clamav
    fi
    if [ `grep clamav /etc/group | wc -l` = 1 ]; then
        /usr/sbin/groupdel clamav
    fi
else
    [ ! -f /var/run/clamav/clamd.pid ] || /etc/init.d/clamd restart
    [ ! -f /var/run/clamav/freshclam.pid ] || /etc/init.d/freshclam restart
fi

%if %{?milter}
%post milter
/sbin/chkconfig --add clamav-milter

%preun milter
if [ "$1" = 0 ]; then
    [ ! -f /var/run/clamav/clamd.pid ] || /etc/init.d/clamav-milter stop
    /sbin/chkconfig --del clamav-milter
fi

%postun milter
if [ "$1" -ge 1 ]; then
    [ ! -f /var/run/clamav/clamav-milter.pid ] || /etc/init.d/clamav-milter restart
fi
%endif

%files 
%defattr(-,root,root)
%doc AUTHORS BUGS COPYING* ChangeLog FAQ INSTALL NEWS README examples test
%doc README
%doc docs/*
%{_initdir}/clamd
%{_initdir}/freshclam
%config(noreplace) %{_sysconfdir}/clamd.conf
%config(noreplace) %{_sysconfdir}/freshclam.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/clamav
%{_bindir}/*
%exclude %{_bindir}/clamav-config
%{_sbindir}/*
%{_libdir}/lib*.so.*
%attr(-,clamav,clamav) %dir %{_localstatedir}/run/clamav
%attr(-,clamav,clamav) %dir %{_localstatedir}/log/clamav
%attr(-,clamav,clamav) %dir %{dbdir}
%attr(-,clamav,clamav) %config(noreplace) %{dbdir}/*
%exclude %{_mandir}/man8/clamav-milter.8*
%{_mandir}/man*/*

%if %{?milter}

%files milter
%defattr(-,root,root)
%doc AUTHORS BUGS COPYING ChangeLog FAQ NEWS README
%{_initdir}/clamav-milter
%config(noreplace) %{_sysconfdir}/clamav-milter.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/clamav-milter
%{_sbindir}/clamav-milter
%{_mandir}/man8/clamav-milter.8*

%endif

%files devel
%defattr(-,root,root)
%doc AUTHORS BUGS COPYING ChangeLog FAQ NEWS README
%{_bindir}/clamav-config
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc
%{_includedir}/*

%changelog
* Thu Jun 09 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.97.1-1
- new upstream release.

* Sun Mar 27 2011 IWAI, Masaharu <iwai@alib.jp> 0.97-2
- add else routine for milter: fix building on Vine Linux 5

* Tue Feb 08 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.97-1
- new upstream release.

* Fri Dec 03 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.96.5-1
- new upstream release.

* Sat Nov 27 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.96.4-3
- moved virus databases to /var/lib/clamav.

* Wed Nov 17 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.96.4-2
- added milter support.

* Fri Nov 05 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.96.4-1
- new upstream release.
- added logrotate support.
- fixed pre/post scripts for daemons.

* Thu Sep 30 2010 Shu KONNO <owa@bg.wakwak.com> 0.96-2
- rebuilt with rpm-4.8.1 for pkg-config

* Sun Apr 11 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.96-1
- new upstream release.

* Sat Jan 30 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.95.3-1
- new upstream release.

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

* Tue Jun  2 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.95.1-1
- new upstream release.

* Tue Mar 24 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.95-2
- dropped *.a files.

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

* Tue Jun 10 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.93.1-1
- new upstream release.
- wrote specfile in UTF-8.

* Tue Apr 15 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.93-1
- new upstream release.
- move clamd.init to /etc/rc.d/init.d/.
- add /etc/rc.d/init.d/freshclam.

* Thu Apr 10 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.92.1-1
- apply new versioning policy.

* Sat Mar  1 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.92.1-0vl0.40.1
- add missing files.

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

* Tue Aug 21 2007 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.91.2-0vl0.40
- new upstream release.

* Thu Aug  9 2007 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.91.1-0vl0.40
- new upstream release.

* Fri Mar  2 2007 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.90.1-0vl0.40
- new upstream release.

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

* Thu Feb  1 2007 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.88.7-0vl0.40
- for Vine Linux 4.0.
- new upstream release.

* Tue Nov  7 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.88.6-0vl1
- built for VineSeed.

* Mon Nov  6 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.88.6-0vl0.1
- new upstream release.

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

* Wed Aug 16 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.88.4-0vl0.1
- rebuilt for Vine Linux 3.x.

* Wed Aug 16 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 0.88.4-0vl1
- new upstream release.

* Sat Aug  5 2006 IWAI, Masaharu <iwai@alib.jp> 0.88.2-0vl3
- add clamd.init script in doc dir

* Mon Aug  1 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.88.2-0vl2
- rebuilt for VineSeed (4.0)
- added libclamav.pc to devel package
- added Requires: gmp-devel to devel package

* Mon May  1 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.88.2-0vl1
- new upstream release.

* Wed Apr  5 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.88.1-0vl1
- new upstream release.

* Tue Jan 10 2006 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.88-0vl1
- new upstream release.

* Fri Nov  4 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.87.1-0vl1
- new upstream release.

* Sun Sep 18 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.87-0vl1
- new upstream release.

* Mon Jul 25 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.86.2-0vl1
- new upstream release.

* Sun Jun 26 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.86.1-0vl1
- new upstream release.
- fix "Requires:".

* Fri May 27 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.85.1-0vl1
- new upstream release.

* Mon May 16 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.85-0vl1
- new upstream release.

* Sun May  1 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.84-0vl2
- new upstream release.

* Tue Feb 15 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.83-0vl1
- new upstream release.

* Mon Feb 14 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.82-0vl1
- new upstream release.

* Thu Jan 27 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.81-0vl1
- new upstream release.

* Tue Nov  2 2004 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.80-0vl1
- new upstream release.

* Wed Aug 18 2004 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.75-0vl1
- new upstream release.

* Wed May  5 2004 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.70-0vl1
- new upstream release.

* Wed Apr 14 2004 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.68.1-0vl1
- new upstream release.

* Fri Feb 20 2004 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.67-0vl1
- new upstream release.

* Fri Nov 28 2003 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.65-0vl1
- new upstream release.

* Sat Aug 23 2003 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.60-0vl3
- fix %%files.

* Fri Aug 22 2003 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.60-0vl2
- fix 'Requires:' and %%files.

* Thu Aug 21 2003 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 0.60-0vl1
- new upstream release.
- add a sub-package 'devel'.

* Mon Nov  4 2002 TORAYA Shin-ichi <shin@tora-jp.com>
- 0.53-0vl1

* Wed Oct 30 2002 TORAYA Shin-ichi <shin@tora-jp.com>
- 0.52-0vl1

* Tue Oct 22 2002 TORAYA Shin-ichi <shin@tora-jp.com>
- 0.51-0vl1
- port to Vine Linux from (0.51-1m)

* Fri Oct 11 2002 Kazuhiko <kazuhiko@fdiary.net>
- (0.51-1m)
- major bugfixes

* Sun Oct  6 2002 Kazuhiko <kazuhiko@fdiary.net>
- (0.50-1m)
- major feature enhancements

* Fri Sep 20 2002 Kazuhiko <kazuhiko@fdiary.net>
- (0.24-2m)
- fix permission etc.

* Fri Aug 23 2002 Kazuhiko <kazuhiko@fdiary.net>
- (0.24-1m)
- minor bugfixes

* Sat Aug  3 2002 Kazuhiko <kazuhiko@fdiary.net>
- (0.23-1m)
- minor feature enhancements

* Fri Jul 19 2002 Kazuhiko <kazuhiko@fdiary.net>
- (0.21-1m)
- minor bugfixes

* Mon Jul 15 2002 Kazuhiko <kazuhiko@fdiary.net>
- (0.20-1m)
- revise URL
- add a new program 'sigtool'

* Thu Jun 13 2002 Kazuhiko <kazuhiko@kondara.org>
- (0.15-2k)

* Fri May 31 2002 Kazuhiko <kazuhiko@kondara.org>
- (0.14-2k)

* Thu May 23 2002 Kazuhiko <kazuhiko@kondara.org>
- (0.12-2k)

* Fri May 10 2002 Kazuhiko <kazuhiko@kondara.org>
- (0.11-2k)
