MIMEDefang spec file (was Re: [Mimedefang] More on mimedefang and x86_64)

Philip Prindeville philipp_subx at redfish-solutions.com
Mon Dec 11 16:54:14 EST 2006


Philip Prindeville wrote:

>Well, I can test changes.
>
>One thing I noticed in the .spec file after I posted my first
>email message is that we should run "autoconf" so that the
>configure file gets rebuilt.  This would happen after %setup
>gets run, but before ./configure.  Especially if some distros
>include %patch changes to configure.in...
>
>So, I'll attach files to show these changes...
>
>I've added a build-time dependency to autoconfig > 2.55, since
>we're running it.
>
>-Philip
>  
>

Went and looked at the Fedora extras version, and noticed their fix
for finding the appropriate lib/lib64 version of libmilter.a was a lot
simpler than mine:

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


I concur that --disable-check-perl-modules is the right thing to do (since
your build host is rarely your run-time host).

I think that calling "autoconf" just before %configure (which isn't
currently done) is correct...  The overhead is acceptable.

Oh, and calling "%configure" is better than calling "./configure".

The change in build-time vs. run-time requirements is:

 Buildroot:     %{_tmppath}/%{name}-root
 Requires:      sendmail > 8.12.0
 Requires:      perl-Digest-SHA1 perl-MIME-tools perl-IO-stringy perl-MailTools
 BuildRequires: sendmail-devel > 8.12.0
-BuildRequires: perl-Digest-SHA1 perl-MIME-tools perl-IO-stringy perl-MailTools
+BuildRequires: autoconf > 2.55

 %description

and:

 %prep
 %setup -q -n %{name}-%{version}
-./configure --prefix=%{_prefix} \
+autoconf
+%configure --prefix=%{_prefix} \
             --mandir=%{_mandir} \
+           --with-milterlib=%{_libdir} \
            --sysconfdir=/etc   \
+           --disable-check-perl-modules \
             --with-spooldir=%{dir_spool} \
             --with-quarantinedir=%{dir_quarantine} \
 %if %{with_antivirus}
            --with-user=%{user}

oh, and:

 %build
-make
+make DONT_STRIP=1

 %install


David:  can we institute these changes?

Attached are:

* the Fedora extras mimedefang.spec
* the stock Mimedefang.spec with the above tweaks (as mimedefang2.spec)

-Philip


