Building and Updating SpamAssassin RPMs

This page by John Simpson inspired this page. Similar to the questions regarding ClamAV, questions arise on the qmailrocks mailing list regarding updating SpamAssassin. The current release of QMR (2.2.0) provides a severely outdated version and the Apache SpamAssassin Project had two security releases this year (2006).

I developed the directions on this page using CentOS. However they should work with any RPM based Linux distro.

Note: The following instructions should be completed by a non-root user, except for a few specific commands as noted in the text.

  1. If you have not already done so, configure your home directory so that you can build RPM files without needing root privileges. This involves two steps:

    1. Create an RPM build directory structure in your home directory. I call mine "rpm", you may want to call yours "rpmbuild" or whatever... but choose a name which doesn't already exist. The example assumes you are using "rpm" as the name:

      % cd
      % mkdir -m 755 rpm
      % cd rpm
      % mkdir -m 755 BUILD RPMS SOURCES SPECS SRPMS

    2. Create a .rpmmacros file in your home directory which contains a pointer to the directory structure you just created. I use a second line which marks any RPM packages I build with my own name and email address- while not strictly required, it is a good idea. My file looks like this:

      %_topdir /home/marlowe/rpm
      %packager Patrick R McDonald <marlowe@antagonism.org>

      Obviously you need to substitute the full path to the "rpm" directory within your home directory, as well as your own name and email address.

  2. Download the latest source package from the mirror located nearest you to your rpm/SOURCES directory. Build the RPM with the source tarball.

    % cd ~/rpm/SOURCES
    % wget http://apache.mirrors.versehost.com/spamassassin/source/Mail-SpamAssassin-3.1.7.tar.bz2
    % rpmbuild -tb --define 'srcext .bz2' Mail-SpamAssassin-3.1.7.tar.bz2

    (The below section is taken almost verbatim from the following page by John Simpson.

    This should go through the process of configuring and compiling the spamassassin software according to the spamassassin.spec file contained in the tarball. It will then "install" the software to a temporary working directory, and then scan that directory to build a list of the files which were installed. It then compares that list to a checklist in the spec file to make sure you aren't missing anything, and you aren't forgetting to include any files which are installed from the source, and then builds the binary RPM files.

    If it complains about missing dependencies, read the error message carefully. In many cases the message will tell you the name of the package or library it needs, and a simple "yum install" command as root will be all you need in order to install what it needs (and then try the "rpmbuild" command again.)

  3. Upgrade the spamassassin software.

    If your current spamassassin was installed using an earlier RPM package...

    % su -
    Password:
    # cd ~userid/rpm/RPMS/i386
    # rpm -Fvh spamassassin-* perl-Mail-SpamAssassin-*
    # exit
    If your current spamassassin was installed using some other method...
    • Shut down any SMTP or other services which use spamassassin.

    • Shut down any "spamd" process which may already be running. This may involve a command like "service spamassassin stop", or "/etc/init.d/spamassassin stop", or "killall spamd".

    • Uninstall the existing spamassassin software. If it was installed from an RPM package you should be able to do "rpm -e spamassassin perl-Mail-SpamAssassin". If it was installed from source, you should be able to go to the original source directory and run "make uninstall".

    • Install the new spamassassin software.

      % su -
      Password:
      # cd ~userid/rpm/RPMS/i386
      # rpm -ivh spamassassin-* perl-Mail-SpamAssassin-*
      # exit
  4. Make sure the spamd service is running, and that it will start automatically when the system boots up. If you are running spamd from daemontools simply start the service back up with the svc command. The below example covers the init script method.

    % su -
    Password:
    # /etc/init.d/spamassassin start
    # chkconfig --level 345 spamassassin on
    # exit
  5. Start your SMTP and other services back up.


2006-12-11 Thanks to John Simpson for pointing out several typos on the page.