(OLDER) <- More Stuff -> (NEWER) (NEWEST)
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?

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!




More Articles by Bruce Garlock




Click here to add your comments





Fri Sep 18 19:23:03 2009: Subject:   Janis

gravatar
Thank you for this post! I didn't need to rebuild a "custom" Samba package, but the idea was the same.





Wed Nov 11 15:47:51 2009: Subject:   BruceGarlock
http://bgarlock.com
gravatar
Your welcome! I need to make it more generic - but yes, this should apply to just about any source RPM building.



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



/BGarlock/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

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!



 I sell and support
 Kerio Mail server






More:
       - Linux
       - Unix
       - Administration
       - Programming
       - BGarlock


Unix/Linux Consultants

Skills Tests

Guest Post Here