-------------- next part --------------
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 at fedoraproject.org> 2.58-1
- Upgrade to 2.58 (#212657)

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

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

* Mon Sep 11 2006 Robert Scheck <robert at 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 at fedoraproject.org> 2.57-2
- Changes to match with Fedora Packaging Guidelines (#196101)

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

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

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

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

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

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

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

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

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

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

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

* Thu Jul 15 2004 Robert Scheck <robert at 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 at fedoraproject.org> 2.43-1
- Upgrade to 2.43

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

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

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

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

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

* Sat Oct 11 2003 Robert Scheck <robert at fedoraproject.org> 2.38-1
- Upgrade to 2.38
- Initial spec file for Red Hat Linux
-------------- next part --------------
##########################################################################
# Copyright @2002, Roaring Penguin Software Inc.  All rights reserved.
#
# Project     : MIMEDefang
# Component   : redhat/mimedefang.spec
# Author      : Michael McLagan <Michael.McLagan at linux.org>
# Creation    : 30-Apr-2002 12:25
# Description : This is the spec file for building the RedHat RPM 
#               distribution SRC and i386 files
#    
# Current Revision:
#
# $Source$
# $Revision: 9982 $
# $Author: dfs $
# $Date: 2004-09-19 15:55:28 -0400 (Sun, 19 Sep 2004) $
#
# Revision History:
# 
# $Log$
# Revision 1.30  2004/09/19 19:55:28  dfs
# Add sa-mimedefang.cf to example.
#
# Revision 1.29  2004/09/01 21:22:52  dfs
# Fixed bug.
#
# Revision 1.28  2004/08/09 22:28:06  dfs
# Fixed spec so as not to disable service on upgrade.
#
# Revision 1.27  2004/07/15 17:13:43  dfs
# Move sa-mimedefang.cf into /etc/mail instead of /etc/mail/spamassassin
#
# Revision 1.26  2004/02/24 14:41:08  dfs
# Loosened spool permissions to make it world-readable.
# Improved spec file to allow detection of AV software at build time.
#
# Revision 1.25  2003/06/04 14:12:24  dfs
# Took out noarch.
#
# Revision 1.24  2003/06/04 14:03:33  dfs
# Copy pid files into /var/run to keep Red Hat killproc() happy.
#
# Revision 1.23  2003/06/04 13:39:33  dfs
# Split out contrib into a separate package.
#
# Revision 1.22  2002/10/25 14:01:51  dfs
# Build RPM with --disable-anti-virus
#
# Revision 1.21  2002/09/25 11:28:13  dfs
# Fixed spec.
#
# Revision 1.20  2002/08/26 03:48:40  dfs
# Install logrotate file
#
# Revision 1.19  2002/08/26 03:15:40  dfs
# Take ip key out!
#
# Revision 1.18  2002/08/26 03:13:52  dfs
# Better RPM file.
#
# Revision 1.17  2002/08/26 03:10:00  dfs
# Better RPM packaging.
#
# Revision 1.16  2002/06/21 14:50:27  dfs
# Fixed spec file.
#
# Revision 1.15  2002/06/11 12:33:14  dfs
# Fixed typo.
#
# Revision 1.14  2002/06/03 14:26:14  dfs
# Fixups for sysconfdir.
#
# Revision 1.13  2002/05/29 18:12:15  dfs
# Put pid files and sockets in /var/spool/MIMEDefang instead of /var/run
#
# Revision 1.12  2002/05/23 19:08:00  dfs
# Fixed spec file to make log directory.
#
# Revision 1.11  2002/05/15 13:39:02  dfs
# Added README.NONROOT
#
# Revision 1.10  2002/05/14 16:19:14  dfs
# Patch from Michael McLagan
#
# Revision 1.9  2002/05/13 20:32:03  dfs
# More spec fixes.
#
# Revision 1.8  2002/05/13 20:20:07  dfs
# Fixed spec file.
#
# Revision 1.7  2002/05/10 13:46:43  dfs
# Backward compatibility with Michael McLagan's RPM setup.
#
# Revision 1.6  2002/05/10 11:30:24  dfs
# Updated spec.
#
# Revision 1.5  2002/05/09 20:30:42  dfs
# Changed spool dir paths back.
#
# Revision 1.4  2002/05/09 20:26:47  dfs
# Fixed typo
#
# Revision 1.3  2002/05/09 20:24:31  dfs
# Fixed bug in spec.
#
# Revision 1.2  2002/05/09 20:22:09  dfs
# Revert spec to our style.
#
# Revision 1.1  2002/05/09 20:18:05  dfs
# Merge Michael McLagan's patch.
#
# Revision 1.7  2002/05/08 16:56:58  dfs
# Added /etc/mail/spamassassin to spec.
#
# Revision 1.6  2002/05/06 15:23:31  dfs
# Update for 2.10.
#
# Revision 1.5  2002/05/03 14:24:24  dfs
# Merge packaging patches.
# Fixed typo.
# Made default value for -n 10.
#
##########################################################################

%define dir_spool      /var/spool/MIMEDefang
%define dir_quarantine /var/spool/MD-Quarantine
%define dir_log        /var/log/mimedefang
%define user           defang
%define with_antivirus 0

%{?_with_antivirus: %{expand: %%define with_antivirus 1}}
%{?_without_antivirus: %{expand: %%define with_antivirus 0}}

Summary:       Email filtering application using sendmail's milter interface
Name:          mimedefang
Version:       2.58
Release:       2
License:       GPL
Group:         Networking/Mail
Source0:       http://www.roaringpenguin.com/%{name}/%{name}-%{version}.tar.gz
Url:           http://www.roaringpenguin.com/%{name}
Vendor:        Roaring Penguin Software Inc.
Buildroot:     %{_tmppath}/%{name}-root
Requires:      sendmail > 8.12.0
Requires:      perl-Digest-SHA1 perl-MIME-tools perl-IO-stringy perl-MailTools
BuildRequires: sendmail-devel > 8.12.0
BuildRequires: autoconf > 2.55

%description
MIMEDefang is an e-mail filter program which works with Sendmail 8.11
and later.  MIMEDefang 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.

Deleting attachments could cause a loss of information.  Recipients must
be aware of this possibility, and must be willing to explain to senders
exactly why they cannot mail certain types of files.  You must have the
willingness of your e-mail users to commit to security, or they will
complain loudly about MIMEDefang.

%prep
%setup -q -n %{name}-%{version}
autoconf
%configure --prefix=%{_prefix} \
            --mandir=%{_mandir} \
	    --enable-debug \
	    --with-milterlib=%{_libdir} \
	    --sysconfdir=/etc   \
	    --disable-check-perl-modules \
            --with-spooldir=%{dir_spool} \
            --with-quarantinedir=%{dir_quarantine} \
%if %{with_antivirus}
	    --with-user=%{user}
%else
	    --with-user=%{user} \
	    --disable-anti-virus
%endif

%build
make DONT_STRIP=1

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{dir_log}
make install-redhat RPM_INSTALL_ROOT=$RPM_BUILD_ROOT
# Turn off execute bit on scripts in contrib
find contrib -type f -print0 | xargs -0 chmod a-x

%clean
HERE=`pwd`
cd ..
rm -rf $HERE
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc COPYING Changelog README* examples SpamAssassin
%dir %{dir_spool}
%dir %{dir_log}
%dir %{dir_quarantine}
%{_bindir}/*
%{_mandir}/*
%config(noreplace) /etc/mail/mimedefang-filter
%config(noreplace) /etc/mail/sa-mimedefang.cf
%config(noreplace) /etc/mail/sa-mimedefang.cf.example
%config(noreplace) /etc/sysconfig/%{name}
/etc/rc.d/init.d/%{name}
/etc/logrotate.d/%{name}

%pre
# Backward-compatibility
if test -d /var/spool/mimedefang -a ! -d /var/spool/MIMEDefang ; then
	mv /var/spool/mimedefang /var/spool/MIMEDefang || true
fi

if test -d /var/spool/quarantine -a ! -d /var/spool/MD-Quarantine ; then
	mv /var/spool/quarantine /var/spool/MD-Quarantine || true
fi

# Add user
useradd -M -r -d %{dir_spool} -s /bin/false -c "MIMEDefang User" %{user} > /dev/null 2>&1 || true

%post
# Tighten permissions
chown %{user} %{dir_spool}
chgrp %{user} %{dir_spool}
chmod 750 %{dir_spool}
chown %{user} %{dir_quarantine}
chgrp %{user} %{dir_quarantine}
chmod 750 %{dir_quarantine}
chown %{user} %{dir_log}
chgrp %{user} %{dir_log}
chmod 755 %{dir_log}

cat << EOF

In order to complete the installation of mimedefang, you will need to add the 
following line to your sendmail mc file:

   INPUT_MAIL_FILTER(\`mimedefang', \`S=unix:/var/spool/MIMEDefang/mimedefang.sock, F=T, T=S:1m;R:1m;E:5m')

Use the sendmail-cf package to rebuild your /etc/mail/sendmail.cf file and 
restart your sendmail daemon.

EOF
/sbin/chkconfig --add mimedefang

%preun
if [ $1 = 0 ] ; then
	/sbin/service mimedefang stop > /dev/null 2>&1 || true
	/sbin/chkconfig --del mimedefang || true
fi

%package contrib
Summary:	Contributed software that works with MIMEDefang
Version:	2.58
Release:	1
Group:          Networking/Mail

%description contrib
This package contains contributed software that works with MIMEDefang,
such as the graphdefang graphing package and a sample filter.

%files contrib
%defattr(-,root,root)
%doc contrib

%changelog
* Wed May 29 2002 David F. Skoll <dfs at roaringpenguin.com>
- Put pid files and sockets in /var/spool/MIMEDefang so we can
  drop privileges early.
* Wed May 15 2002 David F. Skoll <dfs at roaringpenguin.com>
- Change log directory to /var/log/mimedefang/ to more easily accomodate
  -U flag.
* Tue May 14 2002 Michael McLagan <Michael.McLagan at linux.org>
- Fixed preinstall script
* Thu May 09 2002 David F. Skoll <dfs at roaringpenguin.com>
- Install SpamAssassin config file
- Changed spool dir to /var/spool/MIMEDefang and quarantine dir
  to /var/spool/MD-Quarantine
* Thu May 09 2002 Michael McLagan <Michael.McLagan at linux.org>
- Modified to build beta releases
* Fri May 03 2002 Michael McLagan <Michael.McLagan at linux.org>
- Updated to 2.9
* Tue Apr 30 2002 Michael McLagan <Michael.McLagan at linux.org>
  Initial version 2.8


More information about the MIMEDefang mailing list