RedHat RPM Source Packages by Bruce Garlock
Ever wanted to rebuild a RedHat RPM from source? I had an issue
where I wanted to include one of the new features offered by SAMBA
that enables logging to utmp in RedHat 7.1 and RedHat 6.2. Since
RedHat's supplied binary RPM's did not include this support, I had
two choices: one was to download the SAMBA source, and compile the
feature in from there, and my other choice was to possibly use the
RPM source that RedHat supplies with their RPM's. I like the idea
of a package management system, since when you install from source,
you don't get nice features like easily removing the package,
upgrading it, or listing where all the files are currently
installed to. Sure, you can do that manually, but you have to be
careful of where the program gets installed, or keep records of
where you are installing things. By default, most source code gets
installed somewhere in the /usr/local tree, versus the /usr tree (a
simple configure option or Makefile change can take care of that).
Usually most RPM binaries from RedHat get installed to /usr, and
the configuration files get placed in /etc, which makes things like
system upgrades easier, since everything is usually in one place.
So how do you get a source RPM to compile with the options you
want, plus get all the features of the RPM system?
Before we begin, I *strongly* recommend you backup your SAMBA
configuration files, especially /etc/samba/smb.conf file, before
proceeding. I did not have any trouble, but your mileage may vary.
It's always nice to have the original SAMBA binary RPM's around, in
case you need to reinstall SAMBA.
Step One is of course, to grab the source RPM from
Redhat. I use their ftp site to do this: ftp://updates.redhat.com
The RPM in question here is:
Step Two we install the rpm - don't worry, it does not
install over your current SAMBA install, but the source RPM is
installed to /usr/src/redhat
rpm -ivh samba-2.0.8-1.7.1.src.rpm
A directory of the /usr/src/redhat tree looks like this:
[[email protected] redhat]# l
drwxr-xr-x 7 root root 4096 May 19 04:23 .
drwxr-xr-x 6 root root 4096 Jun 4 20:20 ..
drwxr-xr-x 5 root root 4096 Jun 6 21:08 BUILD
drwxr-xr-x 8 root root 4096 May 19 04:23 RPMS
drwxr-xr-x 2 root root 4096 Jun 4 19:46 SOURCES
drwxr-xr-x 2 root root 4096 Jun 6 21:07 SPECS
drwxr-xr-x 2 root root 4096 Apr 8 18:43 SRPMS
Step Three now we have the source to SAMBA "installed"
and we are ready to go to work. In this case, I went in to
/usr/src/redhat/BUILD/samba-2.0.8 and saw where all the sources are
installed. RedHat also installed various patches to the "RedHat
Version" of SAMBA in /usr/src/redhat/SOURCES. We don't need to
worry about these for changing a compile option, though. Next, I
went into /usr/src/redhat/BUILD/samba-2.0.8/source and saw that
there was a configure script. Here is where I got some needed
information for compiling in the option I wanted. I simply ran the
configure script, with the help option, and saw what option I
needed. ./configure --help . Since I wanted utmp support, I
saw that I needed to add --with-utmp to my configure
options. Don't run that now, we need to make sure to note this, so
it can be included in our RPM build.
I made a small error, since if the RPM is not initially
rebuilt, the /usr/src/redhat/BUILD/samba-2.0.8 directory will not
exist yet. You need to copy the source file from
/usr/src/redhat/SOURCES, and extract it to a temporary directory,
and find out what configure options are available.
Corrected Step Three now we have the source to SAMBA
"installed" and we are ready to go to work. In this case, I went in
to /usr/src/redhat/SOURCES/samba-2.0.8 and saw where all the
sources are installed. RedHat also installed various patches to the
"RedHat Version" of SAMBA in this directory. Now lets figure out
what compile time options are available to us, by copying the
source (samba-2.0.8.tar.bz2) file to a temporary directory,
extracting it, and running the configure script with the --help
option. Here is where I got some needed information for compiling
in the option I wanted. I simply ran the configure script, with the
help option, and saw what option I needed.
--help . Since I wanted utmp support, I saw that I needed to
--with-utmp to my configure options. Don't run
that now, but we need to make sure to note this, so it can be
included in our RPM build.
UPDATE (08-09-2001): Note that Redhat has recently come out with
a beta version of Redhat 7.2, and now includes SAMBA 2.2.1a. I am
now running this SAMBA version on my machine, and it adds a real
nice feature that allows more options with PAM. PAM is an extensive
option of authenticating users, and one notable option is
enabling/disabling of user logins, and times people can login via
the pam_time.so module. Previous versions of SAMBA were
incompatible with pam_time.so, because SAMBA would not allocate a
tty. The 2.2.x versions of SAMBA allocate a tty, so many of PAM's
now work with SAMBA.
You should also make sure you are using at least version 2.0.10
of SAMBA, which corrects a security issue.
Step Four Now that we have our needed compile option, we
have to tell the RPM spec, to include this when we build our
"custom" RPM binary. To do that, change into the
/usr/src/redhat/SPECS directory, and do a listing. You should see a
file called: samba.spec This is the file we need to modify with our
compile option. The beginning of this file includes the various
patches that are located in /usr/src/redhat/SOURCES. If you go a
down a little bit further in the file, you will see the area where
all the compile options are assigned. The area begins with:
%configure. Now we just need to add our option to all the
other options RedHat uses with their SAMBA, and save the new spec
file. I simply added --with-utmp after the last option,
which in this case was --without-smbwrapper.
Step Five Now we are ready to build our custom binary of
SAMBA, with our new option compiled in. Simply run rpm -bb
samba.spec and grab a cup of coffee. Depending on the speed of
your system, this could take a few minutes. You should now see
SAMBA being rebuilt from source, with our new option.
Step Six Once SAMBA is done being rebuilt, the resulting
binary(s) are placed in /usr/src/redhat/RPMS/i386. You should now
see the following binaries:
-rw-rw-r-- 1 root root 2596787 Jun 6 21:15 samba-2.0.8-1.7.1.i386.rpm
-rw-rw-r-- 1 root root 776776 Jun 6 21:15 samba-client-2.0.8-1.7.1.i386.rpm
-rw-rw-r-- 1 root root 968786 Jun 6 21:15 samba-common-2.0.8-1.7.1.i386
We are now ready to upgrade our SAMBA with the new option ready
to go! I usually issue a: rpm -Uvh samba*.rpm --force
We now have a "new" version of SAMBA with the option of logging
SAMBA users to utmp. This is a nice feature so we can audit when
users logged into a particular share. You must also enable this
feature in your /etc/samba/smb.conf file before the logging takes
place. For more information on this new feature, read the man page
Publish your articles, comments, book
reviews or opinions here!
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
More Articles by Bruce Garlock
© 2009-11-11 Bruce Garlock