-->

Previous | Table of Contents | Next

Page 125

Chapter 11

Building Packages:
A Simple Example

Page 126

In Chapter 10, "The Basics of Developing with RPM," we looked at RPM's build process from a conceptual level. In this chapter, we will be performing an actual build using RPM. In order to keep things understandable for this first pass, the build will be very simple. Once we've covered the basics, we'll present more real-world examples in later chapters.

11.1. Creating the Build Directory Structure

RPM requires a set of directories in which to perform the build. Although the directories' locations and names can be changed, it's best to use the default layout. Note that if you've installed RPM, the build directories are most likely in place already.

The normal directory layout consists of a single top-level directory (the default name is /usr/src/redhat) with five subdirectories. The five subdirectories and their functions are

In general, there are no special requirements that need to be met when creating these directories. In fact, the only important requirement is that the BUILD directory be part of a filesystem with sufficient free space to build the largest package expected. Here is a directory listing showing a typical build directory tree:


# ls -lF /usr/src/redhat

total 5

drwxr-xr-x 3 root root 1024 Aug 5 13:12 BUILD/

drwxr-xr-x 3 root root 1024 Jul 17 17:51 RPMS/

drwxr-xr-x 4 root root 1024 Aug 4 22:31 SOURCES/

drwxr-xr-x 2 root root 1024 Aug 5 13:12 SPECS/

drwxr-xr-x 2 root root 1024 Aug 4 22:28 SRPMS/

#

Now that we have the directories ready to go, it's time to prepare for the build. For the remainder of this chapter, we'll be building a fictional piece of software known as cdplayer.


NOTE
The cdplayer software is a mercilessly hacked version of cdp, which was written by Sariel Har-Peled. The software was hacked to provide a simple sample package and in no way represents the fine work done by Sariel on cdp.

Page 127

11.2. Getting the Sources

The first thing we need to do in order to build a package for cdplayer is to obtain the sources. Being avid cdplayer fans from way back, we know that the latest source can be found at GnomoVision's FTP site, so we go get a copy.

We now have a gzipped tar file of cdplayer version 1.0 on our system. After putting a copy in the SOURCES directory, we're ready to tell RPM what to do with it.

11.3. Creating the Spec File

The way we direct RPM in the build process is to create a spec file. As we saw in Chapter 10, the spec file contains eight different sections, most of which are required. Let's go through each section and create cdplayer's spec file as we go.

11.3.1. The Preamble

The preamble contains a wealth of information about the package being built and the people who built it. Here's cdplayer's preamble:


#

# Sample spec file for cdplayer app...

#

Summary: A CD player app that rocks!

Name: cdplayer

Version: 1.0

Release: 1

Copyright: GPL

Group: Applications/Sound

Source: ftp://ftp.gnomovision.com/pub/cdplayer/cdplayer-1.0.tgz

URL: 

http://www.gnomovision.com/cdplayer/cdplayer.html

Distribution: WSS Linux

Vendor: White Socks Software, Inc.

Packager: Santa Claus <sclaus@northpole.com>



%description

It slices! It dices! It's a CD player app that can't be beat. By using

the resonant frequency of the CD itself, it is able to simulate 20X

oversampling. This leads to sound quality that cannot be equaled with

more mundane software...

In general, the preamble consists of entries, one per line, that start with a tag followed by a colon, and then some information. For example, the line starting with Summary: gives a short description of the packaged software that can be displayed by RPM. The order of the lines is not important, as long as they appear in the preamble.

Page 128

Let's take a look at each line and see what function it performs:

Previous | Table of Contents | Next