-Summary: A Mail Virus Scanner
-Summary(pl): Antywirusowy skaner poczty elektronicznej
+# TODO:
+# Make freshclam (script and daemon)
+
+Summary: An anti-virus utility for Unix
+Summary(pl): Antywirusowe narzêdzie dla Uniksów
Name: clamav
-Version: 0.11
-Release: 4
-URL: http://www.konarski.edu.pl/~zolw/clam.html
-Source0: http://www.konarski.edu.pl/~zolw/clam/%{name}-%{version}.tar.gz
-Patch0: %{name}-am_ac.patch
+Version: 0.74
+Release: 2
License: GPL
-Group: Applications/Mail
+Group: Applications
+Source0: http://dl.sourceforge.net/clamav/%{name}-%{version}.tar.gz
+# Source0-md5: 3a1e6e0b33267749cdb1f4104ed42f14
+Source1: %{name}.init
+Source2: %{name}.sysconfig
+Source4: %{name}-cron-updatedb
+Source5: %{name}.logrotate
+# Remember to update date after databases upgrade
+%define database_version 20040703
+Source6: http://www.clamav.net/database/daily.cvd
+# Source6-md5: 794193f51b470ebf9d8f04b2e647fe67
+Source7: http://www.clamav.net/database/main.cvd
+# Source7-md5: 937f22844dd8dc7e75604a7c0939ad73
+Source8: %{name}-post-updatedb
+Patch0: %{name}-pld_config.patch
+Patch1: %{name}-no_auto_libwrap.patch
+URL: http://www.clamav.net/
BuildRequires: autoconf
BuildRequires: automake
+BuildRequires: zlib-devel
+BuildRequires: gmp-devel
+Requires(post,preun): /sbin/chkconfig
+Requires: %{name}-libs = %{version}-%{release}
+Requires: bc
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
aktualizacji. Skaner jest wielow±tkowy, napisany w C i zgodny z
POSIXem.
+%package libs
+Summary: Shared libraries for clamav
+Summary(pl): Biblioteki dzielone clamav
+Group: Libraries
+
+%description libs
+Shared libraries for clamav.
+
+%description libs -l pl
+Biblioteki dzielone clamav.
+
+%package devel
+Summary: clamav - Development header files and libraries
+Summary(pl): clamav - Pliki nag³ówkowe i biblioteki dla programistów
+Group: Development/Libraries
+Requires: %{name}-libs = %{version}-%{release}
+
+%description devel
+This package contains the development header files and libraries
+necessary to develop clamav client applications.
+
+%description devel -l pl
+Pliki nag³ówkowe i biblioteki konieczne do kompilacji aplikacji
+klienckich clamav.
+
+%package static
+Summary: clamav static libraris
+Summary(pl): Biblioteki statyczne clamav
+Group: Development/Libraries
+Requires: %{name}-devel = %{version}-%{release}
+
+%description static
+clamav static libraries.
+
+%description static -l pl
+Biblioteki statyczne clamav.
+
+%package database
+Summary: Virus database for clamav
+Summary(pl): Bazy wirusów dla clamav
+Group: Applications
+Version: %{version}.%{database_version}
+PreReq: %{name}
+
+%description database
+Virus database for clamav (updated %{database_version}).
+
+%description database -l pl
+Bazy wirusów dla clamav (aktualizowana %{database_version}).
+
%prep
%setup -q
%patch0 -p1
+%patch1 -p1
%build
-rm -f missing
-aclocal
-autoconf
-automake -a -c -f
+%{__aclocal}
+%{__autoconf}
+%{__automake}
%configure \
- --disable-clamav
+ --disable-clamav \
+ --with-dbdir=/var/lib/%{name}
%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily
-install -d $RPM_BUILD_ROOT%{_var}/log/
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/{rc.d/init.d,sysconfig,logrotate.d} \
+ $RPM_BUILD_ROOT{%{_sysconfdir}/cron.d,%{_var}/log}
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
-echo -e '#!/bin/sh\n%{_bindir}/freshclam --quiet -l %{_var}/log/%{name}.log' \
- > $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/%{name}
+cat <<EOF >$RPM_BUILD_ROOT%{_sysconfdir}/cron.d/%{name}
+5 * * * * root %{_sbindir}/clamav-cron-updatedb
+EOF
+
-touch $RPM_BUILD_ROOT%{_var}/log/%{name}.log
+install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/clamd
+install %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/clamd
+install %{SOURCE4} $RPM_BUILD_ROOT%{_sbindir}/clamav-cron-updatedb
+install etc/*.conf $RPM_BUILD_ROOT%{_sysconfdir}/
+install %{SOURCE5} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
+install %{SOURCE6} $RPM_BUILD_ROOT/var/lib/%{name}/
+install %{SOURCE7} $RPM_BUILD_ROOT/var/lib/%{name}/
+install %{SOURCE8} $RPM_BUILD_ROOT%{_sbindir}
-gzip -9nf AUTHORS ChangeLog FAQ NEWS README TODO
+# NOTE: clamd uses sane rights to it's clamd.pid file
+# So better keep it dir
+# If it is fixed use of dir will be unecesary
+install -d $RPM_BUILD_ROOT%{_var}/run/%{name}
+touch $RPM_BUILD_ROOT%{_var}/log/freshclam.log
%clean
rm -rf $RPM_BUILD_ROOT
-%pre
+%triggerin -- amavis-ng
+AMAVIS=$(/usr/bin/getgid amavis)
+RESULT=$?
+if [ $RESULT -eq 0 ]; then
+ /usr/sbin/usermod -G amavis clamav 1>&2 > /dev/null
+ echo "adding clamav to amavis group GID=$AMAVIS"
+fi
+
+%triggerin -- amavisd-new
+AMAVIS=$(/usr/bin/getgid amavis)
+RESULT=$?
+if [ $RESULT -eq 0 ]; then
+ /usr/sbin/usermod -G amavis clamav 1>&2 > /dev/null
+ echo "adding clamav to amavis group GID=$AMAVIS"
+fi
+
+%triggerin -- amavisd
+AMAVIS=$(/usr/bin/getgid amavis)
+RESULT=$?
+if [ $RESULT -eq 0 ]; then
+ /usr/sbin/usermod -G amavis clamav 1>&2 > /dev/null
+ echo "adding clamav to amavis group GID=$AMAVIS"
+fi
+
+
+%pre
if [ -n "`getgid clamav`" ]; then
- if [ "`getgid clamav`" != "43" ]; then
- echo "Warning: group clamav doesn't have gid=43. Correct this before installing clamav" 1>&2
- exit 1
- fi
+ if [ "`getgid clamav`" != "43" ]; then
+ echo "Warning: group clamav doesn't have gid=43. Correct this before installing clamav" 1>&2
+ exit 1
+ fi
else
- /usr/sbin/groupadd -g 43 -r -f clamav
+ echo "Adding group clamav GID=43"
+ /usr/sbin/groupadd -g 43 -r -f clamav
fi
if [ -n "`id -u clamav 2>/dev/null`" ]; then
if [ "`id -u clamav`" != "43" ]; then
exit 1
fi
else
- /usr/sbin/useradd -u 43 -r -d /tmp -s /bin/false -c "Clam Anti Virus Checker" -g clamav clamav 1>&2
+ echo "Adding user clamav UID=43"
+ /usr/sbin/useradd -u 43 -r -d /tmp -s /bin/false -c "Clam Anti Virus Checker" -g clamav clamav 1>&2
+fi
+
+%post
+/sbin/chkconfig --add clamd
+if [ -f /var/lock/subsys/clamd ]; then
+ /etc/rc.d/init.d/clamd restart >&2
+else
+ echo "Run \"/etc/rc.d/init.d/clamd start\" to start Clam Antivirus daemon." >&2
+fi
+touch %{_var}/log/freshclam.log
+chown clamav:root %{_var}/log/freshclam.log
+chmod 640 %{_var}/log/freshclam.log
+
+%preun
+if [ "$1" = "0" ]; then
+ if [ -f /var/lock/subsys/clamd ]; then
+ /etc/rc.d/init.d/clamd stop
+ fi
+ /sbin/chkconfig --del clamd
fi
%postun
if [ "$1" = "0" ]; then
+ echo "Removing user clamav"
/usr/sbin/userdel clamav
+ echo "Removing group clamav"
/usr/sbin/groupdel clamav
fi
-%post
-touch %{_var}/log/%{name}.log && chmod 640 %{_var}/log/%{name}.log && chown clamav %{_var}/log/%{name}.log
+%post libs -p /sbin/ldconfig
+%postun libs -p /sbin/ldconfig
+
+%post database -p %{_sbindir}/%{name}-post-updatedb
%files
%defattr(644,root,root,755)
-%doc *.gz docs/*.pdf
+%doc AUTHORS ChangeLog FAQ NEWS README TODO docs/html/
%attr(755,root,root) %{_bindir}/*
-%attr(755,clamav,root) %dir %{_datadir}/clam
-%attr(644,clamav,root) %verify(not md5 size mtime) %{_datadir}/clam/*.db
-%attr(640,clamav,root) %ghost %{_var}/log/%{name}.log
-%attr(750,root,root) %{_sysconfdir}/cron.daily/%{name}
+%attr(755,root,root) %{_sbindir}/*
+%attr(755,clamav,root) %dir /var/lib/%{name}
+%attr(640,clamav,root) %ghost %{_var}/log/freshclam.log
+%attr(750,clamav,clamav) %dir %{_var}/run/%{name}
+
+%attr(640,root,root) %{_sysconfdir}/cron.d/%{name}
+%attr(644,root,root) %config(noreplace) %verify(not md5 size mtime) /etc/clamav.conf
+%attr(644,root,root) %config(noreplace) %verify(not md5 size mtime) /etc/freshclam.conf
+
+%attr(754,root,root) /etc/rc.d/init.d/clamd
+%attr(640,root,root) %config(noreplace) %verify(not md5 size mtime) /etc/sysconfig/clamd
+%attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/logrotate.d/clamav
%{_mandir}/man?/*
+
+%files libs
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/lib*.so.*.*
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/lib*.so
+%{_libdir}/lib*.la
+%{_includedir}/*.h
+%{_pkgconfigdir}/*.pc
+
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/*.a
+
+%files database
+%defattr(644,root,root,755)
+%attr(644,clamav,root) %verify(not md5 size mtime) /var/lib/%{name}/*.cvd