How To Create RPM Using Source RPM

on May 24 | in Linux, Programming / Scripting | by | with 4 Comments

In this how to i will describe how to create binary rpm (installable) using source rpm i.e *.src.rpm. Source rpm is collection of source files in tar.gz, patches and spec file. Spec file defines how the source code will compile with current machine, defining depencies and generate rpm from source rpm. Usually we do this when we need to have some custom changes to be made in required software.

1) Pre-requisite

First of all you should have install rpm-devel and rpm-build rpms from your distro repository. Confirm it using following command

rpm -qa | grep rpm

rpm-4.3.3-26
rpm-devel-4.3.3-26
rpm-python-4.3.3-26
redhat-rpm-config-8.0.32.1-4
rpmdb-CentOS-4.7-0.20080805
rpm-libs-4.3.3-26
rpm-build-4.3.3-26

If you see required rpms in the list then you are good to go with source rpm compilation, else you have to install required rpms.

yum -y install rpm-build rpm-devel

or

rpm -ivh /path/rpm-build* /path/rpm-devel*

The rpm-build and rpm-devel also build following directories for source rpm compilations.

/usr/src/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

2) Compiling the source

Get your source rpm which you need to compile.  Here i will get the ffmpeg source rpm from http://dag.wieers.com/rpm/packages/ffmpeg/ because i need to add libamr-nb and libamr-wb support for converting 3gp clips.

wget http://dag.wieers.com/rpm/packages/ffmpeg/ffmpeg-0.4.9-0.9.20070530.rf.src.rpm

rpm -ivh ffmpeg-0.4.9-0.9.20070530.rf.src.rpm

It will install source files tar.gz, patch files in

/usr/src/redhat/SOURCES

and spec file in

/usr/src/redhat/SPECS

I have to add –with-libamrnb and –with-libamrwb in ./configure command specified in ffmpeg.spec and you can edit whatever you are going to change/edit.

After editing now compile the sources and generate rpm using spec file.

cd /usr/src/redhat/SPECS

rpmbuild -bb ffmpeg.spec

The above command will apply patches if any and compile the source and generate rpm under /usr/src/redhat/RPMS sub-directories regarding to your architecture i.e

/usr/src/redhat/RPMS/i386 for i386,i686

/usr/src/redhat/RPMS/x86_64 for x86_64 etc.

While compiling you will see the verbose output of compilation and you should see clean compilation with notifying of generating rpm at the end.

Pin It

related posts

4 Responses to How To Create RPM Using Source RPM

  1. Rashid Iqbal says:

    Dear Sir

    DNS installed successfully, now I want to made him PDC,
    secondly I don’t have direct internet connection e.g. through wireless I download the package and then copy it and then try to install that software. b/c wireless card is not installed in centos.

    1. samba is in trar.gz extenstion.
    how to install that
    i give tar -zxvf sambas-3.5.3.tar.gz
    what step next.?

    secondly I install the LDAP and
    in third step I want to install the LDAP tools but all are in norch extension. so HOW TO INSTALL THESE.

    waiting for your earlier response.

    Regards,

    Rashid

  2. Chris says:

    wget does not install srpms…

  3. @Chris: Yes wget wont install srpms, its to download any piece of file :). rpmbuild which build a rpm file from srpm and then you can install with rpm command. Kindly read full blog and you will find a way to compile and install srpms.
    ————–
    Regards,

  4. Chris says:

    @Sohail
    I did read it in full. Please refer to “2) Compiling the source”. You state “wget http://dag.wieers.com/rpm/packages/ffmpeg/ffmpeg-0.4.9-0.9.20070530.rf.src.rpm” and then say “It will install source files tar.gz, patch files in…”

    And I repeat, wget will NOT “install source files tar.gz, patch files” anywhere.rpmbuild in

Leave a Reply

Your email address will not be published. Required fields are marked *

« »