Identifying Relocatable Package
Not all RPM packages can be installed into another directory. An RPM package that can be installed into a different directory is said to be relocatable. To check whether a particular package is relocatable, use the command:
# rpm -qpi [rpm package] | head -1
For example, the packages: redhat-lsb-1.3-3.1.EL3.i386.rpm and rsync-2.5.7-5.3E.i386.rpm produces below output:
# rpm -qpi redhat-lsb-1.3-3.1.EL3.i386.rpm | head -1 Name : redhat-lsb Relocations: (not relocatable)
# rpm -qpi rsync-2.5.7-5.3E.i386.rpm | head -1 Name : rsync Relocations: /usr
It states that the redhat-lsb package is not relocatable but rsync is.
Relocating an RPM package
1. Relocating an rpm package allows user to install the rpm package to a different directory than the default. That means you may install the rsync package into a different directory, say /opt using the rpm option –prefix like this:
rpm -ivh --prefix=/opt rsync-2.5.7-5.3E.i386.rpm
2. To verify whether it was indeed installed in /opt, use the command rpm -ql rsync. Below is a sample output:
# rpm -ql rsync /etc/xinetd.d/rsync /opt/bin/rsync /opt/share/doc/rsync-2.5.7 /opt/share/doc/rsync-2.5.7/COPYING /opt/share/doc/rsync-2.5.7/README /opt/share/doc/rsync-2.5.7/tech_report.tex /opt/share/man/man1/rsync.1.gz /opt/share/man/man5/rsyncd.conf.5.gz
3. Now, if the similar process is applied to the redhat-lsb package, this error message will appear:
# rpm -ivh --prefix=/opt redhat-lsb-1.3-3.1.EL3.i386.rpm error: package redhat-lsb is not relocatable
Final Thoughts
Relocation of packages listed as not relocatable is unsupported by most of the OS vendors like RedHat. Therefore it is advisable to only relocate “relocatable” rpm packages.