How-To create a RPM

GeSHi installation not found. See configuration of the filter.

Packaging is a cool feature when you want to have a software easily installed on different machines. On top of that, it is easier to manage installed packages, remove them or update them.

This How-To will explain how to create a distributable package using rpmbuild package. This tutorial was done on a Fedora 7 machine but should be working on Red Hat and CentOS.

For the purpose of this tutorial, we are going to package subtitleeditor.

This tutorial will consist in preparing your machine, get the source, create magical .spec file and finally compile the package.

1. Setting up your System

1.1. Setting up the directory structure

First of all, we need to create a directory structure which is going to host the different elements that are required when building an RPM. As a normal user, type:

$ mkdir ~/packages
$ cd ~/packages

The different directories will be used for:

  • BUILD : The place where rpmbuild will build the package
  • RPMS : The binary package created by rpmbuild will be stored here
  • SOURCES : The place where to keep the original software sources
  • SPECS : This is where the .spec will be stored
  • SRPMS : The source rpm from your build will be stored there

1.2. Installing the necessary packages

First of all, in order to be able to build a package, we need to have the rpmbuild executable. In order to get it, we need to install rpm-build. As root type:

# yum install rpm-build