How-To create a RPM -- page 3 -- inside .spec file

2.3. Inside .spec file

Let's get through this file. The best way to create your own will be to use this one as a template and adapt it to your need.

This file basically contains 7 sections: introduction, prep, build, install, clean, files and changelog. I will go through each section individually.

2.3.1. Introduction section

the first section, up to %prep is pretty explicit by itself. It mainly contains information as seen by rpm -qi subtitleeditor. Here is a short description of each parameters:

  • Summary: a short description of the package
  • Name: the name of the package
  • Version: the version of the package we are building. Here subtitleeditor-0.20.0alpha4
  • Release: the package release number. Here 1.rb7
  • License: the license under which the software is released, here GPL
  • Group: the group your package belongs to. See /usr/share/doc/rpm-/GROUPS
  • URL: software homepage
  • Source: the location of the sources
  • BuildRoot: where the package is going to be built
  • Patch: if you need to apply patch, enter the patch file name and copy the file to the SOURCES directory
  • BuildRequires: packages requires in order to build this packages
  • Packager: the name of the packager
  • %description: a longer description of the package

Once the package introduced, we need to define how to build the package.

2.3.2. prep section

The prep section prepares the package for the build process. This is the section taking care of untarring the package as well as patching if required.

%setup -q is a rpm macro which knows how to unarchive the source.
%patch will patch the source tree.

2.3.3. build section

This section will configure and make the package. Here we use the %configure to which we append the --disable-debug as we don't want to compile this feature.
Then we compile the package with the %{__make} macro.

The meaning of the macros can be found in /usr/lib/rpm/macros

2.3.4. install section

This section take care of cleaning up the BuildRoot and installing the application.

2.3.5. clean section

Cleans up files created by other sections.

2.3.6. files section

defines the files that have to go in the binary RPM. Permission are defined and special attributes can be used.

This section starts with %files, additionally, the list of files that have to be included can be in a separate file, here subtitleeditor.lang.

%defattr(-, root, root, 0755) define the file attributes.

Files can be marked as document files by prepending their name with %doc.

You can exclude a file from a package using the %exclude macro.

2.3.7. changelog section

Finally the last section: %changelog.

You should add a new changelog entry anytime you repackage the RPM. Changelogs entry are defined as:

* Date - email name
- Action taken

Well, now that we have defined how to build our package, let's build it!