BuildRequires: autoconf
BuildRequires: automake
BuildRequires: zlib-devel
-Requires(pre): user-clamav
Requires(post,preun): /sbin/chkconfig
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%clean
rm -rf $RPM_BUILD_ROOT
+%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
+else
+ 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
+ echo "Warning: user clamav doesn't have uid=43. Correct this before installing clamav" 1>&2
+ exit 1
+ fi
+else
+ 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
touch %{_var}/log/%{name}.log && chmod 640 %{_var}/log/%{name}.log && chown clamav %{_var}/log/%{name}.log
/sbin/chkconfig --add clamd
/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 libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig