7. Advanced RPM Building

RPM has some very advanced features available for larger, more complex
packages. It has the ability to build and output multiple binary
subpackages. An example of this is the ability to produce separate
Tcl/Tk binary packages from one spec file. Another example is the
ability to use one spec file to create a single XFree86 package with
no servers, and a separate package for each of the servers.

7.1 How to Get Started

The best way to get started is to look at an example spec file.
The following tcl/tk spec file is a good one to start with (though
you can also view the spec file of any package by installing
the sources and looking in /usr/src/redhat-2.0/SPECS):

7.2 Sub-Packages

One of the main advanced features of RPM is the ability to build
subpackages. They are easy to build as for most macros you can just
add the subpackage name as a parameter for anything specific to a
subpackage (and if you leave it off the section will apply to the
main package).

7.3 The Header

The header only has one major difference, the %package macro.
This macro is used in the header to tell which subpackage name to match
the description with. If you omit the macro in the initial part of the
header, you will get a main package with no change to the name. In
the XFree86 package, however, there is no %package macro
in the top of the header. This is because we wanted a base XFree86
package with all the common stuff in it and then several subpackages
(XFree86-SVGA, etc.) with the servers. Tcl/Tk does not need a
main package, so the macro is at the top.

Another difference is the fact that this package has multiple source
and patch lines. If you'll notice, there is now a Source0 line
instead of just Source. They are functionally equivalent, though
it is a good idea to use Source0 when there is more than one
source file (and the same applies to patches as well).

7.4 Prep

Prep is basically the same as in the simple example, except it uses more
of the options available to the setup and patch macros.

7.5 Build

Build is basically the same, with the exception that the setup
macro above used the -T option. Because of that, you have to
do a manual cd to get into the source directory.

You will also notice that the build does a configure before
it can build. This is the section where any of this type of configuration
should go.

7.6 Install

Again, everything is pretty normal with the exception of the fact that
you must manually cd into the source directories.

7.7 Optional pre and post Install/Uninstall Scripts

This section is almost the same as in a simple RPM case (see the above section).
It has two post install scripts that run ldconfig for each of the subpackages
upon install. It should have two post uninstall scripts to run ldconfig
as well.

7.8 Files

Here you will declare which files go in which packages. You really have
multiple file sections, each started with a new %files macro
and the name of the subpackage (except in the case where you have a
main package...that %files macro will have no argument
given to it). The other macros (doc, config, etc) work exactly the
same as in the simple case.

You also have the option to use the * to glob filenames out of
a directory. You need to be careful with this (perhaps test it
first) so as not to include files you didn't mean to. The above
example does this with the man pages.

7.9 What Now?

Please see the above sections on Testing and What to do with new RPMs.
We want all the RPMs available we can get, and we want them to be good
RPMs. Please take the time to test them well, and then take the time
to upload them for everyone's benefit. Also, please make sure
you are only uploading freely available software. Commercial
software and shareware should not be uploaded unless they have
a copyright expressly stating that this is allowed.