Managing (mangling) software installation using Stow

What is stow?

Stow is a simple way to manage software packages that were built from source, or any package that lets you specify a destination directory. Essentially, it is just a huge wrapper around ln, but it has hordes of sanity checks thrown in the mix.

What does stow do for me?

If you've ever installed a piece of software from source under UNIX, you probably understand that things get can out of control really quick. If you only install a small number of packages, you are pretty safe just letting the software's configuration defaults (hopefully cobbled together with autoconf and automake) "do their thing". This usually results in software getting dumped to /usr/local/, and in rare cases / or /usr. The directories off of /, /usr, and /usr/local generally include some combination of:


For demonstration purposes, let us say I have a piece of software called 'foobar' which is currently at version 1.0. I download the source (http://www.foobar.com/downloads/foobar-1.0.tar.gz), do a very-very simple configuration and installation (tar -zxvf foobar-1.0.tar.gz; cd foobar-1.0; ./configure && make && make install). The installation copies the following files to their respective directories in /usr/local/: Great. You just successfully installed foobar. You use it for a month. During that time, you install 15 other packages from source using similar techniques. Then a little bird whispers in your ear and tells you that foobar-1.3 has come out and fixes a serious security hole and eliminates a few cosmetic bugs.

No problem, right? Just download and install the latest version just like you did with 1.0. Wait a minute, it appears the developers have mixed things up a bit. The installation now creates the following layout under /usr/local: See the problems? Here are a few: Two months later, at least 3 revisions of some 20 software packages, and an unfortunate-command-mishap-while-root later, /usr/local is in shambles. Newly installed packages are linking against incorrect files. Which configuration file do I edit? foobar-1.3 doesn't do what I need -- 2.0 does, but is still beta. How can I safely use 2.0 without wreaking even more havok? When I execute 'foobar', which version am I using?

Soon enough, software installed from source is in an unuseable state. The system is almost entirely broken. You reach for the CDs to reinstall....

Enter: Stow.

As stated above, stow is a simple way to manage software installation that makes having N packages each with X versions painless.

Lets redo the installation of foobar from above, but this time with two minor changes: After 'make && make install', if all goes as planned (and the software's configuration/installation scripts are not horribly broken), we will now have the following directory layout: Well, thats great and all, but none of that is in anybody's $PATH and it's too long for me to type. This is where stow does the dirty work. Since all the business in /usr/local is generally in everyone's $PATH (and in $LD_LIBRARY_PATH and in $MANPATH, etc), we need to get foobar-1.0's files there somehow while keeping in mind that we will be installing newer versions of this software later. Some previous attempts included using a database of sorts, a program called depot and softinst. Stow uses a simple approach -- symlinks. Jumping ahead a bit, lets say we've "stowed" foobar-1.0. We now have the following layout in /usr/local (where --> is a symlink): Cool. The foobar executable is now in everyone's path, the manpage is in the right spot, and the libary and header file are in place. How did we get here? Easy: So what? Now all the files are just symlinks to their true locations. How does this help us when it comes to managing newer versions of software? Simple. Stow has a delete method (-D). Delete (or really just removing the symlinks to the files) the elder version, configure, make, install and stow the newer version:

What does stow not do?

Examples

Here is an example of a system that was recently installed (Slackware Linux 8.0). After installation, the owner of the machine decided to install a number of packages and has since updated some of them. Here is what /usr/local/stow looks like:

Q&A