6

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?

4
  • 1
    Best option is Michael's suggestion to get your admin to do it. However, you might be able to rebuild from the source package and specify an alternate install point (e.g. /home/matthew/whatever as the top prefix directory). Or, you might be able to extract the files manually like a tarball. I just answered a similar question here: serverfault.com/questions/772073/install-rsync-3-1-1-on-systemd/… This can work if the package can work relative even if it's not "relocatable" (e.g. uses relative symlinks like ../../blah). It's more work, but if your admin refuses ... Apr 30, 2016 at 5:57
  • @CraigEstey Thanks, I will favorite that and keep it in mind for future cases; unfortunately this is a closed source driver from MapR. Apr 30, 2016 at 5:59
  • Caveat: Dangerous Liaisons Do not do this if you could get fired [for any [silly] reason]. But, if you're the only user of the system (e.g. it's your desktop system and not a shared server), boot the install DVD in recovery mode. Your HD's will get mounted on /mnt/sysimage/whatever. Then, do su. Then do (e.g.) chroot /mnt/sysimage/rootfs rpm .... The .rpm file may have to be on a thumb drive or it could be in your home directory under the cross-mount. And, while you're at it, give yourself sudo ... Or, just get sudo, and then reboot and install [simpler] Apr 30, 2016 at 6:15
  • This should either be on SU or closed. Serverfault is for admins.
    – Jim B
    May 1, 2016 at 19:26

2 Answers 2

8

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.

5
  • 1
    Thanks. As to my reason for wanting to relocate the package, I lack sudo on the host and can't install it via yum. Apr 30, 2016 at 5:29
  • You should contact your system administrator, then. Apr 30, 2016 at 5:36
  • 1
    At my company it can take upwards of 2 days to accomplish that feat :) Apr 30, 2016 at 5:58
  • 2
    2 days? you were lucky! Mar 8, 2017 at 10:35
  • I routinely make my packages relocatable so that I can test they are installable without actually installing them. However, not that way of doing this is to install them in a docker image. Jun 14, 2022 at 14:55
0

I had to do something similar, and while rpm --relocate did not work ("error: package is not relocatable"), rpm -i --prefix did work.

I use it in combination witht --dbpath to install it to a local development path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .