-->

Previous | Table of Contents | Next

Page 139

Chapter 12

rpm -b
Command Reference

Page 140

Table 12.1. Build-mode command syntax and options.

rpm -b <stage> Options file1.spec...fileN.spec
<stage> Section
p Execute %prep 12.1.1
c Execute %prep, %build 12.1.2
i Execute %prep, %build, %install 12.1.3
b Execute %prep, %build, %install; Package (bin) 12.1.4
a Execute %prep, %build, %install; Package (bin, src) 12.1.5
l Check %files list 12.1.6
Parameters
spec1...specN One or more spec files
Build-Specific Options Section
--short-circuit Force build to start at particular stage (-bc, -bi only) 12.1.7
--test Create, save build scripts for review 12.1.11
--clean Clean up after build 12.1.12
--sign Add a digital signature to the package 12.1.10
--buildroot <root> Execute %install using <root> as the root 12.1.13
--buildarch <arch> Perform build for the <arch> architecture 12.1.8
--buildos <os> Perform build for the <os> operating system 12.1.9
--timecheck <secs> Print a warning if files are over <secs> old 12.1.14
General Options Section
-vv Display debugging information 12.1.15
--quiet Produce as little output as possible 12.1.16
--rcfile <rcfile> Set alternate rpmrc file to <rcfile> 12.1.17

12.1. rpm -b: What Does It Do?

When RPM is invoked with the -b option, the process of building a package is started. The rest of the command will determine exactly what is to be built and how far the build should proceed. This chapter explores every aspect of rpm -b.

An RPM build command must have two additional pieces of information, over and above rpm -b:

Page 141

As discussed in Chapter 10, "The Basics of Developing with RPM," the spec file is one of the inputs to RPM's build process. It contains the information necessary for RPM to perform the build and package the software.

RPM goes through a number of stages during a build. By specifying that the build process is to stop at a certain stage, the package builder can monitor the build's progress, make any changes necessary, and restart the build. Let's start by looking at the various stages that can be specified in a build command.

12.1.1. rpm -bp: Execute %prep

The command rpm -bp directs RPM to execute the very first step in the build process.

In the spec file, this step is labeled %prep. Every command in the %prep section will be executed when the -bp option is used.

Here's a simple %prep section from the spec file we used in Chapter 11, "Building Packages: A Simple Example":


%prep

%setup

This %prep section consists of a single %setup macro. When using rpm -bp against this spec file, we can see exactly what %setup does:


# rpm -bp cdplayer-1.0.spec

* Package: cdplayer

+ umask 022

+ echo Executing: %prep

Executing: %prep

+ cd /usr/src/redhat/BUILD

+ cd /usr/src/redhat/BUILD

+ rm -rf cdplayer-1.0

+ gzip -dc /usr/src/redhat/SOURCES/cdplayer-1.0.tgz

+ tar -xvvf -

drwxrwxr-x root/users         0 Aug  4 22:30 1996 cdplayer-1.0/

-rw-r--r-- root/users     17982 Nov 10 01:10 1995 cdplayer-1.0/COPYING

-rw-r--r-- root/users       627 Nov 10 01:10 1995 cdplayer-1.0/ChangeLog

...

-rw-r--r-- root/users      2806 Nov 10 01:10 1995 cdplayer-1.0/volume.c

-rw-r--r-- root/users      1515 Nov 10 01:10 1995 cdplayer-1.0/volume.h

+ [ 0 -ne 0 ]

+ cd cdplayer-1.0

+ cd /usr/src/redhat/BUILD/cdplayer-1.0

+ chown -R root.root .

+ chmod -R a+rX,g-w,o-w .

+ exit 0

#

First, RPM confirms that the cdplayer package is the subject of this build. Then it sets the umask and starts executing the %prep section. At this point, the %setup macro is doing its thing. It changes directory into the build area and removes any old copies of cdplayer's build tree.

Page 142

Next, %setup unzips the sources and uses tar to create the build tree. We've removed the complete listing of files, but be prepared to see lots of output if the software being packaged is large.

Finally, %setup changes directory into cdplayer's build tree and changes ownership and file permissions appropriately. exit 0 signifies the end of the %prep section and, therefore, the end of the %setup macro. Because we used the -bp option, RPM stopped at this point. Let's see what RPM left in the build area:


# cd /usr/src/redhat/BUILD

# ls -l

total 1

drwxr-xr-x 2 root root 1024 Aug 4 22:30 cdplayer-1.0

#

There's the top-level directory. Changing directory into cdplayer-1.0, we find that the sources are ready to be built:


# cd cdplayer-1.0

# ls -lF

total 216

-rw-r--r--    1 root    root    17982 Nov 10  1995 COPYING

-rw-r--r--    1 root    root      627 Nov 10  1995 ChangeLog

...

-rw-r--r--    1 root    root     2806 Nov 10  1995 volume.c

-rw-r--r--    1 root    root     1515 Nov 10  1995 volume.h

#

We can see that %setup's chown and chmod commands did what they were supposed to—the files are owned by root, with permissions set appropriately.

If not stopped by the -bp option, the next step in RPM's build process would be to build the software. RPM can also be stopped at the end of the %build section in the spec file. This is done by using the -bc option.

12.1.2. rpm -bc: Execute %prep, %build

When the -bc option is used during a build, RPM stops once the software has been built. In terms of the spec file, every command in the %build section will be executed. In the following example, we've removed the output from the %prep section to cut down on the redundant output, but keep in mind that it is executed nonetheless:


# rpm -bc cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ make

gcc -Wall -O2 -c -I/usr/include/ncurses cdp.c

gcc -Wall -O2 -c -I/usr/include/ncurses color.c

gcc -Wall -O2 -c -I/usr/include/ncurses display.c



Previous | Table of Contents | Next