From de9ceccb788eff720aa5eeee8ecb5f106fc69359 Mon Sep 17 00:00:00 2001 From: Joshua Bussdieker Date: Sun, 4 Mar 2012 18:01:08 -0800 Subject: [PATCH] More message cleanup --- scripts/function/display_warning | 7 +++++++ scripts/install | 28 ++++++++++++++-------------- scripts/uninstall | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 scripts/function/display_warning diff --git a/scripts/function/display_warning b/scripts/function/display_warning new file mode 100644 index 0000000..f0c475f --- /dev/null +++ b/scripts/function/display_warning @@ -0,0 +1,7 @@ +display_warning() { + # YELLOW! + tput sgr0 + tput setaf 3 + echo "$1" + tput sgr0 +} diff --git a/scripts/install b/scripts/install index f4e48c8..b04e687 100755 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,7 @@ read_command_line() { download_source() { GO_CACHE_PATH=$GVM_ROOT/archive/go [ -d $GO_CACHE_PATH ] && return - echo "Downloading Go source..." + display_message "Downloading Go source..." hg clone $GO_SOURCE_URL $GO_CACHE_PATH >> $GVM_ROOT/logs/go-download.log 2>&1 || display_error "Couldn't download Go source" } @@ -42,7 +42,7 @@ check_tag() { } update_source() { - echo "Updating Go source..." + display_message "Updating Go source..." hg pull -R $GO_CACHE_PATH >> $GVM_ROOT/logs/go-download.log 2>&1 || display_error "Couldn't get latest Go version info" } @@ -54,7 +54,7 @@ copy_source() { compile_go() { - echo " * Compiling..." + display_message " * Compiling..." unset GOARCH && unset GOOS && unset GOPATH && unset GOBIN && unset GOROOT && export GOBIN=$GO_INSTALL_ROOT/bin && export PATH=$GOBIN:$PATH && @@ -81,13 +81,17 @@ create_enviroment() { install_go() { GO_INSTALL_ROOT=$GVM_ROOT/gos/$version - trap 'rm -rf $GO_INSTALL_ROOT; display_error "Canceled!"' INT + #trap 'rm -rf $GO_INSTALL_ROOT; display_error "Canceled!"' INT # Check for existing install - [ -d $GO_INSTALL_ROOT ] && - display_error "Already installed!" + if [ -d $GO_INSTALL_ROOT ]; then + [ -f $GO_INSTALL_ROOT/manifest ] && + display_error "Already installed!" + display_warning "Removing corrupt install..." + gvm uninstall $version + fi - echo "Installing $version..." + display_message "Installing $version..." # Create the global package set folder mkdir -p $GVM_ROOT/pkgsets/$version >> $GVM_ROOT/logs/go-$version-install.log 2>&1 || @@ -99,7 +103,7 @@ install_go() { } install_gpkg() { - echo " * Installing gpkg..." + display_message " * Installing gpkg..." $GVM_GOINSTALL github.com/moovweb/gpkg > $GVM_ROOT/logs/$version-gpkg.log 2>&1 if [[ $? -ne 0 ]]; then echo "Failed to install gpkg" @@ -108,7 +112,7 @@ install_gpkg() { } install_gb() { - echo " * Installing gb..." + display_message " * Installing gb..." $GVM_GOINSTALL github.com/skelterjohn/go-gb/gb > $GVM_ROOT/logs/$version-gb.log 2>&1 if [[ $? -ne 0 ]]; then echo "Failed to install gb" @@ -117,7 +121,7 @@ install_gb() { } install_goprotobuf() { - echo " * Installing goprotobuf..." + display_message " * Installing goprotobuf..." $GVM_GOINSTALL goprotobuf.googlecode.com/hg/proto > $GVM_ROOT/logs/$version-pb-compiler.log 2>&1 if [[ $? -ne 0 ]]; then echo "Failed to install goprotobuf" @@ -136,9 +140,6 @@ install_goprotobuf() { main() { trap 'display_error "Canceled!"' INT read_command_line $@ - # GREEN! - tput sgr0 - tput setaf 2 [ -z $VERSION ] && display_error "No version specified" download_source check_tag || (update_source && check_tag) || display_error "Unrecognized Go version" @@ -153,7 +154,6 @@ main() { install_goprotobuf fi cd $GO_INSTALL_ROOT && find . > manifest - tput sgr0 } main $@ diff --git a/scripts/uninstall b/scripts/uninstall index ddb6439..b456c85 100755 --- a/scripts/uninstall +++ b/scripts/uninstall @@ -16,7 +16,7 @@ if [ -d $GVM_ROOT/gos/$fuzzy_match ]; then display_error "Couldn't remove pkgset environment files" rm -rf $GVM_ROOT/gos/$fuzzy_match &> /dev/null || display_error "Couldn't remove Go folder" - echo "Uninstalled version $fuzzy_match" + display_message "Uninstalled version $fuzzy_match" else display_error "Invalid version" fi