Skip to content

Commit

Permalink
Discover last release.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed Feb 8, 2018
1 parent ca001a4 commit aedaac2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
31 changes: 24 additions & 7 deletions update-golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ case "$arch" in
;;
esac

show_version() {
msg version $version
}

show_version

find_latest() {
local last=
local fetch=
if hash wget 2>/dev/null; then
fetch="wget -qO-"
else
fetch="curl --silent"
fi
last=$($fetch https://golang.org/doc/devel/release.html | grep -E -o 'go[0-9\.]+' | grep -E -o '[0-9]\.[0-9]+(\.[0-9]+)?' | sort | uniq | tail -1)
if echo "$last" | grep -q -E '[0-9]\.[0-9]+(\.[0-9]+)?'; then
msg find_latest: found last release: "$last"
release=$last
fi
}
find_latest

[ -n "$SOURCE" ] && source=$SOURCE
[ -n "$DESTINATION" ] && destination=$DESTINATION
[ -n "$RELEASE" ] && release=$RELEASE
Expand Down Expand Up @@ -311,10 +333,6 @@ remove_old_install() {
fi
}

show_version() {
msg version $version
}

check_package() {
if hash dpkg 2>/dev/null && dpkg -s golang-go 2>/dev/null | grep ^Status | grep -q installed; then
msg warning: golang-go is installed, you should remove it: sudo apt remove golang-go
Expand Down Expand Up @@ -348,14 +366,13 @@ case "$1" in
;;
esac

show_version
show_vars | log_stdin
check_package

msg will install golang "$label" as: "$abs_goroot"

cd "$destination" || die could not enter destination="$destination"

msg will install golang "$label" as: "$abs_goroot"

download
remove_old_link
untar
Expand Down
2 changes: 1 addition & 1 deletion update-golang.sh.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
51e6a830828f12f089a21cdc45ab2eee5dc4d1cb73feb64aa75d9d0ad145b9ba update-golang.sh
e24ce7e0d2eda19dce857f5f2a9d54dba6b9cd156c27ea8d4a5817f437675b6c update-golang.sh

0 comments on commit aedaac2

Please sign in to comment.