-->

Previous | Table of Contents | Next

Page 119

Chapter 10

The Basics of Developing
with RPM

Page 120

Now that we've seen the design philosophy of RPM, let's look at the nuts and bolts of RPM's build process. Building a package is similar to compiling code—there are inputs, an engine that does the dirty work, and outputs.

10.1. The Inputs

There are three different kinds of inputs that are used to drive RPM's build process. Two of the three inputs are required, and the third, strictly speaking, is optional. But unless you're packaging your own code, chances are you'll need it.

10.1.1. The Sources

First and foremost are the sources. After all, without them, there wouldn't be much to build! In the case of packaging someone else's software, the sources should be kept as the author distributed them, which usually means a compressed tar file. RPM can handle other archive formats, but a bit more up-front effort is required.

In any case, you should not modify the sources used in the package building process. If you're a third-party package builder, the sources should be just the way you got them from the author's FTP site. If it's your own software, the choice is up to you, but you should consider starting with your mainstream sources.

10.1.2. The Patches

Why all the emphasis on unmodified sources? Because RPM gives you the ability to automatically apply patches to them. Usually, the nature of these patches falls into one of the following categories:

Page 121

10.1.2.1. Creating the Patches

While it might sound a bit daunting to take into account the types of patches outlined here, it's really quite simple. Here's how it's done:

  1. Unpack the sources.
  2. Rename the top-level directory. Make it end with .orig, for example.
  3. Unpack the sources again, leaving the top-level directory name unchanged.

The source tree that you created the second time will be the one you'll use to get the software to build.

If the software builds with no changes required, that's great—you won't need a patch. But if you had to make any changes, you'll have to create a set of patches. To do so, simply clean the source directory of any binaries. Then issue a recursive diff command to compare the source tree you used for the build against the original, unmodified source tree. It's as easy as that!

10.1.3. The Spec File

The spec file is at the heart of RPM's packaging building process. Similar in concept to a makefile, it contains information required by RPM to build the package, as well as instructions telling RPM how to build it. The spec file also dictates exactly what files are a part of the package and where they should be installed.

As you might imagine, with this many responsibilities, the spec file format can be a bit complex. However, it's broken into several sections, making it easier to handle. All told, there are eight sections:

Page 122

Previous | Table of Contents | Next