This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: System Administration

Get rid of stowaway packages with GNU Stow

By David A. Harding on February 22, 2008 (9:00:00 AM)

Share    Print    Comments   

The installation instructions in most free software reviews aren't enough. If you decide a package sucks, how do you get rid of it? If a package rocks, how do you upgrade it? GNU Stow, a package manager for packages you compile and install yourself, provides an easy answer to both questions.

Many GNU/Linux distribution developers use Stow, so you'll find it in the default package repositories of every major GNU/Linux distribution. Stow's only dependency is Perl. If you use a distribution that includes neither Stow nor Perl, you can use Stow's simple bootstrapping instructions to install both.

Installing a package with Stow requires you to slightly modify the make install step of package installation (modifications in bold):

sudo make install prefix=/usr/local/stow/pkgname cd /usr/local/stow sudo stow pkgname

Running make install creates the directory you specify with the prefix= variable and installs all of the package's files there. Changing to the /usr/local/stow/ directory tells Stow to install packages into /usr/local/; Stow always installs packages into the directory above the current directory. Running stow pkgname creates symbolic links in /usr/local/ for each file beneath the package directory, and each symbolic link retains its original path minus stow/pkgname/. So, for example, if you used Stow to install vim, then type vim into most shells and application launchers, the kernel would run /usr/local/stow/vim-7.0/bin/vim.

Stow without AutoConf

Most free software packages for Unix-style operating systems use GNU AutoConf to build themselves. All AutoConf packages accept the prefix= variable to their make install command. Some packages don't use AutoConf and may not support the prefix= variable. To install these packages with Stow, you need to edit the package's Makefile or installation script yourself.

Start by finding the installation step through the package's installation instructions (usually a README or INSTALL file), then modify this step to install the package's files beneath /usr/local/stow/. If the installation instructions say to use the command make, open the Makefile file, look for a variable holding a directory name (normally /usr/local), and set this variable to /usr/local/stow/package_name-release_number/. If the installation process uses a custom script in the source directory (for example, ./install), edit the script and change the variable holding the directory name.

If the package doesn't have an installer, you will have to create directories in /usr/local/stow/package_name-release_number/ and copy the package's files into those directories yourself.

Some rare packages use special installers like CONS and SCons, but they and most installers work like make by reading instructions from a control file in the top level of the package source directory. To get these packages to work with Stow, try reading the installer's manual page, finding the program's control file, opening it in a text editor, and changing the variable holding the directory name.

Conflicts

All package managers, including Stow, are vulnerable to file name conflicts. Suppose you try to install Vim while New vi (Nvi) is already installed in /usr/local/. Both Vim and Nvi want to own the file /usr/local/bin/ex. Stow prints the following error:

stow: CONFLICT: /usr/local/stow/vim-7.0/bin/ex vs. /usr/local/bin/ex

You're lucky: if you hadn't been using Stow, Vim would have replaced Nvi's ex executable without asking you.

The simplest way to resolve such a conflict is to remove one of the involved packages. Alternatively, you may be able to keep both packages by selectively renaming files. But renaming files is a tricky business. Some programs depend on names to find other files or even to run themselves correctly. In this case, for instance, renaming ex will break it; Vim's ex expects to be called ex in order to start in ex mode.

You should be able to keep both packages by recompiling one of the packages with different file names. Running ./configure --help in Vim's source directory, for instance, we find the following three options:

--with-vim-name=NAME what to call the Vim executable --with-ex-name=NAME what to call the Ex executable --with-view-name=NAME what to call the View executable

Re-running ./configure with these options, changing each of the NAMEs to non-default values, re-running make, and re-running make install (with prefix=) will resolve the conflict.

Removing and upgrading packages

Removing a package with Stow requires two commands. As with installing a package, you start by changing to the /usr/local/stow/ directory. Then you run stow -D dirname on the directory holding the package you want to remove.

Stow looks in /usr/local/ for any symbolic links pointing to /usr/local/stow/dirname/ and removes them. Stow never removes or alters files in /usr/local/stow/ and its subdirectories; the files will still be there and taking up disk space. You can reinstall them if you want, or you can permanently delete them with rm.

In addition to letting you install and remove packages, Stow also lets you upgrade them by removing the old package and installing the new one. If you're not happy with the upgrade, you can reverse the process to uninstall the replacement and reinstall the original.

And what if you try Stow, and decide that it sucks? Remove it using your distribution's package manager, or remove it using stow -D stow. Removing Stow won't break your existing stowed packages; they'll continue to work.

Share    Print    Comments   

Comments

on Get rid of stowaway packages with GNU Stow

Note: Comments are owned by the poster. We are not responsible for their content.

