Why are some RPM's "not relocatable"?

Matthew Moisen asked:

An RPM is relocatable if you can install it like this:

rpm -ivh --prefix=/path/to/non/default/dir package-name.rpm

Without getting the following error message:

error: package package-name is not relocatable

This link states:

RPM has the ability to give users some latitude in deciding where packages are to be installed on their systems. However, package builders must first design their packages to give users this freedom. In other words, an RPM package that can be installed into a different directory is said to be relocatable. Please note that not all RPM packages can be installed into another directory.

It however does not explain why a package builder would not want to permit users the freedom to decide where to install the package.

So, why is it a good idea to make a particular package not relocatable?

My answer:

In fact, most RPM packages you will find are not relocatable.

The Fedora Packaging Guidelines have this to say:

The use of RPM’s facility for generating relocatable packages is strongly discouraged. It is difficult to make work properly, impossible to use from the installer or from yum, and not generally necessary if other packaging guidelines are followed. However, in the unlikely event that you have a good reason to make a package relocatable, you MUST state this intent and reasoning in the request for package review.

These being the upstream packages for RHEL, you are very unlikely to find a relocatable package in an official Fedora, RHEL/CentOS, or EPEL distribution repository.

You might, however, very rarely find third-party RPMs which are relocatable. But there’s no good way to install or manage them once they are installed, as dependency managers can’t handle them, and there’s little point to trying to relocate the package anyway.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.