-->

Previous | Table of Contents | Next

Page 143




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

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

volume.c: In function `mix_set_volume':

volume.c:67: warning: implicit declaration of function `ioctl'

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

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

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

gcc -o cdp cdp.o color.o display.o misc.o volume.o hardware.o database.o

getline.o -I/usr/include/ncurses -L/usr/lib -lncurses

groff -Tascii -man cdp.1 | compress >cdp.1.Z

+ exit 0

#

After the command, we see RPM executing the %prep section (which we've removed almost entirely). Next, RPM starts executing the contents of the %build section. In our sample spec file, the %build section looks like this:


%build

make

We see that prior to the make command, RPM changes directory into cdplayer's top-level directory. RPM then starts the make, which ends with the groff command. At this point, the execution of the %build section has been completed. Because the -bc option was used, RPM stops at this point.

The next step in the build process would be to install the newly built software. This is done in the %install section of the spec file. RPM can be stopped after the install has taken place by using the -bi option.

12.1.3. rpm -bi: Execute %prep, %build, %install

By using the -bi option, RPM is directed to stop once the software is completely built and installed on the build system. Here's what the output of a build using the -bi option looks like:


# rpm -bi cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

...

+ exit 0

Executing: %install

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ make install

chmod 755 cdp

chmod 644 cdp.1.Z

cp cdp /usr/local/bin

ln -s /usr/local/bin/cdp /usr/local/bin/cdplay

cp cdp.1 /usr/local/man/man1

+ exit 0

+ umask 022

+ echo Executing: special doc



Page 144




Executing: special doc

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ DOCDIR=//usr/doc/cdplayer-1.0-1

+ rm -rf //usr/doc/cdplayer-1.0-1

+ mkdir -p //usr/doc/cdplayer-1.0-1

+ cp -ar README //usr/doc/cdplayer-1.0-1

+ exit 0

#

As before, we've cut out most of the previously described sections. In this example, the %install section looks like this:


%install

make install

After the %prep and %build sections, the %install section is executed. Looking at the output, we see that RPM changes directory into cdplayer's top-level directory and issues the make install command, the sole command in the %install section. The output from that point until the first exit 0 is from makefile's install target.

The remaining commands are due to the contents of the spec file's %files list. Here's what it looks like:


%files

%doc README

/usr/local/bin/cdp

/usr/local/bin/cdplay

/usr/local/man/man1/cdp.1

The line responsible is %doc README. The %doc tag identifies the file as being documentation. RPM handles documentation files by creating a directory in /usr/doc and placing all documentation in it. The exit 0 at the end signifies the end of the %install section. RPM stops due to the -bi option.

The next step at which RPM's build process can be stopped is after the software's binary package file has been created. This is done using the -bb option.

12.1.4. rpm -bb: Execute %prep, %build, %install, Package (bin)

As stated at the end of the previous section, RPM's -bb option performs every step of the build process up to the point of creating the source package file. At that point it stops, as shown here:


# rpm -bb cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

...

+ exit 0

Executing: %install

...



Page 145




+ exit 0

Executing: special doc

...

+ exit 0

Binary Packaging: cdplayer-1.0-1

Finding dependencies...

Requires (2): libc.so.5 libncurses.so.2.0

usr/doc/cdplayer-1.0-1

usr/doc/cdplayer-1.0-1/README

usr/local/bin/cdp

usr/local/bin/cdplay

usr/local/man/man1/cdp.1

93 blocks

Generating signature: 0

Wrote: /usr/src/redhat/RPMS/i386/cdplayer-1.0-1.i386.rpm

+ umask 022

+ echo Executing: %clean

Executing: %clean

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ exit 0

#

After executing the %prep, %build, and %install sections and handling any special documentation files, RPM creates a binary package file. In the sample output, we see that first RPM performs automatic dependency checking. It does this by determining which shared libraries are required by the executable programs contained in the package. Next, RPM actually archives the files to be packaged, optionally signs the package file, and outputs the finished product.

The last part of RPM's output looks suspiciously like a section in the spec file being executed. In our example, there is no %clean section. If there were, however, RPM would have executed any commands in the section. In the absence of a %clean section, RPM simply issues the usual cd commands and exits normally.

12.1.5. rpm -ba: Execute %prep, %build, %install, Package
(bin, src)

The -ba option directs RPM to perform all the stages in building a package. With this one command, RPM does the following:

  1. Unpacks the original sources.
  2. Applies patches (if desired).
  3. Builds the software.
  4. Installs the software.
  5. Creates the binary package file.
  6. Creates the source package file.

Page 146

That's quite a bit of work for one command! Here it is, in action:


# rpm -ba cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

...

+ exit 0

Executing: %install

...

+ exit 0

Executing: special doc

...

+ exit 0

Binary Packaging: cdplayer-1.0-1

...

Executing: %clean

...

+ exit 0

Source Packaging: cdplayer-1.0-1

cdplayer-1.0.spec

cdplayer-1.0.tgz

80 blocks

Generating signature: 0

Wrote: /usr/src/redhat/SRPMS/cdplayer-1.0-1.src.rpm

#

As in previous examples, RPM executes the %prep, %build, and %install sections, handles any special documentation files, creates a binary package file, and cleans up after itself.

The final step in the build process is to create a source package file. As the output shows, it consists of the spec file and the original sources. A source package may optionally include one or more patch files, although in our example, cdplayer requires none.

At the end of a build using the -ba option, the software has been successfully built and packaged in both binary and source form. But there are a few more build-time options we can use. One of them is the -bl option.

12.1.6. rpm -bl: Check %files List

There's one last option that may be specified with rpm -b, but unlike the others, which indicate the stage at which the build process is to stop, this option performs a variety of checks on the %files list in the named spec file. When l is added to rpm -b, the command does the following:

Previous | Table of Contents | Next