Get rid of stows

Posted by: Michael Shigorin on February 22, 2008 10:50 AM
"If you decide a package sucks, how do you get rid of it?" -- apt-get remove (or rpm -e). Dave, learning (and educating) to build packages is way better an enterprise than spreading ill advice like "use stow/checkinstall/0install". It's way more reusable, and googling for %name.spec or looking for a similar package for its debian/rules is what might even spare one's time and not junk it within /usr/local.

PS: I maintain ~180 packages in ALT Linux and feel pretty comfortable with these. :)

#

Re: Get rid of stows

Posted by: Anonymous [ip: 127.0.0.1] on February 23, 2008 04:50 PM
I couldn't disagree more, Michael. I use Ubuntu at home, Debian at work for a production server, and OS X as my work desktop, and don't get me started on using Free Software on Windows. If I have a package that's not widely distributed for whatever reason (such as swftools) you can be sure that I'll be using stow. Building two different debian packages (one for Debian and Ubuntu, and whatever procedure Fink uses) isn't really an option in my opinion, and if something were to happen to where I had an RPM-based distribution forced on me, well, I've worked with the RPM specs before, but again, I'll be danged if I'm going to do cross-distribution package handling just to run a popular-yet-tainted software package.

Stow, on the other hand, is built for this sort of ad-hoc package management. Tell configure to install to a particular dir, stow it, and you're done.

#

Re: Get rid of stows

Posted by: Anonymous [ip: 80.108.103.172] on February 24, 2008 12:16 AM
What you write here is WRONG. As in, it is the WRONG approach because there are SIMPLER ones and they are more elegant. It also makes the community split up, because every distribution adds incompatibilities (where can you find config files? is it /etc/perl/ or is it /etc/perl_settings.xml ...)

Your way adds a layer upon the system. A needless layer. One that complicates everything.

How GoboLinux solves the issue at hand is a LOT more elegant. It comes extremely close to AppDirs.

After that you can add a package manager, but before that there is NO need at all to completely mess up your system with the traditional way Linux behaves (aka FHS)

#

Re: Get rid of stows

Posted by: Anonymous [ip: 198.182.208.51] on February 24, 2008 04:36 PM
In response to Michael who favors building packages: I try to minimize my dependence on any particular packaging system or distro-specific feature. I don't even want to invest valuable time in learning how to build RPM or Debian packages, because that knowledge is not portable.

I use my distro's packages to install a bare-bones system, and then install network services and security-sensitive software from their original developers' source code. It's somewhat more work, but it means if I need an update I don't have to hope for and wait for my distro to supply it. It also means that my installation of, say, Samba, has the behavior and layout described by Samba's own documentation, and by non-distro-specific aftermarket Samba books. My skills are relevant to any distro, not just the one I happen to be using today.

Building my own packages would be much more work for me, and would only reduce my flexibility.

I personally don't run into a need for something like Stow very often, but it certainly serves a real purpose and I'm glad to know about it; it's going in my toolbox for sure.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 86.121.210.167] on February 22, 2008 11:21 AM
I absolutely agree with Michael.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 87.211.83.27] on February 22, 2008 01:32 PM
Looks a bit like Gentoo to me. Much more powerful, and covers the whole system from the start. You could use 'emerge' or 'paludis' to install packages. Shure this is a package tostart with on a 'Linux from scratch' system, but other than that?....

For more information on gentoo: http://gentoo.org

#

Re: Get rid of stowaway packages with GNU Stow

Posted by: Dummy00001 on February 24, 2008 08:41 AM

... and on binary systems you can always use my usual trick:

$ mkdir ~/usr

$ ./configure --prefix=$HOME/usr

$ make install

Most software would work. Actually I haven't yet seen software which wouldn't.

Idea is simple: do NOT install packages onto whole system, keep them local to user(s). Doing all that from under user account has added bonus that no left stuff will be install where you do not want it.

If you need to customize packages often, then use Gentoo.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 64.9.232.163] on February 22, 2008 03:07 PM
These comments are absurd. Systems like stow are more general than package managers and are certainly valuable. I can't imagine never installing an autoconf package. apt-get install ion3, oh wait, it's not in Ubuntu or Debian's repo currently. Writing a deb pkg for it isn't a worthwhile endeavor for those of us that use source regularly.

#

Think beyond locally installed packages and think beyond Linux.

