Skip to content

Commit

Permalink
Option for debug.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed May 5, 2017
1 parent 3525470 commit 72882f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ before_install:

script:
- shellcheck -e SC2153 pre-commit sha256-update.sh update-golang.sh
- sudo ./update-golang.sh
- sudo ./update-golang.sh
- sudo DEBUG=1 ./update-golang.sh
- sudo DEBUG=1 ./update-golang.sh
- ls -al /usr/local
- sudo ./update-golang.sh remove
- sudo DEBUG=1 ./update-golang.sh remove
- ls -al /usr/local
25 changes: 19 additions & 6 deletions update-golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ msg() {
echo >&2 "$me": "$*"
}

debug() {
[ -n "$DEBUG" ] && msg debug: "$*"
}

log_stdin() {
while read -r i; do
msg "$i"
Expand Down Expand Up @@ -59,6 +63,7 @@ ARCH=$arch
PROFILED=$profiled
CACHE=$cache
GOPATH=$GOPATH
DEBUG=$DEBUG
EOF
}

Expand All @@ -84,11 +89,14 @@ die() {

solve() {
local path=$1
local p=
if echo "$path" | egrep -q ^/; then
echo "$path"
p="$path"
debug solve: "$p": `file "$p"`
else
echo "$save_dir/$path"
p="$save_dir/$path"
fi
echo "$p"
}

abs_filepath=$(solve "$filepath")
Expand Down Expand Up @@ -132,10 +140,15 @@ remove_old_link() {
[ -r "$abs_goroot" ] && die could not remove existing golang directory: "$abs_goroot"
}

rm_dir() {
local dir=$1
rm -r "$dir"
}

untar() {
if [ -d "$abs_new_install" ]; then
msg untar: rm -r "$abs_new_install"
rm -r "$abs_new_install" || die untar: could not remove: "$abs_new_install"
msg untar: rm_dir "$abs_new_install"
rm_dir "$abs_new_install" || die untar: could not remove: "$abs_new_install"
fi
[ -d "$PWD" ] || die untar: not a directory: "$PWD"
[ -w "$PWD" ] || die untar: unable to write: "$PWD"
Expand Down Expand Up @@ -231,7 +244,7 @@ remove_golang() {
msg remove: removing symlink: "$abs_goroot"
rm "$abs_goroot"
msg remove: removing dir: "$old_install"
rm -r "$old_install"
rm_dir "$old_install"
else
msg remove: not found symlink for old install
fi
Expand All @@ -244,7 +257,7 @@ remove_old_install() {
if [ "$abs_old_install" != "$abs_new_install" ]; then
# remove old install only if it actually changed
msg removing old install: "$abs_old_install"
rm -r "$abs_old_install"
rm_dir "$abs_old_install"
fi
fi
}
Expand Down
2 changes: 1 addition & 1 deletion update-golang.sh.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d92994f82de766ce6f5fd4d9d0d5cb8862ef538969c786729c01c482d3ff40a6 update-golang.sh
e19e63ac69f9ad78f25c4ff9164d54d8f3a31d64d9bde643ec0dbe176dfbe5a5 update-golang.sh

0 comments on commit 72882f4

Please sign in to comment.