(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Kerio Reseller
Printer Friendly Version

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?


Hate these ads?

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: /7.1/en/os/SRPMS/samba-2.0.8-1.7.1.src.rpm

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:


[root@linux redhat]# l
total 28
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. ./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, 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 man smb.conf

Publish your articles, comments, book reviews or opinions here!



Comments /Linux/rpm-bg.html


Wed Sep 19 23:12:05 2007: Subject: correction   anonymous
Step Five says use rpm -bb samba.spec to build. This should actually be rpmbuild -bb samba.spec



Wed May 7 17:58:02 2008: Subject:   BruceGarlock
http://bgarlock.com

Yes, that is correct for newer versions of RPM. However, this is an older article (I should have dated it), and applies probably to Redhat 6.2. 'rpmbuild' was not available in RPM way back then, so I should have been more clear about the version of RPM that this applies to. I am not sure exactly when 'rpmbuild' came out (maybe Redhat 8?). Anyway, I really need to start dating my articles, so things are more clear to the reader (and the author 5+ years later :-)

Best Regards,

Bruce

Add your comments

Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


ad

Views for this page
Today This Week This Month This Year  Overall
592471698,576 19,806

/Linux/rpm-bg.html copyright June 2001 Bruce Garlock All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

More:
       - Linux
       - Unix
       - Administration
       - Programming




Unix/Linux Consultants

Your ad here - $24.00 yearly!

SCO, OpenServer, UnixWare, software, servers, security, networks, installation, administration, troubleshooting, maintenance, Watchguard, firewalls, VPNs, e-mail. Visit us at http://opensystemscomputing.com and www.go2unix.com.


larryi@ccamedical.com SCO OS5, Debian Linux, RedHat Linux, MySQL, Apache, AJAX development using dXport/dL4/Unibasic, Windows Connectivity, Sharing Resouces, Automation, Shell Scripting


http://thatitguy.com Business networking servers, Linux and Unix experts. In business since 1997! Windows and Exchange to Samba and Scalix migration experts.




Twitter
  • Jun 26 21:28
    Lost 5 cents at poker tonight. Hard to do with 10 and 20 cent betting..
  • Jun 23 07:01
    Hypermiling:







Coming Attractions

My Favorites

Change Congress

Related Posts