How To Build RPM Packages on Fedora

These are some general guidelines and notes in order to assist the adventurous first-time Fedora user to get started with RPM package building.

What Is An RPM Package?

In simple terms, an RPM package is an advanced form of a container for other files. Generally, it includes:

  1. The program to be installed plus all the necessary files that accompany this program.
  2. Information about the program and the RPM package itself.
  3. Information about the program’s dependencies, which means info about what other software needs to be installed, so your program to function correctly in the system.
  4. Information about potential conflicts between the program and other software that is currently installed in the system.
  5. Actions that need to be performed when the program is installed/upgraded/removed.

But, this is enough with the theory. For more information, refer to the links at the Further Reading section of this article.


The following are needed in order to build RPM Packages.

  • The development tools. All the utilities that are needed to compile a program, including the compiler itself.
  • A SPEC file for the particular program you want to create an RPM package for. A SPEC file contains all the information regarding the program’s details, its dependencies, the compilation options etc. For more info on writing SPEC files, refer to the links at the Further Reading section of this article.

Things You Need To Do Once

There are a couple of thing you need to do before starting building your RPMs. These mainly include the installation of the core development tools and the creation of the building environment for your user.

Install the core development tools using YUM. As root:

# yum groupinstall "Development Tools"

Next, create the building environment for your user. Fortunately, Fedora includes some neat utilities that greatly simplify this procedure. First, use YUM to install them (as root):

# yum install rpmdevtools

Then, create the directory structure in your home directory by issuing the command (as a user):

$ rpmdev-setuptree

That’s it.

Build That RPM!

Provided that you have a SPEC file for your program, you can build the binary RPM package by issuing the command:

$ rpmbuild -bb --clean myprogram.spec

If you need to build the package for a different architecture, you can set the --target option, like in the example below:

$ rpmbuild -bb --clean --target i686 myprogram.spec

Please note that you should never build RPM packages using root.


Some programs may need additional development libraries in order to be compiled. You can use YUM to install these needed libraries (-devel packages) or programs. If the operation finishes succesfully, you’ll find your RPM package in the ~/rpmbuild/RPMS/ directory.

Further Reading

This small article’s goal was to get you started with art of RPM packaging by setting up the environment for RPM building. It’s a "Batteries Not Included!" article though. Information about how to write SPEC files is not available here. It would be pointless, as there are some excellent resources for this purpose. So, prepare for some real reading ladies and gentlemen:

  1. Chapter 4. Building RPM Packages of the Fedora Core Developer’s Guide by Tammy Fox, Havoc Pennington – General information about the SPEC file sections.
  2. Chapter 8. Creating RPMs: An Overview of the RPM Guide by Eric Foster-Johnson – In depth information about SPEC files.
  3. Packaging Guidelines by Tom ‘spot’ Callaway – Information specific to writing SPEC files for Fedora Core.
  4. Package Naming Guidelines by Tom ‘spot’ Callaway – Information specific to Fedora RPM naming scheme.
  5. RPM scriptlet recipes – Some extremely useful notes regarding the actions that need to be performed when a package is installed/upgraded/removed from the system, which should be included in the relevant sections of the SPEC file.
  6. Maximum RPM РTaking the RPM Package Manager to the Limit РAn excellent book about the RPM Package Manager, by Edward C. Bailey, Paul Nasrat, Matthias Saou, Ville Skyttä.


Wed 23 Jan, 2008
This article has been updated to reflect the changes in the package names for rpmdevtools. The old package, named fedora-rpmdevtools, is now known as rpmdevtools. Also, the utility that sets up the initial rpmbuild directory tree is now called rpmdev-setuptree (old name was: fedora-buildrpmtree).

How To Build RPM Packages on Fedora by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2006 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

One response on “How To Build RPM Packages on Fedora

  1. Gaurav Garg Permalink →

    Awesome Tutorial and you cover maximum steps for creating a rpm file.

    Thanks a Lot
    Gaurav Garg