Summary:           E-Mail filtering framework using Sendmail's Milter interface
Name:              mimedefang
Version:           2.58
Release:           1%{?dist}
License:           GPL
Group:             System Environment/Daemons
URL:               http://www.mimedefang.org/
Source0:           http://www.mimedefang.org/static/%{name}-%{version}.tar.gz
Source1:           README.FEDORA
Requires:          sendmail-cf >= 8.12.0, perl-MailTools >= 1.15, perl(Mail::SpamAssassin) >= 1.6
Requires:          perl(IO::Stringy) >= 1.212, perl(MIME::Base64) >= 3.03
Requires(pre):     /usr/sbin/useradd
Requires(post):    /sbin/chkconfig
Requires(preun):   /sbin/service, /sbin/chkconfig
Requires(postun):  /sbin/service
BuildRequires:     sendmail-devel >= 8.12.0
BuildRoot:         %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

%description
MIMEDefang is an e-mail filter program which works with Sendmail 8.12
and later. It filters all e-mail messages sent via SMTP. MIMEDefang
splits multi-part MIME messages into their components and potentially
deletes or modifies the various parts. It then reassembles the parts
back into an e-mail message and sends it on its way.

There are some caveats you should be aware of before using MIMEDefang.
MIMEDefang potentially alters e-mail messages. This breaks a "gentleman's
agreement" that mail transfer agents do not modify message bodies. This
could cause problems, for example, with encrypted or signed messages.

%prep
%setup -q
cp -f %{SOURCE1} .

%build
%configure --with-milterlib=%{_libdir} --with-user=defang --disable-check-perl-modules --disable-anti-virus
make %{?_smp_mflags} DONT_STRIP=1

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install-redhat

# Fix config file, initscript, create log directory and remove duplicate
sed -i '1d' $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
sed -i 's/2345/-/' $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name}
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/%{name}
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/mail/sa-mimedefang.cf.example

%pre
if [ -x %{_sbindir}/fedora-useradd ]; then
  %{_sbindir}/fedora-useradd 8 -r -s /sbin/nologin -d %{_localstatedir}/spool/MIMEDefang -M -c "MIMEDefang User" defang > /dev/null 2>&1 || :
else
  %{_sbindir}/useradd -r -s /sbin/nologin -d %{_localstatedir}/spool/MIMEDefang -M -c "MIMEDefang User" defang > /dev/null 2>&1 || :
fi

%post
/sbin/chkconfig --add %{name}

%preun
if [ $1 -eq 0 ]; then
  /sbin/service %{name} stop > /dev/null 2>&1 || :
  /sbin/chkconfig --del %{name}
fi

%postun
if [ $1 -ne 0 ]; then
  /sbin/service %{name} condrestart > /dev/null 2>&1 || :
fi

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc README README.{ANOMY,NONROOT,SECURITY,SOPHIE,SPAMASSASSIN,VEXIRA,FEDORA}
%doc COPYING Changelog contrib/{word-to-html,linuxorg,fang.pl} examples/*filter*
%dir %attr(0750,defang,defang) %{_localstatedir}/log/%{name}
%dir %attr(0750,defang,defang) %{_localstatedir}/spool/MIMEDefang
%dir %attr(0750,defang,defang) %{_localstatedir}/spool/MD-Quarantine
%{_bindir}/*
%{_mandir}/man?/*
%{_sysconfdir}/rc.d/init.d/%{name}
%config(noreplace) %{_sysconfdir}/mail/mimedefang-filter
%config(noreplace) %{_sysconfdir}/mail/sa-mimedefang.cf
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}

%changelog
* Wed Nov 08 2006 Robert Scheck <robert@fedoraproject.org> 2.58-1
- Upgrade to 2.58 (#212657)

* Tue Oct 03 2006 Robert Scheck <robert@fedoraproject.org> 2.57-5
- Rebuilt

* Sat Sep 16 2006 Robert Scheck <robert@fedoraproject.org> 2.57-4
- Removed two hardcoded versioned requirements (#196101 #c13)

* Mon Sep 11 2006 Robert Scheck <robert@fedoraproject.org> 2.57-3
- Disable stripping to have a non-empty -debuginfo package
- Added %%configure parameter for finding libmilter.a on x86_64

* Wed Jun 21 2006 Robert Scheck <robert@fedoraproject.org> 2.57-2
- Changes to match with Fedora Packaging Guidelines (#196101)

* Tue Jun 20 2006 Robert Scheck <robert@fedoraproject.org> 2.57-1
- Upgrade to 2.57

* Tue Mar 07 2006 Robert Scheck <robert@fedoraproject.org> 2.56-1
- Upgrade to 2.56

* Mon Feb 06 2006 Robert Scheck <robert@fedoraproject.org> 2.55-1
- Upgrade to 2.55

* Sat Dec 24 2005 Robert Scheck <robert@fedoraproject.org> 2.54-1
- Upgrade to 2.54

* Mon Sep 19 2005 Robert Scheck <robert@fedoraproject.org> 2.53-1
- Upgrade to 2.53

* Thu Jun 02 2005 Robert Scheck <robert@fedoraproject.org> 2.52-1
- Upgrade to 2.52

* Sun Mar 13 2005 Robert Scheck <robert@fedoraproject.org> 2.51-2
- Rebuilt against gcc 4.0

* Tue Feb 08 2005 Robert Scheck <robert@fedoraproject.org> 2.51-1
- Upgrade to 2.51

* Mon Dec 13 2004 Robert Scheck <robert@fedoraproject.org> 2.49-1
- Upgrade to 2.49

* Sun Nov 07 2004 Robert Scheck <robert@fedoraproject.org> 2.47-1
- Upgrade to 2.47 and some spec file cleanups

* Mon Oct 04 2004 Robert Scheck <robert@fedoraproject.org> 2.45-1
- Upgrade to 2.45 and lots of spec file cleanups

* Thu Jul 15 2004 Robert Scheck <robert@fedoraproject.org> 2.44-1
- Upgrade to 2.44
- Move sa-mimedefang.cf from /etc/mail/spamassassin to /etc/mail

* Mon May 10 2004 Robert Scheck <robert@fedoraproject.org> 2.43-1
- Upgrade to 2.43

* Wed Mar 31 2004 Robert Scheck <robert@fedoraproject.org> 2.42-1
- Upgrade to 2.42

* Thu Mar 18 2004 Robert Scheck <robert@fedoraproject.org> 2.41-1
- Upgrade to 2.41
- Few fixes and cleanup in the spec file

* Mon Mar 08 2004 Robert Scheck <robert@fedoraproject.org> 2.40-1
- Upgrade to 2.40

* Wed Jan 07 2004 Robert Scheck <robert@fedoraproject.org> 2.39-2
- Fixed spec file problems with chkconfig

* Sat Nov 29 2003 Robert Scheck <robert@fedoraproject.org> 2.39-1
- Upgrade to 2.39

* Sat Oct 11 2003 Robert Scheck <robert@fedoraproject.org> 2.38-1
- Upgrade to 2.38
- Initial spec file for Red Hat Linux
