-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added in support for Gitbash on Windows OS #31
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
############################################################################### | ||
# GENERATED VERSION! DO NOT CHANGE! # | ||
SCRIPTVERSION="local-dev" | ||
SCRIPTVERSION="latest" | ||
############################################################################### | ||
|
||
# Static variable definintions | ||
|
@@ -176,8 +176,15 @@ upgrade() { | |
curl -sL "$GVMURL" > .gvm.tmp | ||
|
||
# shellcheck disable=SC2002 | ||
DOWNLOADEDSUM=$(cat .gvm.tmp | shasum -a 256) | ||
|
||
# Gitbash/Windows certutil with explit sha256 can be used | ||
if [[ "$OSTYPE" == "msys"* ]] | ||
then | ||
DOWNLOADEDSUM=$(certutil -hashfile .gvm.tmp sha256 | tail -n2 | head -n1) | ||
else | ||
DOWNLOADEDSUM=$(cat .gvm.tmp | shasum -a 256) | ||
fi | ||
|
||
if [[ $DOWNLOADEDSUM != "$EXPECTEDSUM" ]] | ||
then | ||
printf "Checksum does not match new version of GVM [%s]\n" "$SCRIPTVERSION" | ||
|
@@ -226,7 +233,17 @@ update() { | |
EXPECTEDSUM=$(curl -sL "$SUMPATH") | ||
|
||
# shellcheck disable=SC2086 | ||
FILESUM=$(cat $0 | shasum -a 256) | ||
|
||
if [[ "$OSTYPE" == "msys"* ]] | ||
then | ||
FILESUM=$(certutil -hashfile $0 sha256 | tail -n2 | head -n1) | ||
EXPECTEDSUM=$(curl -sL "$SUMPATH" | sed 's/ -//') # ⚠️ additional 2xspace + dash may also need to be addressed on unix installs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was interesting as I noticed the additional spaces and dash being appended to $EXPECTEDSUM coming from the $SUMPATH request. I don't have a lot of experience in bash so this may be expected in the Unix environment. Specifically when using shasum. Just thought I'd call it out that I had to strip these appended characters in order to accurately compare the file downloaded to the expected checksum. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll look into this |
||
else | ||
FILESUM=$(cat $0 | shasum -a 256) | ||
EXPECTEDSUM=$(curl -sL "$SUMPATH") | ||
fi | ||
|
||
|
||
|
||
if [[ "$EXPECTEDSUM" != "Not Found" ]] | ||
then | ||
|
@@ -294,6 +311,7 @@ then | |
fi | ||
|
||
arch="amd64" | ||
extention=".tar.gz" | ||
if uname -a | grep "arm64"&> /dev/null | ||
then | ||
arch="arm64" | ||
|
@@ -306,6 +324,11 @@ then | |
elif [[ "$OSTYPE" == "linux"* ]] | ||
then | ||
os="linux" | ||
elif [[ "$OSTYPE" == "msys"* ]] | ||
then | ||
os="windows" | ||
arch="amd64" | ||
extention=".zip" | ||
elif [[ "$OSTYPE" == "freebsd"* ]] | ||
then | ||
os="freebsd" | ||
|
@@ -386,7 +409,8 @@ then | |
else | ||
if [[ ! -d "$versionroot" ]] | ||
then | ||
pkg="go$version.$os-$arch.tar.gz" | ||
|
||
pkg="go$version.$os-$arch$extention" | ||
url="$dlroot$pkg" | ||
pkgDir="$gvmroot/$pkg" | ||
|
||
|
@@ -407,10 +431,18 @@ else | |
fail "$(printf "Unable to create %s\n" "$versionroot")" | ||
fi | ||
|
||
if ! tar -C "$versionroot" -xzf "$pkgDir" | ||
then | ||
fail "$(printf "Unable to extract %s\n" "$pkgDir" rm -rf "$versionroot")" | ||
fi | ||
if [[ "$extention" == ".zip" ]] | ||
then | ||
if ! unzip -qd "$versionroot" "$pkgDir" | ||
then | ||
fail "$(printf "Unable to zip extract %s\n" "$pkgDir" rm -rf "$versionroot")" | ||
fi | ||
else | ||
if ! tar -C "$versionroot" -xzf "$pkgDir" | ||
then | ||
fail "$(printf "Unable to tar extract %s\n" "$pkgDir" rm -rf "$versionroot")" | ||
fi | ||
fi | ||
|
||
rm "$pkgDir" | ||
fi | ||
|
@@ -420,6 +452,14 @@ fi | |
lnsrc="$versionroot/go" | ||
|
||
printf "Updating symlink %s => %s\n" "$lnsrc" "$gvmroot" | ||
|
||
#Windows + Gitbash require an explicit delete of the previously linked folder | ||
if [[ "$os" == "windows" ]] | ||
then | ||
printf "Removing %s/go if the directory exists\n" "$gvmroot" | ||
rm -rf "$gvmroot/go" | ||
fi | ||
|
||
if ! ln -sf "$lnsrc" "$gvmroot" | ||
then | ||
fail "$(printf "Unable to symlink directory %s\n" "$lnsrc")" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update this to
local-dev
? The script version should belocal-dev
for changes. It's updated by the CI/CD pipeline to match the tagged version prior to generating the sum file for comparison on update.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Just updated in latest commit.