Installing a package locally to a user - best practices?
There are ways to install rpms in a user directory using
rpm, but I don't believe it is straight-forward. I don't believe there is a way with
My standard practice has become to compile from source to a
local directory in my home
$ mkdir ~/local $ mkdir ~/local/bin $ mkdir ~/local/lib $ mkdir ~/local/include
I download source as I would to
/usr/local when I have root, e.g., in
When compiling I set the prefix to the
$ configure --prefix=/home/user_name/local $ make $ make install
I then add
~/local/bin to my $PATH in
Of course, the pain with installing from source is that you don't get automatic dependency resolution. If you find that you need to install dependencies, compile and install them as above. Then when you compile
git, you need to update the compile flags so they look in the correct location for the dependency's libraries and include files:
./configure --prefix=/home/user_name/local LDFLAG='-L/home/user_name/local/lib' CFLAGS='-I/home/user_name/local/include' CPPFLAGS='-I/home/user_name/local/include' CXXFLAGS='-I/home/user_name/local/include'
An .rpm file is actually a form of
cpio archive, which is a lot like a simple form of
rpm2cpio utility is probably installed on the system and does not require privileges to use; it writes to standard out, so to convert:
rpm2cpio whatever.rpm > whatever.cpio
man cpio you can look at yourself, but what you now want to do is feed the archive to cpio in "copy in" mode:
cat whatever.cpio | cpio -i
Very likely the stuff is organized into a directory tree so that files go into appropriate locations (bin, etc, etc.). If those don't exist in your pwd, you'll get an error, but that will list the files in the archive (you can get the same thing with the
--list switch). If you want to create the directories automatically, use
-d. So a quick way to unpack an rpm:
rpm2cpio whatever.rpm | cpio -i -d
You can use this to install into $HOME. The only problem will be if the program expects to find stuff in
/etc, etc., since many things have their install location hard-coded in for whatever purpose when they are compiled.
Building from source is probably a better option (since you can provide the correct location), but if you can get this to work in whatever case then it's quick and simple.
Also, the midnight commander file browser (
mc), and probably other file browsers besides, will allow you to navigate an rpm or cpio (or compressed tar, or zip) hierarchy and copy out individual files as if the archive were unpacked (it creates a temporary file system to browse with the archive contents in it).