Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to install Git locally to a user on a RHEL server (I don't have root access) What would be your cleanest/ most organized way of installing software to a local user account?

  • Installing everything in that users home directory?
  • What would the directory layout look like?
  • Would you install from source or RPM?
  • If from RPM would you use YUM or RPM?
share|improve this question

2 Answers 2

up vote 6 down vote accepted

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 yum.

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 ~/local/git.

When compiling I set the prefix to the local directory

$ configure --prefix=/home/user_name/local
$ make
$ make install

I then add ~/local/bin to my $PATH in .bash_profile.

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'
share|improve this answer
    
This worked perfectly, thanks for the advice! –  wiredin Apr 25 '13 at 20:15

An .rpm file is actually a form of cpio archive, which is a lot like a simple form of tar. The 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

There's a 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 -t/--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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.