summaryrefslogtreecommitdiff
path: root/distrib/MacOS/installer-scripts/Uninstaller.in
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/MacOS/installer-scripts/Uninstaller.in')
-rw-r--r--distrib/MacOS/installer-scripts/Uninstaller.in91
1 files changed, 91 insertions, 0 deletions
diff --git a/distrib/MacOS/installer-scripts/Uninstaller.in b/distrib/MacOS/installer-scripts/Uninstaller.in
new file mode 100644
index 0000000000..8774e07ad3
--- /dev/null
+++ b/distrib/MacOS/installer-scripts/Uninstaller.in
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+# Uninstaller script for GHC.framework
+# (currently only for system volume installations)
+
+INSTALL_DEST=/Library/Frameworks
+INSTALL_BASE=/
+
+# Turn off things that might make /usr/bin/ls give funky output
+unset CLICOLOR
+unset CLICOLOR_FORCE
+unset LSCOLORS
+
+if [ ${INSTALL_BASE} = / ]; then
+ INSTALL_BASE=/usr
+fi
+INSTALL_BIN=${INSTALL_BASE}/bin
+INSTALL_MAN1=${INSTALL_BASE}/share/man/man1
+INSTALL_HTML=${INSTALL_BASE}/share/doc
+
+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
+
+FRAMEWORK_DIRECTORY="$INSTALL_DEST/GHC.framework"
+VERSIONS_DIRECTORY="$FRAMEWORK_DIRECTORY/Versions"
+
+MY_VERSION=@ProjectVersion@-@TargetArch_CPP@
+MY_DIRECTORY="$VERSIONS_DIRECTORY/$MY_VERSION"
+
+CURRENT_DIRECTORY="$VERSIONS_DIRECTORY/Current"
+CURRENT_VERSION=`readlink "$CURRENT_DIRECTORY"`
+
+if [ "$CURRENT_VERSION" = "$MY_VERSION" ]
+then
+ rm -f "$CURRENT_DIRECTORY"
+
+ removeLinksFrom () {
+ for f in `ls -1 "$MY_DIRECTORY/$1"`
+ do
+ qf="$1/$f"
+ # Sanity check that it is a link like we expect
+ l=`readlink "$qf" | grep GHC.framework/Versions`
+ if [ "$l" != "" ]
+ then
+ rm -f "$qf"
+ fi
+ done
+ }
+
+ removeLinksFrom /usr/bin
+ removeLinksFrom /usr/share/man/man1
+ removeLinksFrom /usr/share/doc
+fi
+
+echo "Removing $MY_DIRECTORY"
+rm -rf "$MY_DIRECTORY"
+
+if [ "$CURRENT_VERSION" = "$MY_VERSION" ]
+then
+ # This isn't ideal, but it's a vague approximation to
+ # "the most recent version":
+ NEW_VERSION=`ls -1 "$VERSIONS_DIRECTORY" | tail -1`
+ if [ "$NEW_VERSION" = "" ]
+ then
+ echo "Removing $FRAMEWORK_DIRECTORY"
+ rm -rf "$FRAMEWORK_DIRECTORY"
+ else
+ ln -s "$NEW_VERSION" "$CURRENT_DIRECTORY"
+ NEW_CREATE_LINKS="$VERSIONS_DIRECTORY/$NEW_VERSION/Tools/create-links"
+ if [ -f "$NEW_CREATE_LINKS" ]
+ then
+ sh "$NEW_CREATE_LINKS"
+ fi
+ fi
+fi
+
+echo "Removing package receipt"
+# The first is for Leopard packages and the second for Tiger packages.
+rm -f "/Library/Receipts/boms/org.haskell.ghc.$MY_VERSION.bom"
+rm -rf "/Library/Receipts/ghc.$MY_VERSION.pkg"
+
+echo "Done."
+