Maximum RPM: Taking the RPM Package Manager to the Limit
Chapter 13. Inside the Spec File
While every directive we've seen so far is used in the %files list, the %package directive is different. It is used to permit the creation of more than one package per spec file and can appear at any point in the spec file. These additional packages are known as subpackages. Subpackages are named according to the contents of the line containing the %package directive. The format of the package directive is:
|
The <string> should be a name that describes the subpackage. This
string is appended to the base package name to produce the subpackage's
name. For example, if a spec file contains a name tag value of
"foonly", and a "%package doc" line, then the subpackage name
will be foonly-doc
.
As we mentioned above, the name of a subpackage normally includes the
main package name. When the -n option is added to the %package
directive, it directs RPM to use the name specified on the %package
line as the entire package name. In the example above, the following
%package line would create a subpackage named foonly-doc
:
|
The following %package line would create a subpackage named doc
:
|
The %package directive plays another role in subpackage building. That role is to act as a place to collect tags that are specific to a given subpackage. Any tag placed after a %package directive will only apply to that subpackage.
Finally, the name string specified by the %package directive is also used to denote which parts of the spec file are a part of that subpackage. This is done by including the string (along with the -n option, if present on the %package line) on the starting line of the section that is to be subpackage-specific. Here's an example:
|
In this heavily edited spec file segment, a subpackage called bar
has
been defined. Later in the file is a post-install script. Because it has
subpackage bar
's name on the %post line, the post-install script
will be part of the bar
subpackage only.
For more information on building subpackages, please see Chapter 18.