Product SiteDocumentation Site

8.2.3. Creating the spec file

The spec file, short for specification file, defines all the actions the rpmbuild command should take to build your application, as well as all the actions necessary for the rpm command to install and remove the application. Each source RPM should have the necessary spec file for building a binary RPM.
The spec file is a text file. The normal naming convention is to name the file with the package name and a .spec filename extension. For example, the jikes package spec file would be named jikes.spec.
Inside the spec file, format the information on the package using a special syntax. This syntax defines how to build the package, version numbers, dependency information, and everything else you can query about a package. This syntax differs slightly depending on the section in the spec file. The following section describe these spec file section and the necessary syntax in each section.

8.2.3.1. The introduction section

The introduction section contains information about the package, the type of information shown with the rpm -qi command. For example:
Summary: java source to bytecode compiler
%define version 1.17
Copyright: IBM Public License, http://ibm.com/developerworks/oss/license10.html
Group: Development/Languages
Name: jikes
Prefix: /usr
Provides: jikes
Release: 1
Source: jikes-%{version}.tar.gz
URL: http://ibm.com/developerworks/opensource/jikes
Version: %{version}
Buildroot: /tmp/jikesrpm
%description
The IBM Jikes compiler translates Java source files to bytecode. It
also supports incremental compilation and automatic makefile generation,
and is maintained by the Jikes Project:
http://ibm.com/developerworks/opensource/jikes/
In this example, you can see the Source: definition of a compressed tar archive associated with a particular version number. This also names a Buildroot: setting that defines where the files will get built into a working program. You can see the description of the package that will get printed with the rpm –qi command.
Note
You can further divide this first section into the preamble and other areas. For simplicity, I grouped all introductary parts of a spec file into one introduction section.
This example comes from a real-world RPM spec file. It does not follow all the rules for creating RPMs. This example:
*Should not explicitly provide jikes, the name of the package.
*Should not include a Copyright tag, as this tag is deprecated.
*Uses a %define for the version when the rpmbuild command can create a version macro for you.