[ale] SUCCESSFUL: My first custom recompile of an RPM. Was: Anyone have experience hosting email for multiple domains?

Richard Bronosky Richard at Bronosky.com
Thu Sep 10 00:38:56 EDT 2009


A big THANK YOU to Brandon Checketts! The guide you wrote was really
great. I decided to install CentOS on my slicehost server 1. because
that's what I use at work, and 2. to challenge myself. I didn't
realize how much I was going to have to learn so early into the setup.
However, rebuilding RPMs has been something that intimidated me, and I
always handed off to one of my direct reports.

Brandon, it turns out that the postfix RPM in the CentOS 5 base repo
is not compiled with MySQL support, so that pretty much invalidated
your guide for that version of CentOS. I've included my script for
rebuilding the RPM with MySQL support. It can be found (without mail
line wrapping) at http://dpaste.com/91687/

As always, I welcome anyone's thoughts.

################
#!/bin/bash

# Because the postfix offered by CentOS 5 is not built with MySQL
support, we must compile it ourselves.

# My hope is that this process should work with other packages. So,
I've built in a lot of flexability.

# Define the package you need to custom build:
package=postfix
specfile=rpmbuild/SOURCES/$package.spec
# A base CentOS install doesn't define source repos. This will infer
the url for the source RPM.
url=$(yumdownloader --urls $package |sed
'$!d;s?/os/.*/?/os/SRPMS/?;s/[^.]*\.rpm$/src.rpm/')

cd
# Building in your $HOME instead of as root protects your system.
# You must mimic the structure found in the default "topdir" of /usr/src/redhat
for d in $(ls /usr/src/redhat); do mkdir -p  rpmbuild/$d; done
# The rpmbuild command will take cues from the .rpmmacros file
echo %_topdir  $HOME/rpmbuild >> .rpmmacros
wget -P ~/rpmbuild/SRPMS $url
( cd rpmbuild/SOURCES; rpm2cpio ../SRPMS/${url##*/} | cpio -idmv )

# The following is the only part that is specific to postfix
if [[ $package == 'postfix' ]];
then
    # Enable MySQL support
    sed -i '/define MYSQL 0/s/0/1/' $specfile
    # If you don't want to include the "Postfix MTA logfile summary"
tool, do:    sed -i '/define PFLOGSUMM 1/s/1/0/' $specfile
fi
# If you build it...
rpmbuild -bb --clean --rmspec --rmsource $specfile | tee /tmp/$package-build.log
# ...they will come.
sudo yum localinstall $(awk '/^Wrote: /{print $2;quit}' /tmp/$package-build.log)

# Uncomment the following to do some automatic clean up:
     rm -rf ~/rpmbuild /tmp/$package-build.log
     sed -i '$d' .rpmmacros


More information about the Ale mailing list