Local installs
From Peyton Hall Documentation
m (Updated for loop for path modifications) |
(LD_LIBRARY_PATH considered harmful) |
||
Line 28: | Line 28: | ||
[[ "$MANPATH" =~ "(^|:)$D/man($|:)" ]] || \ | [[ "$MANPATH" =~ "(^|:)$D/man($|:)" ]] || \ | ||
export MANPATH=$D/man:${MANPATH:+$MANPATH} | export MANPATH=$D/man:${MANPATH:+$MANPATH} | ||
- | |||
- | |||
- | |||
- | |||
- | |||
fi | fi | ||
done</nowiki> | done</nowiki> |
Revision as of 20:51, 21 October 2009
Even with the amount of software available on the network, sometimes you can't live without a certain program. Or maybe you want to install it on your laptop, but don't want to have to bother with putting it in a "normal" system location (and having to be root or an administrator to deal with it). Here's a trick which I've started doing on my Mac, and you can do on any other machine to make it simple to install software without needing administrative privileges (and it's easy to clean up if you reinstall/remove the software later on, too!)
- Create a directory where your software installs will live.
- mkdir ~/Installs
- Create a directory named for the program you wish to install.
- mkdir ~/Installs/FooGram
- Download the source to that directory. Uncompress it as usual.
- This will normally create a directory called ~/Installs/FooGram/FooGram-1.2.3 for example. This directory contains the source.
- Add a prefix command to your './configure' command.
- ./configure --prefix=~/Installs/FooGram
- This tells configure that you want to install the software not in the normal /usr/bin or /usr/local/bin location, but in a directory tree based from ~/Installs/FooGram.
- When done compiling and installing, you will probably have directories like ~/Installs/FooGram/bin, ~/Installs/FooGram/lib and ~/Installs/FooGram/share, perhaps more.
- Tell your shell where to look, so you can run the program just like any other.
- For bash, I have the following in my ~/.bashrc:
for D in $HOME/Installs/* ; do if [ -d $D/bin ]; then [[ "$PATH" =~ "(^|:)$D/bin($|:)" ]] || \ export PATH=$D/bin${PATH:+:$PATH} fi if [ -d $D/share/man ]; then [[ "$MANPATH" =~ "(^|:)$D/share/man($|:)" ]] || \ export MANPATH=$D/share/man:${MANPATH:+$MANPATH} fi if [ -d $D/man ]; then [[ "$MANPATH" =~ "(^|:)$D/man($|:)" ]] || \ export MANPATH=$D/man:${MANPATH:+$MANPATH} fi done
Now for each of the directories in which I have software installed, the proper PATH value is prepended to my normal $PATH. So I can just run "foogram" from a prompt, instead of running "~/Installs/FooGram/bin/foogram". Also, since $MANPATH is updated, I can type 'man foogram' and have it work. Note that after a new install, you will have to logout and login again for the change to be noticed - but that's a pretty small price to pay.
Later on, if you decide to remove the program, you need only delete the entire ~/Installs/FooGram directory and it's gone - no more hunting in multiple shared/bin/sbin/lib/man directories to find all the files that go with some bit of software. Or you can move the directory out of the way, install a newer version, and then remove the old one when you're sure it's working as expected.
NOTE:
- You should not install a program to your network home directory. /u is backed up regularly, and storing a program there is wasteful (and expensive). Instead, install programs to scratch disks, which are still accessible by most of the machines in the building. The above example is written if you're looking to install things on a laptop or home machine, but it's not difficult to adapt the instructions to a scratch disk install.