I sometimes run into the problem that I work on a computer (via ssh) which does not have all the tools and libraries installed that I want to use. In the past I went on and compiled all I needed manually and installed them into ~/opt
.
Problem: you don’t have any kind of package management for the stuff you installed into ~/opt
.
Solution: GNU stow
GNU Stow is a symlink farm manager which takes distinct packages of software and/or data located in separate directories on the filesystem, and makes them appear to be installed in the same place.
With stow you install each piece of software into a different directory and you use stow to create symlinks.
So here is what you have to do:
- Create
~/opt
folder with all the usual subfolder (bin, etc, include, lib, share, …) - Create
~/opt/stow
folder for your package - Get GNU stow (obviously) and put the
stow
script into~/opt/bin
- If not done already, put ~/opt/bin to your path
- Create a
.stowrc
with the following content
--dir=/home/f3lix/opt/stow
--target=/home/f3lix/opt
- Install something (e.g. tmux):
$ tar xzf tmux-1.5.tar.gz
$ cd tmux-1.5
$ ./configure --prefix=$HOME/opt/stow/tmux-1.5
$ make install
Now you can use stow tmux-1.5
to activate the installed ‘package’. This will create symlinks in ~/opt
which point to $HOME/opt/stow/tmux-1.5
.
One advantage over installing everything directly into ~/opt
is that uninstalling is much easier (e.g. stow -D tmux-1.5
). Another advantage is that you can have multiple versions of a library installed and switch between them. I use this for example to switch between different BLAS implementations.
BTW, if you are running Debian and do not want to compile things or if you just need some header files for existing libraries you can also install DEB packages using something like this script:
#!/bin/sh debfile=$1 debname=`basename $1 .deb` targetdir=${HOME}/opt/stow/${debname} mkdir ${targetdir} dpkg -x ${debfile} ${targetdir} mv ${targetdir}/usr/* ${targetdir}/ rm -rf ${targetdir}/usr stow ${debname}
Additional infos
- Manage packages using Stow
http://www.ibm.com/developerworks/linux/library/l-stow/ - Simple Package Management With Stow
http://linuxgazette.net/issue75/peda.html
To completely follow the tradition, I think you should use ~/local as the place to put your symlinks, because ~/opt is not supposed to contain the usual unix tree (bin, lib …).