From 65983695fb8e3b0ba0859f964ad0a41e3e4ca2c3 Mon Sep 17 00:00:00 2001 From: Tyler Bunnell Date: Thu, 28 Feb 2013 16:09:48 +1100 Subject: [PATCH] misc/dist: handle previous installation The installer package will now detect a previous installation and warn the user that the previous installation will be deleted. If the user continues, the installer will delete the previous installation and install the package as usual. Fixes #4293. R=adg CC=golang-dev https://golang.org/cl/7427044 --- misc/dist/darwin/Distribution | 8 +++++++- misc/dist/darwin/scripts/preinstall | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 misc/dist/darwin/scripts/preinstall diff --git a/misc/dist/darwin/Distribution b/misc/dist/darwin/Distribution index 1468a629a2..8b764b69f4 100644 --- a/misc/dist/darwin/Distribution +++ b/misc/dist/darwin/Distribution @@ -13,7 +13,13 @@ function installCheck() { my.result.type = 'Fatal'; return false; } - return true; + if(system.files.fileExistsAtPath('/usr/local/go/bin/go')) { + my.result.title = 'Previous Installation Detected'; + my.result.message = 'A previous installation of Go exists at /usr/local/go. This installer will remove the previous installation prior to installing. Please back up any data before proceeding.'; + my.result.type = 'Warning'; + return false; + } + return true; } diff --git a/misc/dist/darwin/scripts/preinstall b/misc/dist/darwin/scripts/preinstall new file mode 100644 index 0000000000..4cdaaa4bca --- /dev/null +++ b/misc/dist/darwin/scripts/preinstall @@ -0,0 +1,8 @@ +#!/bin/bash + +GOROOT=/usr/local/go + +echo "Removing previous installation" +if [ -d $GOROOT ]; then + rm -r $GOROOT +fi -- 2.48.1