Building a source RPM using rpmbuild command

last updated in Categories CentOS, FAQ, Howto, Linux, RedHat/Fedora Linux

Q. I need to build a source RPM, how do I build it?

A. In order to build a source RPM you need to use rpmbuild command. rpmbuild is used to build both binary and source software packages. A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package. Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.

You need to use .spec file to build the RPM file. Next type rpmbuild command as follows:

# rpmbuild -ba pakagename.spec

For more information, please refer Maximum RPM book.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

4 comment

  1. If you have the .src.rpm file, just rpm -ivh .src.rpm. You’ll find the spec file in /usr/src/packages/SPEC directory after instalation.

    Have a question? Post it on our forum!