Posted by: Anonymous [ip: 129.33.49.251] on February 22, 2008 04:52 PM
The benefit to utilities like 'stow' and 'depot' becomes apparent when you cluster an application across multiple systems, or need to provide multiple versions of a given piece of software because multiple applications are served from the same system. In those circumstances it doesn't make sense to keep the packages locally, or to provide a means to administer the packages to inidividual chroot jails. If the environment isn't Linux (AIX, Solaris, and HPUX ), 'stow' and 'depot' can be less painful approaches than attempting to create native packages. 'EPM' works for those environments, but becomes a PITA when the native packager doesn't accept something like ':' in filenames and the package (Perl) likes them quite a lot.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 77.96.122.110] on February 22, 2008 05:46 PM
lol, chill man...

I'm a Linux newbie and I really welcome any article (such as this one) that is informative. Being a Windows user currently, the whole 'apt-get' / 'make install' thing is still somewhat of a mystery to me, as it's so different to what I'm familiar with in Windows (you just run an EXE file...).

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 75.70.237.86] on February 22, 2008 11:30 PM
I'm tired of hearing 'learn to build a proper package' (be sure to overlay that with a whiny geeky voice) . What a pompus wanker you are Michael. If it was that easy then all software would already be in your distros package format doncha think? For new users (and even those of us that are experienced users) what is better; 'make install' that tosses your package managers efforts right out the window or something like stow that DOES at least allow you to remove any software you've installed w/ make install? Let's also not forget that alot of software does not have a make uninstall option. I for one think checkinstall is great and now I will be further investigating stow thanks to this article. You can continue to live in your unrealiastic world where everyone knows how to builld packages because it's just soooo easy and intuitive.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 193.166.94.185] on February 23, 2008 02:25 AM
"the whole 'apt-get' / 'make install' thing is still somewhat of a mystery to me, as it's so different to what I'm familiar with in Windows (you just run an EXE file...)" --- No, you don't "just run an EXE file" in Windows. First, you need to spend a lot of time searching for a website that allows you to download the EXE file (supposing you want to install a freeware/shareware/adware/malware program that you can download free of charge). Then you download it and then you click it to start the installer. Then you have to accept the license and answer many other questions. Often you also need to reboot the computer to finish the installation. And if you want to keep your installed freeware/shareware/adware/malware programs up-to-date, you need to constantly monitor the dozens of websites from where you downloaded the programs in the first place. That's a lot of work. Installing programs with "apt-get install program_name" and upgrading them with "apt-get update && apt-get dist-upgrade" once a week is much simpler and easier, IMHO.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 85.183.32.58] on February 23, 2008 08:12 AM
There is a Unix package manager that does away with dependency problems - and has clean package removal and versioning. The name is NIX - see http://nix.cs.uu.nl/

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 72.53.89.42] on February 23, 2008 07:25 PM
A lightweight quasi-package manager for people inclined to work at the bleeding edge? I'm doing an apt-get to install stow right now. I have made rpms and I have made autoconf files from scratch and I can definitely see how this could be useful.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 82.225.152.22] on February 24, 2008 09:07 PM
hi,
this problem may also be solved with checkinstall : instead of "make install" you can "checkinstall [-D|-R] make install" which creates and installs the debian/rpm package.
has someone used it ? I'm quite glad with it.
michal

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 72.68.110.24] on February 25, 2008 01:31 PM
As a sometime stow user on Solaris and Linux systems, for those tough-to-resolve naming conflicts or when renaming conflicting package library names is not an option, I opt to create the /usr/local2 tree. Then add /usr/local2/bin to PATH and /usr/local2/lib to /etc/ld.so.conf, etc.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 84.81.162.166] on March 03, 2008 08:05 PM
One very nice thing that stow supports, is a multi-user system where every user can install the software himself in for example $HOME/stow/... (and add those directories to his PATH and MANPATH). Now the system administrator can easily install a new version, like /usr/local/stow/git-1.5.4.3 and leave /usr/local/stow/git-1.4 installed. The user can upgrade whenever it suits him, not when it suits the sysadmin. This is impossible with apt and rpm, where the user cannot do anything, and it is next to impossible to have multiple versions installed.

#

Get rid of stowaway packages with GNU Stow

Posted by: Anonymous [ip: 74.85.18.250] on March 19, 2008 02:34 AM
The people on here touting packages clearly don't understand the value of stow in and of itself. It's a necessary tool, and reminds of epkg from times back. When you need to keep versions of software that don't have packages written for them in a format that is easily removable at the drop of a hat, stow is excellent. Additionally, compile-time options that are critical evade the use of packages. I've went from building my own packages for years under Solaris, surviving RPM (horrible package management), and all of the various package setups for *nix-like OSes over the years.

Most package toolsets have things like fakeroot, etc that prior to building the actual package from the package installation directory, kind of do similar things... but it makes its way into an actual package format. Stow abstracts this idea, just like epkg did.

-- Ex-sysadmin

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya