Personal tools

User:Benmachine/uninstall.sh

From HaskellWiki

< User:Benmachine(Difference between revisions)
Jump to: navigation, search
(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...)
 
 
Line 1: Line 1:
<code>
+
<pre>
 
#!/bin/bash -eu
 
#!/bin/bash -eu
 
# Usage: ./uninstall.sh [--force | --no-unregister] pkgname
 
# Usage: ./uninstall.sh [--force | --no-unregister] pkgname
Line 31: Line 31:
 
then rm -rfv -- ~/.cabal/share/doc/$1 # then wipe the docs as well
 
then rm -rfv -- ~/.cabal/share/doc/$1 # then wipe the docs as well
 
fi
 
fi
</code>
+
</pre>

Latest revision as of 00:53, 6 September 2012

#!/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 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

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

# 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