Random Wisdom

Installing RPMs as a regular user

by on Apr.20, 2006, under How To ..., Linux, Software

A while back I needed some packages on a machine that I don’t have admin rights to. Grabbing the source and recompiling would have been a pain the a** so I decided to read the rpm man pages and look for a way to install packages in the user home directory. Since it’s such a nice package manager, it comes with options that allows me to do just that. The command needed is:

$ rpm -ivh --relocate OLDPATH1=NEWPATH1 [--relocate OLDPATH2=NEWPATH2 ...] \
      --badreloc package.rpm

where OLDPATH is the path in the package; and NEWPATH is something like /home/user/userroot/usr, etc.

It’s best to run

$ rpm -qpl package.rpm

to see exactly which paths are going to be used by the package. For example, if the package foo.rpm produces:

$ rpm -qpl foo.rpm

then the steps needed are:

$ mkdir -p ~/myroot/usr/bin ~/myroot/usr/lib ~/myroot/usr/share/doc
$ rpm -ivh --relocate /usr=/home/$USER/myroot/usr --badreloc foo.rpm

That’ll install the package under the hierarchy ~/myroot. There will some errors from rpmdb but this is fine since the rpmdb is in a filesystem that we do not have write access to. The only repercussion is that rpm will have no record of the package foo being installed (so packages will have to be removed by hand); but that’s okay since we cannot possibly mess up the system while installing stuff under our own home dirs.

The only steps remaining are to add the new paths to the binary and library search paths. To so this, add the following lines to ~/.bash_profile


        export PATH LD_LIBRARY_PATH

This is only efficient as long as the package does not have too many unmet dependencies — since you will need to grab and install all missing dependencies along with the package itself. And even if you had installed some of the dependencies earlier using this method, rpm will not know about it since there will be no entry in the system rpmdb.

:, ,

Leave a Reply