-->
Page 255
Summary: The foo app, and the baz library needed to build it Group: bogus/junque %description This is the long description of the foo app, and the baz library needed to build it... %package server Summary: The foo server Group: bogus/junque %package client Summary: The foo client Group: bogus/junque %package -n bazlib Version: 5.6 Summary: The baz library Group: bogus/junque %files /usr/local/foo-file %files server /usr/local/server-file %files client /usr/local/client-file %files -n bazlib /usr/local/bazlib-file
As you can see, we've added %files lists for
Each package contains a single file. (Hey, we said it was a simple example!) If there was no need for a main package, we could simply remove the unnamed %files list. Keep in mind that even if you do not create a main package, the tags defined in the main package's preamble will appear somewherespecifically, in the source package file.
Let's look at the last subpackage-specific part of the spec file: the install and erase time scripts.
The install and erase time scripts, %pre, %preun, %post, and %postun, can all be named using exactly the same method as was used for the other subpackage-specific sections of the spec file. The script used during package verification, %verifyscript, can be made package specific as
Page 256
well. Using the subpackage structure from our sample spec file, we would end up with script definitions like this:
Other than the change in naming, there's only one thing to be aware of when creating scripts for subpackages. It's important that you consider the possibility of scripts from various subpackages interacting with each other. Of course, this is simply good script-writing practice, even if the packages involved are not related.
Here we've added some scripts to our spec file. So that our example doesn't get too complex, we've just added preinstall scripts for each package:
Name: foo Version: 2.7 Release: 1 Source: foo-2.7.tgz CopyRight: probably not Summary: The foo app, and the baz library needed to build it Group: bogus/junque %description This is the long description of the foo app, and the baz library needed to build it... %package server Summary: The foo server Group: bogus/junque %description server This is the long description for the foo server... %package client Summary: The foo client Group: bogus/junque %description client This is the long description for the foo client... %package -n bazlib Version: 5.6 Summary: The baz library Group: bogus/junque %description -n bazlib This is the long description for the bazlib... %pre echo "This is the foo package preinstall script" %pre server echo "This is the foo-server subpackage preinstall script"
Page 257
%pre client echo "This is the foo-client subpackage preinstall script" %pre -n bazlib echo "This is the bazlib subpackage preinstall script" %files /usr/local/foo-file %files server /usr/local/server-file %files client /usr/local/client-file %files -n bazlib /usr/local/bazlib-file
As preinstall scripts go, these don't do very much. But they will allow us to see how subpackage-specific scripts can be defined.
Those of you who have built packages probably realize that our spec file is missing something. Let's add that part now.
Although creating subpackages changes the general structure of the spec file, there's one section that doesn't change: the build-time scripts. This means there is only one set of %prep, %build, and %install scripts in any spec file.
Of course, even if RPM doesn't require any changes to these scripts, you still might need to make some subpackage-related changes to them. Normally these changes are related to doing whatever is required to get all the software unpacked, built, and installed. For example, if packaging client/server software, the software for both the client and the server must be unpacked, and then both the client and server binaries must be built and installed.
Let's add some build time scripts and take a final look at the spec file:
Name: foo Version: 2.7 Release: 1 Source: foo-2.7.tgz CopyRight: probably not Summary: The foo app, and the baz library needed to build it Group: bogus/junque %description
Page 258
This is the long description of the foo app, and the baz library needed to build it... %package server Summary: The foo server Group: bogus/junque %description server This is the long description for the foo server... %package client Summary: The foo client Group: bogus/junque %description client This is the long description for the foo client... %package -n bazlib Version: 5.6 Summary: The baz library Group: bogus/junque %description -n bazlib This is the long description for the bazlib... %prep %setup %build make %install make install %pre echo "This is the foo package preinstall script" %pre server echo "This is the foo-server subpackage preinstall script" #%pre client echo "This is the foo-client subpackage preinstall script" %pre -n bazlib echo "This is the bazlib subpackage preinstall script" %files /usr/local/foo-file %files server /usr/local/server-file %files client /usr/local/client-file %files -n bazlib /usr/local/bazlib-file
As you can see, the build time scripts are about as simple as they can be. This is the advantage to making up an example. A more real-world spec file would undoubtedly have more interesting scripts.
Page 259
Now it's time to give our sample spec file a try. The build process is not that much different from that of a single-package spec file:
# rpm -ba foo-2.7.spec Package: foo Package: foo-server Package: foo-client Package: bazlib ... Executing: %prep ... Executing: %build ... Executing: %install ... Executing: special doc + cd /usr/src/redhat/BUILD + cd foo-2.7 + DOCDIR=//usr/doc/foo-2.7-1 + DOCDIR=//usr/doc/foo-server-2.7-1 + DOCDIR=//usr/doc/foo-client-2.7-1 + DOCDIR=//usr/doc/bazlib-5.6-1 + exit 0 Binary Packaging: foo-2.7-1 Finding dependencies... usr/local/foo-file 1 block Generating signature: 0 Wrote: /usr/src/redhat/RPMS/i386/foo-2.7-1.i386.rpm Binary Packaging: foo-server-2.7-1 Finding dependencies... usr/local/server-file 1 block Generating signature: 0 Wrote: /usr/src/redhat/RPMS/i386/foo-server-2.7-1.i386. rpm Binary Packaging: foo-client-2.7-1 Finding dependencies... usr/local/client-file 1 block Generating signature: 0 Wrote: /usr/src/redhat/RPMS/i386/foo-client-2.7-1.i386.rpm Binary Packaging: bazlib-5.6-1 Finding dependencies... usr/local/bazlib-file 1 block Generating signature: 0 Wrote: /usr/src/redhat/RPMS/i386/bazlib-5.6-1.i386.rpm ... Source Packaging: foo-2.7-1 foo-2.7.spec foo-2.7.tgz 4 blocks Generating signature: 0 Wrote: /usr/src/redhat/SRPMS/foo-2.7-1.src.rpm #