Today I compiled my first RPM package from source :-)! But let’s start at the beginning…
At work I recently implemented disk quota on our server. While trying to setup /etc/warnquota.conf
I noticed the example lines at the bottom that showed how to configure warnquota to look up e-mail addresses in an LDAP directory. This was exactly what I needed, because we store our user’s e-mail address in our LDAP tree. Without this feature warnquota would try to send its warning mails to user@our-server.example.com
instead of /etc/warnquota.conf
were:
LDAP_MAIL = true LDAP_HOST = ldap.example.com LDAP_PORT = 389 LDAP_BASEDN = ou=Users,dc=example,dc=com LDAP_SEARCH_ATTRIBUTE = uid LDAP_MAIL_ATTRIBUTE = mail LDAP_DEFAULT_MAIL_DOMAIN = example.com |
So, after saving the file I tested it by running warnquota -s
(as root, and I also made sure I reduced my own quota so I would be the one getting an e-mail warning).
Unfortunately warnquota spitted out some errors:
warnquota: Error in config file (line 65), ignoring warnquota: Error in config file (line 66), ignoring warnquota: Error in config file (line 67), ignoring warnquota: Error in config file (line 68), ignoring warnquota: Error in config file (line 69), ignoring warnquota: Error in config file (line 70), ignoring warnquota: Warning: Mailer exitted abnormally. |
These were the line numbers with the LDAP options above :-(. Google pointed me to an old bug in Fedora that was marked as resolved. I also found out that the quota tools should be compiled with LDAP support for this to work. To be sure that it was actually possible I configured warnquota on my home server that runs Ubuntu 10.04 and also uses LDAP. There, it all worked as expected.
So, my next step was clear: make my own RPM package for quota
. The one installed by CentOS 5.4 is quota-3.13-1.2.5.el5
. These are the steps I took:
- Enable the CentOS source repository by creating the file
etc/yum.repos.d/CentOS-Source.repo
with this contents:[centos-src] name=CentOS $releasever - $basearch - Source baseurl=http://mirror.centos.org/centos/$releasever/os/SRPMS/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
The run
yum update
and check that the new repository is listed. - Install the
yum-utils
andrpmdevtools
packages:sudo yum install yum-utils rpmdevtools
. - Set up a directory to do your build work in. I created the directory
~/tmp/pkgtest
. - Run
rpmdev-setuptree
to create the required sub directories. - Set the basic build configuration by creating the file
~/.rpmmacros
with the following contents:# Path to top of build area %_topdir /home/lennart/tmp/pkgtest
- Go into the SRPMS directory and download the source package:
yumdownloader --source quota
- In the top level directory run
rpm -i SRPMS/quota-3.13-1.2.5.el5.src.rpm
to unpack the package. - The
SPECS
directory now contains the.spec file
that contains the build instructions. TheSOURCES
directory contains the source files and patches from Red Hat. In a temporary directory I untar-ed the quotatools source tar.gz file and ran./configure --help
to find out which option I should add to the spec file in order to enable LDAP lookup. The option was:--enable-ldapmail=yes
. The set of configure lines in the spec file now looked like this:%build %configure \ --with-ext2direct=no --enable-rootsbin --enable-ldapmail=yes make
In the spec file I also added a changelog entry:
* Mon Oct 18 2010 Lennart Karssen <lennart@karssen.org 1:3.13-1.2.6 - Added --enable-ldapmail=try to the ./configure line to enable LDAP for looking up mail addresses. (Resolves Red Hat Bugzilla 133207, it is marked as resolved there, but apparently was reintroduced.)
And I also bumped the build version number at the top of the file (the
Release:
line). Finally, I addedopenldap-devel
to theBuildPreReq
line (of course I ran into a compilation error first and then installed theopenldap-devel
package :-)). - Now it’s time to build the package. In the
SPEC
directory run:rpmbuild -bb quota.spec
and wait. The RPM package is created in theRPMS
directory. - Install the package:
sudo rpm -Uvh RPMS/x86_64/quota-3.13-1.2.6.x86_64.rpm
(if you didn’t bump the package version number the--replacepkgs
must be added to ‘upgrade’ to the same version).
And that was it! The package installed cleanly and a test run of warnquota -s
was successful.