From 84656a4c7bdff98dd7a18994698aef3e8f1bd548 Mon Sep 17 00:00:00 2001 From: Simon Let Date: Fri, 24 May 2019 00:20:26 +0200 Subject: [PATCH] install script update --- install.sh | 29 +++++++++++++++++------------ install_dep.sh | 5 +++++ 2 files changed, 22 insertions(+), 12 deletions(-) create mode 100755 install_dep.sh diff --git a/install.sh b/install.sh index 7de3907..458df80 100755 --- a/install.sh +++ b/install.sh @@ -1,13 +1,17 @@ #!/usr/bin/env bash -if ! go version 2>/dev/null; then +if ! go version &>/dev/null; then echo "Please install Golang and rerun this script" exit 1 fi go_version=$(go version | cut -d' ' -f3) -go_version_major=$(echo ${go_version:2} | cut -d'.' -f1) -go_version_minor=$(echo ${go_version:2} | cut -d'.' -f2) +go_version_major=$(echo "${go_version:2}" | cut -d'.' -f1) +go_version_minor=$(echo "${go_version:2}" | cut -d'.' -f2) + +# install_dep.sh installs to /tmp/gopath/bin +# add it to path just in case +PATH=/tmp/gopath/bin:$PATH if [ "$go_version_major" -gt 1 ]; then # good to go - future proof ;) @@ -17,17 +21,17 @@ elif [ "$go_version_major" -eq 1 ] && [ "$go_version_minor" -ge 11 ]; then # good to go - we have go modules echo "Building & installing ..." make install -elif dep version >/dev/null; then +elif dep version &>/dev/null; then if ! dep init; then - echo "`dep init` failed - bootstraping GOPATH ..." - export GOPATH=/tmp/gopath + echo "\`dep init\` failed - bootstraping GOPATH ..." + export GOPATH=$(mktemp /tmp/gopath-XXX) project_path=$GOPATH/src/github.com/curusarn/resh - mkdir -p $project_path - cp -rf . $project_path - cd $project_path + mkdir -p "$project_path" + cp -rf . "$project_path" + cd "$project_path" if ! dep init; then - echo "Unexpected ERROR while running `dep init`!" - echo "Try fixing it yourself - I'm sorry :(" + echo "Unexpected ERROR while running \`dep init\`!" + echo "Try running \`make install\`" exit 3 fi echo "Succesfuly bootstraped GOPATH" @@ -35,6 +39,7 @@ elif dep version >/dev/null; then echo "Building & installing ..." make install else - echo "Please install dep and rerun this script" + echo "Please update your Golang to version >= 1.11 OR install dep and rerun this script" + echo "If you have trouble installing dep you can run \`./install_dep.sh\` in this directory" exit 2 fi diff --git a/install_dep.sh b/install_dep.sh new file mode 100755 index 0000000..1fe9ed7 --- /dev/null +++ b/install_dep.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +export GOPATH=/tmp/gopath +mkdir $GOPATH/bin +curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh