Product SiteDocumentation Site

10.5. Creating Relocatable Packages

A relocatable package allows a user to specify where to install the package. For example, if you build a package for Red Hat Linux, the normal directory for binary executable programs is /usr/bin. Other versions of Linux, though, may place executable programs into /opt/bin, for example. If your package forces the use of /usr/bin, then your package won’t work on these other systems.
Cross Reference
Chapter 18, Using RPM on Non-Red Hat Linuxes covers using RPM on other versions of Linux.
With a relocatable package, though, you allow the user to redefine the top-level directories for your package, such as changing from /usr/bin to /opt/bin in the previous example. Making relocatable packages is generally considered a good thing, as you make the user’s life easier.
To set up a relocatable package, you need to:
*Set up the prefix directives for the top-level directories
*Define the files under the prefix directories

10.5.1. Setting up the prefixes

The Prefix: directive names a top-level directory as a prefix you can relocate to another directory. For example:
Prefix: /usr
This states that all files under /usr can be relocated to other directories by simply mapping /usr to some other directory, such as /opt, on the rpm command line when installing or upgrading the package.
You can define more than one Prefix: directive to list more than one top-level directory.