stow snippets

Installing git without getting screwed over when it's time to uninstall, upgrade or install package maintainer's version

Tagged git, xstow, stow  Languages bash

Although Git is one of the better source code managers it has a major drawback if you need to install it from the sources - it's makefile doesn't have an uninstall target as defined in the GNU coding standards. Therefore you might find your system screwed over when you want to uninstall or upgrade after installing from sources. This is a workaround that is sufficient enough to make me break my rule of not installing software outside of package management.

Also see the snippet for an alias for the make command first.

Prequisities

sudo apt-get install asciidoc xsltproc xmlto xstow bzip2 build-essential zlib1g-dev tcl8.4

Installation

cd /tmp
wget http://kernel.org/pub/software/scm/git/git-1.5.5.1.tar.bz2
tar xjvf git-1.5.5.1.tar.bz2
sudo mv git-1.5.5.1 /usr/src
sudo ln -s /usr/src/git-1.5.5.1 /usr/src/git
cd /usr/src/git
./configure --prefix=/usr/local/stow/git
make all doc
sudo make install install-doc
cd /usr/local/stow
cat << EOF > /tmp/xstow.ini
# this is the xtow configuration file
# see xstow.ini(5) for details

# list of links that will be handled as normal directories
[traverse-links] 
keep-targets = true      # add targets of the links to the keep-dirs section
link = /usr/local/tmp
link = /usr/local/var
link = /usr/local/man
link = /usr/local/share
link = /usr/local/share/man
link = /usr/local/doc
link = /usr/local/info
add-if-target = /*       # automatic add all absolute links

# directories that never should be removed
[keep-dirs]
dir = /usr/local/bin
dir = /usr/local/sbin
dir = /usr/local/lib
dir = /usr/local/include
dir = /usr/local/share

[matches]
ignore = *~      # emacs
ignore = core    # core file
ignore = core.*  # new style
ignore = CVS     # CVS directories
ignore-regex = [0]+README.*

# make other stow dirs public
[stow-dirs]
dir = /usr/local/local/stow
dir = /usr/local/local/stow2

[debug]
module = ALL
level  = 0

[config-files]
in-home = yes
in-stow-dir = yes
in-other-stow-dirs = yes
file = /etc/xstow.ini
file = /usr/local/local/etc/xstow.ini

[links]
absolute-paths = false
EOF
sudo mv -i /tmp/xstow.ini .
sudo xstow git

Uninstallation

cd /usr/local/xstow
xstow -D git
sudo rm -rf /usr/local/stow/git

Kind of makes one appreciate the work done by package maintainers, doesn't it?