The best way to explain how the prefix tag is used is to step through an example. Here's a sample prefix tag:
In this example, the prefix path is defined as /opt. This means that, by default, the package will install its files under /opt. Let's assume the spec file contains the following line in its %files list:
If the package is installed without any relocation, this file will be installed in /opt/bin. This is identical to how a non-relocatable package is installed.
However, if the package is to be relocated on installation, the path of every file in the %files list is modified according to the following steps:
Using our /opt/bin/baz file as an example, let's assume that the user installing the package wishes to override the default prefix (/opt), with a new prefix, say, /usr/local/opt. Following the steps above, we first remove the original prefix from the file's path:
/opt/bin/baz becomes /bin/baz
Next, we add the user-specified prefix to the front of the remaining part of the filename:
/usr/local/opt + /bin/baz =
Now that the file's new path has been created, RPM installs the file normally. This part of it seems simple enough, and it is. But as we mentioned above, there are a few things the package builder needs to consider before getting on the relocatable package bandwagon.