Skip to content
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

Add support for msys2 on windows #92

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,25 @@ download_golang () {
local download_path=$2
local platform=""
local arch=""
local filetype="tar.gz"

platform=$(get_platform)
if [ "$platform" == "windows" ]; then
filetype="zip"
fi
arch=$(get_arch)
download_url="https://dl.google.com/go/go${version}.${platform}-${arch}.tar.gz"
download_url="https://dl.google.com/go/go${version}.${platform}-${arch}.${filetype}"

http_code=$(curl -I -w '%{http_code}' -s -o /dev/null "$download_url")
if [ "$http_code" -eq 404 ] || [ "$http_code" -eq 403 ]; then
fail "URL: ${download_url} returned status ${http_code}"
fi

curl "$download_url" -o "${download_path}/archive.tar.gz"
curl "${download_url}.sha256" -o "${download_path}/archive.tar.gz.sha256"
curl "$download_url" -o "${download_path}/archive.${filetype}"
curl "${download_url}.sha256" -o "${download_path}/archive.${filetype}.sha256"

echo 'verifying checksum'
if ! check_shasum "${download_path}/archive.tar.gz" "${download_path}/archive.tar.gz.sha256"; then
if ! check_shasum "${download_path}/archive.${filetype}" "${download_path}/archive.${filetype}.sha256"; then
fail "Authenticity of package archive can not be assured. Exiting."
else
msg "checksum verified"
Expand Down
8 changes: 6 additions & 2 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ install_golang () {
created_tmp="1"
ASDF_INSTALL_VERSION="$version" ASDF_DOWNLOAD_PATH="$download_path" "$PLUGIN_DIR/bin/download"
fi

tar -C "$install_path" -xzf "${download_path}/archive.tar.gz"

if [ "$(get_platform)" == "windows" ]; then
unzip -d "$install_path" "${download_path}/archive.zip"
else
tar -C "$install_path" -xzf "${download_path}/archive.tar.gz"
fi

if [ "1" = "$created_tmp" ]; then
rm -r "$download_path"
Expand Down
4 changes: 4 additions & 0 deletions lib/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ get_platform () {
platform="$(uname | tr '[:upper:]' '[:lower:]')"

case "$platform" in
msys_nt*)
platform="windows"
[ -z "$silent" ] && msg "Platform '${platform}' supported!"
;;
linux|darwin|freebsd)
[ -z "$silent" ] && msg "Platform '${platform}' supported!"
;;
Expand Down