#!/bin/sh # Uninstaller script for GHC.framework # (currently only for system volume installations) INSTALL_DEST=/Library/Frameworks INSTALL_BASE=/ if [ ${INSTALL_BASE} = / ]; then INSTALL_BIN=/usr/bin else INSTALL_BIN=${INSTALL_BASE}/bin fi if [ ! -x ${INSTALL_DEST}/GHC.framework ]; then echo "${INSTALL_DEST}/GHC.framework does not exit" exit 1 fi if [ ${USER} != root ]; then echo "GHC.framework installer must be run with admin privileges" echo "Prefix command by 'sudo'" exit 1 fi VERSIONS=(`ls ${INSTALL_DEST}/GHC.framework/Versions`) NO_VERSIONS=${#VERSIONS[@]} if [ ${VERSIONS[${NO_VERSIONS}-1]} != Current ]; then echo "Fatal error: last version should be Current" echo "Found versions: ${VERSIONS[@]}" exit 1 fi CURRENT_PHYS=`cd /Library/Frameworks/GHC.framework/Versions/Current; pwd -P` CURRENT=`basename ${CURRENT_PHYS}` if [ ${NO_VERSIONS} -ne 2 ]; then echo "Multiple versions of GHC.framework are currently installed." echo "This uninstaller removes GHC.framework entirely and should only" echo "be used if there is exactly one version." echo echo "To remove individual old versions, simply delete the directory" echo "${INSTALL_DEST}/GHC.framework/Versions/VERSION_TO_REMOVE" echo echo "Found versions: ${VERSIONS[@]}(= ${CURRENT})" exit 1 fi echo "Removing symbolic links into GHC.framework" for thisfile in `ls ${INSTALL_BIN}`; do if ls -l ${INSTALL_BIN}/${thisfile} | grep -q GHC.framework/Versions; then rm -f ${INSTALL_BIN}/${thisfile} fi done echo "Removing ${INSTALL_DEST}/GHC.framework" rm -rf ${INSTALL_DEST}/GHC.framework echo "Removing package recipts" rm -f /Library/Receipts/boms/org.haskell.glasgowHaskellCompiler.ghc.pkg.bom rm -f /Library/Receipts/boms/org.haskell.glasgowHaskellCompiler.uninstaller.pkg echo "${INSTALL_DEST}/GHC.framework has been purged!"