Trying Stow

Today transzorp in the #snort-gui channel convinced me to try Stow (sysutils/stow), described as "a program for managing the installation of software packages, keeping them separate (/usr/local/stow/emacs vs. /usr/local/stow/perl, for example) while making them appear to be installed in the same place (/usr/local)."

First I installed the Stow package and made a directory.

# setenv PACKAGESITE ftp://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest/
orr:/root# pkg_add -vr stow
# mkdir /usr/local/stow

Here is running Stow with no switches.

$ stow
stow: No packages named
stow (GNU Stow) version 1.3.3

Usage: stow [OPTION ...] PACKAGE ...
-n, --no Do not actually make changes
-c, --conflicts Scan for conflicts, implies -n
-d DIR, --dir=DIR Set stow dir to DIR (default is current dir)
-t DIR, --target=DIR Set target to DIR (default is parent of stow dir)
-v, --verbose[=N] Increase verboseness (levels are 0,1,2,3;
-v or --verbose adds 1; --verbose=N sets level)
-D, --delete Unstow instead of stow
-R, --restow Restow (like stow -D followed by stow)
-V, --version Show Stow version number
-h, --help Show this help

Next I tested Stow while installing Tcpxtract (which was recently added to the FreeBSD ports tree, but I'll just install the source code here).

$ tar -xzf tcpxtract-1.0.1.tar.gz
$ cd tcpxtract-1.0.1
$ ./configure --prefix=/usr/local/stow/tcpxtract-1.0.1
$ make
$ sudo make install
test -z "/usr/local/stow/tcpxtract-1.0.1/bin" || /home/richard/tcpxtract-1.0.1/install-sh -d
"/usr/local/stow/tcpxtract-1.0.1/bin"
/usr/bin/install -c 'tcpxtract' '/usr/local/stow/tcpxtract-1.0.1/bin/tcpxtract'
test -z "/usr/local/stow/tcpxtract-1.0.1/etc" || /home/richard/tcpxtract-1.0.1/install-sh -d
"/usr/local/stow/tcpxtract-1.0.1/etc"
/usr/bin/install -c -m 644 'tcpxtract.conf' '/usr/local/stow/tcpxtract-1.0.1/etc/tcpxtract.conf'
test -z "/usr/local/stow/tcpxtract-1.0.1/man/man1" || /home/richard/tcpxtract-1.0.1/install-sh -d
"/usr/local/stow/tcpxtract-1.0.1/man/man1"
/usr/bin/install -c -m 644 './tcpxtract.1' '/usr/local/stow/tcpxtract-1.0.1/man/man1/tcpxtract.1'
$ cd /usr/local/stow
$ sudo stow tcpxtract-1.0.1
stow: CONFLICT: /usr/local/stow/tcpxtract-1.0.1/bin/tcpxtract vs. /usr/local/bin/tcpxtract

What's that? Oh, I forgot I already installed Tcpxtract on this box, in /usr/local/src/, so I have to remove that for Stow to work.

$ cd /usr/local/src/tcpxtract-1.0.1
$ sudo make uninstall
rm -f '/usr/local/bin/tcpxtract'
rm -f '/usr/local/man/man1/tcpxtract.1'
rm -f '/usr/local/etc/tcpxtract.conf'

Now I can Stow Tcpxtract.

$ cd /usr/local/stow
$ sudo stow tcpxtract-1.0.1
$ cd tcpxtract-1.0.1/
$ ls -alR
total 10
drwxr-xr-x 5 root wheel 512 Jan 9 16:58 .
drwxr-xr-x 3 root wheel 512 Jan 9 16:58 ..
drwxr-xr-x 2 root wheel 512 Jan 9 16:58 bin
drwxr-xr-x 2 root wheel 512 Jan 9 16:58 etc
drwxr-xr-x 3 root wheel 512 Jan 9 16:58 man

./bin:
total 58
drwxr-xr-x 2 root wheel 512 Jan 9 16:58 .
drwxr-xr-x 5 root wheel 512 Jan 9 16:58 ..
-rwxr-xr-x 1 root wheel 54923 Jan 9 16:58 tcpxtract

./etc:
total 8
drwxr-xr-x 2 root wheel 512 Jan 9 16:58 .
drwxr-xr-x 5 root wheel 512 Jan 9 16:58 ..
-rw-r--r-- 1 root wheel 2764 Jan 9 16:58 tcpxtract.conf

./man:
total 6
drwxr-xr-x 3 root wheel 512 Jan 9 16:58 .
drwxr-xr-x 5 root wheel 512 Jan 9 16:58 ..
drwxr-xr-x 2 root wheel 512 Jan 9 16:58 man1

./man/man1:
total 6
drwxr-xr-x 2 root wheel 512 Jan 9 16:58 .
drwxr-xr-x 3 root wheel 512 Jan 9 16:58 ..
-rw-r--r-- 1 root wheel 1036 Jan 9 16:58 tcpxtract.1

Tcpxtract is now installed.

$ which tcpxtract
/usr/local/bin/tcpxtract
$ ls -al /usr/local/bin/tcpxtract
lrwxr-xr-x 1 root wheel 37 Jan 9 17:04 /usr/local/bin/tcpxtract ->
../stow/tcpxtract-1.0.1/bin/tcpxtract

To remove Tcpxtract, I do this in the /usr/local/stow directory:

$ sudo stow -D tcpxtract-1.0.1/
$ which tcpxtract

To reinstall, it's easy:

$ stow -R tcpxtract-1.0.1
$ which tcpxtract
/usr/local/bin/tcpxtract

transzorp says "I use Stow to upgrade sensors... I just build the latest software into new dirs under /usr/local/stow and then do a stow -D followed by a stow package-new.version."

I plan to see how best I can use this software when handling source code.

Comments

Anonymous said…
Stow is also a really good package management system for unprivileged user accounts. It allows you to keep track of package versions without ever leaving $HOME or using the root account.

Popular posts from this blog

Zeek in Action Videos

MITRE ATT&CK Tactics Are Not Tactics

New Book! The Best of TaoSecurity Blog, Volume 4