How to install a source rpm

Download an rpm:- for eg samba. I am using a SUSE 11.x machine, may be i can enable the same using yast. Just consider this as an eg for installing a source rpm. I downloaded samba rpm :- samba-2.0.8-1.7.1.src.rpm

Run the command rpm -ivh samba-2.0.8-1.7.1.src.rpm
you will see the normal rpm installation graphics like :-

1:samba                  ########################################### [100%]

Rememebr this is a source rpm intsllation and so the rpm is not installed yet. we will need to now compile the source just like any other source in a .gz or a .zip format. In a Redahat OS after the above step the source file would have been extracted to /usr/src/redhat/SOURCES but for me it got extracted to /usr/src/packages/SOURCES dir. The following files were present after the extraction:-

linux-lh9j:/usr/src/packages/SOURCES # ll
total 4548
-rw-rw-r– 1 root root   66220 Feb  8  2001 ookpatch
-rw-rw-r– 1 root root     342 Jun 26  2000 samba-2.0.5a-gawk.patch
-rw-rw-r– 1 root root     429 Oct 16  2000 samba-2.0.7-buildroot.patch
-rw-rw-r– 1 root root    2400 Feb  8  2001 samba-2.0.7-fixinit.patch
-rw-rw-r– 1 root root     808 Jun 30  2000 samba-2.0.7-krb5-1.2.patch
-rw-rw-r– 1 root root     356 Aug  1  2000 samba-2.0.7-nocups.patch
-rw-rw-r– 1 root root    3995 Jan 19  2001 samba-2.0.7-pam-foo.patch
-rw-r–r– 1 root root    3353 Mar 30  2001 samba-2.0.7-quota.patch
-rw-rw-r– 1 root root    3876 Mar 27  2001 samba-2.0.7-setcred.patch
-rw-rw-r– 1 root root    3464 Oct 25  2000 samba-2.0.7-smb.conf.rh.patch
-rw-r–r– 1 root root    2599 Aug  8  2000 samba-2.0.7-smbadduser.patch
-rw-rw-r– 1 root root     963 Jan 19  2001 samba-2.0.7-smbpasswd-manpage.patch
-rw-rw-r– 1 root root     586 Jun 29  2000 samba-2.0.7-ssl.patch
-rw-rw-r– 1 root root     380 Jun 26  2000 samba-2.0.7-system-auth.patch
-rw——- 1 root root     449 May  8  2001 samba-2.0.8-tempfile.patch
-rw-rw-r– 1 root root 3489579 Apr 21  2001 samba-2.0.8.tar.gz
-rw-rw-r– 1 root root    1533 Feb  8  2001 samba-autoconf.patch
-rw——- 1 root root    1318 Jun 26  2000 samba-glibc21.patch
-rw-r–r– 1 root root     561 Jun 26  2000 samba-ia64.patch
-rw-rw-r– 1 root root  183850 Feb 15  2001 samba-j-2.patch.bz2
-rw-rw-r– 1 root root  774117 Feb  8  2001 samba-j.patch.bz2
-rw-rw-r– 1 root root     523 Jun 27  2000 samba-logrotate.patch
-rw-rw-r– 1 root root     436 Jun 26  2000 samba-makefilepath.patch
-rw-r–r– 1 root root     420 Jan 19  2001 samba-mkdir.patch
-rw-rw-r– 1 root root    2567 Jun 26  2000 samba-smbprint.patch
-rw-r–r– 1 root root     196 Jul 21  2000 samba.log
-rw-rw-r– 1 root root     357 Oct 16  2000 samba.xinetd
-rw-r–r– 1 root root   16455 Jan 19  2001 smbmount-2.0.7-ascii+fixes.patch
-rw-r–r– 1 root root     350 Jun 27  2000 smbw.patch

Now you can compile the source in two ways one is using the configure script and other is using the rpm command. From the above list you can see the the file samba-2.0.8.tar.gz which will have the configure script. untar the same and inside the dir /usr/src/packages/SOURCES/samba-2.0.8/source you will see the configure script. Executing the configure script will compile from the source. “./configure –help” will give you the whole list of options. For eg if you want to add utmp option along with the default options, give :-

./configure –with-utmp
make
make install

And if you are going to compile using the rpm command, navigate yourselves to /usr/src/packages/SPECS , inside which you will see the file samba.spec. Search for the option %configure inside the file and you will see the following line :-

%configure –libdir=/etc/samba \
–with-lockdir=/var/lock/samba –with-privatedir=/etc/samba \
–with-swatdir=/usr/share/swat –with-smbmount –with-automount \
–with-pam –with-mmap –with-quotas –without-smbwrapper
make CFLAGS=”$RPM_OPT_FLAGS -D_GNU_SOURCE” all

add the option –with-utmp above and then it becomes:-

%configure –libdir=/etc/samba \
–with-lockdir=/var/lock/samba –with-privatedir=/etc/samba \
–with-swatdir=/usr/share/swat –with-smbmount –with-automount \
–with-pam –with-mmap –with-quotas –without-smbwrapper –with-utmp
make CFLAGS=”$RPM_OPT_FLAGS -D_GNU_SOURCE” all

Save the file now and run rpmbuild samba.spec or rpm -bb samba.spec

Share and Enjoy:
  • Digg
  • Mixx
  • del.icio.us
  • StumbleUpon
  • Facebook
  • TwitThis
  • Technorati
  • Google

Tags:

Leave a Reply