User:Benmachine/uninstall.sh

From HaskellWiki
< User:Benmachine
Revision as of 00:52, 6 September 2012 by Benmachine (talk | contribs) (New page: <code> #!/bin/bash -eu # Usage: ./uninstall.sh [--force | --no-unregister] pkgname # Specify the version as well! # if you set VER in the environment to e.g. "-7.0.1" you can use # the gh...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

  1. !/bin/bash -eu
  2. Usage: ./uninstall.sh [--force | --no-unregister] pkgname
  3. Specify the version as well!
  1. if you set VER in the environment to e.g. "-7.0.1" you can use
  2. the ghc-pkg associated with a different GHC version
${VER:=}

if [ "$1" == "--force" ] then force=--force; shift; # passed to ghc-pkg unregister else force= fi

if [ "$1" == "--no-unregister" ] then shift # skip unregistering and just delete files else

       if [ "$(ghc-pkg$VER latest $1)" != "$1" ]
       then    
               # full version not specified: list options and exit
               ghc-pkg$VER list $1; exit 1
       fi
       ghc-pkg$VER unregister $force $1

fi

  1. wipe library files

rm -rfv -- ~/.cabal/lib/$1/ghc-$(ghc$VER --numeric-version)/

  1. if the directory is left empty, i.e. not on any other GHC version

if rmdir -- ~/.cabal/lib/$1 then rm -rfv -- ~/.cabal/share/doc/$1 # then wipe the docs as well fi