3 # Uninstaller script for GHC.framework
4 # (currently only for system volume installations)
6 INSTALL_DEST=/Library/Frameworks
9 if [ ${INSTALL_BASE} = / ]; then
12 INSTALL_BIN=${INSTALL_BASE}/bin
13 INSTALL_MAN1=${INSTALL_BASE}/share/man/man1
14 INSTALL_HTML=${INSTALL_BASE}/share/doc
16 if [ ! -x ${INSTALL_DEST}/GHC.framework ]; then
17 echo "${INSTALL_DEST}/GHC.framework does not exit"
21 if [ ${USER} != root ]; then
22 echo "GHC.framework installer must be run with admin privileges"
23 echo "Prefix command by 'sudo'"
27 VERSIONS=(`ls ${INSTALL_DEST}/GHC.framework/Versions`)
28 NO_VERSIONS=${#VERSIONS[@]}
30 if [ ${VERSIONS[${NO_VERSIONS}-1]} != Current ]; then
31 echo "Fatal error: last version should be Current"
32 echo "Found versions: ${VERSIONS[@]}"
35 CURRENT_PHYS=`cd /Library/Frameworks/GHC.framework/Versions/Current; pwd -P`
36 CURRENT=`basename ${CURRENT_PHYS}`
38 if [ ${NO_VERSIONS} -ne 2 ]; then
39 echo "Multiple versions of GHC.framework are currently installed."
40 echo "This uninstaller removes GHC.framework entirely and should only"
41 echo "be used if there is exactly one version."
43 echo "To remove individual old versions, simply delete the directory"
44 echo "${INSTALL_DEST}/GHC.framework/Versions/VERSION_TO_REMOVE"
46 echo "Found versions: ${VERSIONS[@]}(= ${CURRENT})"
50 echo "Removing symbolic links into GHC.framework"
51 for thisfile in ${INSTALL_BIN}/*; do
52 if ls -l "${thisfile}" | grep -q GHC.framework/Versions; then
56 for thisfile in ${INSTALL_MAN1}/*; do
57 if ls -l "${thisfile}" | grep -q GHC.framework/Versions; then
61 for thisfile in ${INSTALL_HTML}/*; do
62 if ls -l "${thisfile}" | grep -q GHC.framework/Versions; then
67 echo "Removing ${INSTALL_DEST}/GHC.framework"
68 rm -rf ${INSTALL_DEST}/GHC.framework
70 echo "Removing package recipt"
71 # The first is for Leopard packages and the second for Tiger packages.
72 rm -f /Library/Receipts/boms/org.haskell.glasgowHaskellCompiler.ghc.pkg.bom
73 rm -rf /Library/Receipts/ghc.pkg
75 echo "${INSTALL_DEST}/GHC.framework has been purged!"