3.2 Installing patches using spec files

Let's have a close look at the sendmail.spec file. Here's what it looks like:

    Summary: A widely used Mail Transport Agent (MTA).
    Name: sendmail
    Version: 8.9.3
    Release: 15
    Copyright: BSD
    Group: System Environment/Daemons
    Provides: smtpdaemon
    Source0: ftp://ftp.cs.berkeley.edu/ucb/sendmail/sendmail.%[version].tar.gz
    Source1: sendmail.init
    Source2: http://www.informatik.uni-kiel.de/%7Eca/email/rules/check.tar
    Source3: aliases
    Source4: sendmail.sysconfig
    Source5: sendmail-8.9.3-etc-mail-Makefile
    Source6: sendmail-redhat.mc
    Patch0: sendmail-8.9.3-redhat.patch
    Patch1: sendmail-8.9.3-cf.patch
    Patch2: sendmail-8.7.1-makemapman.patch
    Patch3: sendmail-8.7.1-smrsh.patch
    Patch4: sendmail-8.9.3-db1.patch
    Patch5: sendmail-8.8.7-rmail.patch
    Patch6: sendmail-8.9.3-smrsh.patch
    Patch7: mrbl.p3 #---- Note that we need to add this line to the patch list.
    Buildroot: /var/tmp/%[name]-root
    Prereq: /sbin/chkconfig
    

All this does so far is define all of our source files and the RPM file itself. Please note that we have added a patch (patch number 7) to this list. What follows is a series of descriptions.

 
    %description 
    The Sendmail program is a very widely used Mail Transport Agent (MTA). MTAs send mail from one machine to another. Sendmail is not a client program, which you use to read your e-mail. Sendmail is a behind-the-scenes program which actually moves your e-mail over networks or the Internet to where you want it to go.
    If you ever need to reconfigure Sendmail, you'll also need to have the sendmail.cf package installed. If you need documentation on Sendmail, you can install the sendmail-doc package.
    %package doc
    Summary: Documentation about the Sendmail Mail Transport Agent program.
    Group: Documentation
    %description doc
    The sendmail-doc package contains documentation about the Sendmail Mail Transport Agent (MTA) program, including release notes, the Sendmail FAQ and a few papers written about Sendmail.  The papers are provided in PostScript(TM) and troff formats.
    Install the sendmail-doc package if you need documentation about Sendmail.
    %package cf
    Summary: The files needed to reconfigure Sendmail.
    Group: System Environment/Daemons
    %description cf
    This package includes the configuration files which you'd need to generate the sendmail.cf file distributed with the sendmail package. You'll need the sendmail-cf package if you ever need to reconfigure and rebuild your sendmail.cf file.  For example, the default sendmail.cf file is not configured for UUCP. If someday you needed to send and receive mail over UUCP, you'd need to install the sendmail-cf package to help you reconfigure Sendmail.
    Install the sendmail-cf package if you need to reconfigure your sendmail.cf file.
    

The descriptions have now ended and this spec file will build multiple RPMs. In fact it builds all three of the RPMs we've discussed thus far, as well as rebuilding the src.rpm file if you choose to. This is where the software build actually begins:

 
    %prep
    %setup -q
    %patch0 -p1
    %patch1 -p1
    %patch2 -p1
    %patch3 -p1
    
    # XXX REVERTING
    #tar xf $RPM_SOURCE_DIR/check.tar -C cf
    #chown root.root cf/hack/* cf/README.check
     
    %patch5 -p1
    %patch6 -p1
    cd cf # <---- added because the patch instructions require that our patch be implemented from the cf directory
    %patch7 -p1 # <---- the standard patch command
    cd .. # <---- this command brings us back home again
    

What the mrbl patch does is add the ability for sendmail to use multiple Real Time Black hole (RBL) lists. For more information about what these do you should check out http://www.mail-abuse.org/. Here is the original file still unpatched:

divert(-1)
#
# Copyright (c) 1998 Sendmail, Inc.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#

divert(0)
VERSIONID(`@(#)rbl.m4   8.8 (Berkeley) 5/19/1998')
divert(-1)

define(`_RBL_', ifelse(_ARG_, `', `rbl.maps.vix.com', `_ARG_'))dnl                                                              

Now here is the patched version of the same file:

    

divert(-1)
#
# Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.
#	All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#

divert(0)
ifdef(`_RBL_R_',`dnl',`dnl
VERSIONID(`$Id: x192.html,v 1.4 2006/03/31 14:05:31 jeversol Exp $')')
divert(-1)
define(`_RBL_SRV_',ifelse(_ARG_,`',`maps.vix.com',_ARG_))dnl
define(`_RBL_MSG_',ifelse(_ARG2_,`',`"Mail from " $`'&{client_addr} " refused by blackhole site '_RBL_SRV_`"',_ARG2_))dnl
define(`_RBL_R_',defn(`_RBL_R_')
`
# DNS based IP address spam list '_RBL_SRV_`
R$`'*			$`': $`'&{client_addr}
R$`'-.$`'-.$`'-.$`'-		$`':  $`'(host $`'4.$`'3.$`'2.$`'1.'_RBL_SRV_`. $`': OK $`')
ROK			$`': OKSOFAR
R$`'+			$`'#error $`'@ 5.7.1 $`': '_RBL_MSG_)
    

The two files are very different. The key is that once we get around to configuring sendmail, if you're interested in blocking spam, this patch can come in very handy. We'll cover configurations which use this addition once we get into the sections of this document concerning UCE.

The rest of the spec file we will leave untouched except for the changelog.

    #changelog
    * Tue Nov 11 1999 Your Name <your@name.com>
    - added the mrbl patch to my sendmail configuration. 
    

Note, you should always be sure to update the changelog if you make changes to an RPM. It helps the next person who comes along if they need to make changes as well.