Register now and start sharing your code snippets.
-->

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

Shell Script (Bash) posted 6 months ago by marko

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

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

Installation

   1  cd /tmp
   2  wget http://kernel.org/pub/software/scm/git/git-1.5.5.1.tar.bz2
   3  tar xjvf git-1.5.5.1.tar.bz2
   4  sudo mv git-1.5.5.1 /usr/src
   5  sudo ln -s /usr/src/git-1.5.5.1 /usr/src/git
   6  cd /usr/src/git
   7  ./configure --prefix=/usr/local/stow/git
   8  make all doc
   9  sudo make install install-doc
  10  cd /usr/local/stow
  11  cat << EOF > /tmp/xstow.ini
  12  # this is the xtow configuration file
  13  # see xstow.ini(5) for details
  14  
  15  # list of links that will be handled as normal directories
  16  [traverse-links] 
  17  keep-targets = true      # add targets of the links to the keep-dirs section
  18  link = /usr/local/tmp
  19  link = /usr/local/var
  20  link = /usr/local/man
  21  link = /usr/local/share
  22  link = /usr/local/share/man
  23  link = /usr/local/doc
  24  link = /usr/local/info
  25  add-if-target = /*       # automatic add all absolute links
  26  
  27  # directories that never should be removed
  28  [keep-dirs]
  29  dir = /usr/local/bin
  30  dir = /usr/local/sbin
  31  dir = /usr/local/lib
  32  dir = /usr/local/include
  33  dir = /usr/local/share
  34  
  35  [matches]
  36  ignore = *~      # emacs
  37  ignore = core    # core file
  38  ignore = core.*  # new style
  39  ignore = CVS     # CVS directories
  40  ignore-regex = [0]+README.*
  41  
  42  # make other stow dirs public
  43  [stow-dirs]
  44  dir = /usr/local/local/stow
  45  dir = /usr/local/local/stow2
  46  
  47  [debug]
  48  module = ALL
  49  level  = 0
  50  
  51  [config-files]
  52  in-home = yes
  53  in-stow-dir = yes
  54  in-other-stow-dirs = yes
  55  file = /etc/xstow.ini
  56  file = /usr/local/local/etc/xstow.ini
  57  
  58  [links]
  59  absolute-paths = false
  60  EOF
  61  sudo mv -i /tmp/xstow.ini .
  62  sudo xstow git

Uninstallation

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

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

Tagged git, xstow, stow