diff --git a/Makefile b/Makefile index c929e51..486943b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,25 @@ -test: - bin/list-all - ASDF_DOWNLOAD_PATH=./data/download \ - ASDF_INSTALL_VERSION=$$(bin/list-all | tr ' ' "\n" | tail -1) \ - bin/download +.DEFAULT_GOAL := all + +ASDF_INSTALL_VERSION ?= $(shell bin/list-all | tr ' ' "\n" | tail -1) +ASDF_DOWNLOAD_PATH ?= ./data/download/$(ASDF_INSTALL_VERSION) +ASDF_INSTALL_TYPE ?= version +ASDF_INSTALL_PATH ?= ./data/install/$(ASDF_INSTALL_VERSION) + +export ASDF_DOWNLOAD_PATH ASDF_INSTALL_PATH ASDF_INSTALL_TYPE ASDF_INSTALL_VERSION + +download-clean: + rm -rf ./data/download/* + +download: + bin/download + +install: + bin/install + +uninstall: + bin/uninstall + +clean: download-clean + +all: clean download install + diff --git a/bin/download b/bin/download index c11ee53..a991b38 100755 --- a/bin/download +++ b/bin/download @@ -17,7 +17,8 @@ release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz" download_release "$ASDF_INSTALL_VERSION" "$release_file" # Extract contents of tar.gz file into the download directory -tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file" +#tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file" +tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=0 avalanche || fail "Could not extract $release_file" # Remove the tar.gz file since we don't need to keep it -rm "$release_file" +rm -rf "$release_file" diff --git a/bin/help.deps b/bin/help.deps new file mode 100644 index 0000000..eb7663b --- /dev/null +++ b/bin/help.deps @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "" diff --git a/bin/help.links b/bin/help.links new file mode 100755 index 0000000..f1d5164 --- /dev/null +++ b/bin/help.links @@ -0,0 +1,8 @@ +#!/bin/bash +helplinks() { + echo " + Git Repository: https://github.com/ava-labs/avalanche-cli + " +} + +helplinks diff --git a/bin/help.overview b/bin/help.overview new file mode 100755 index 0000000..e090ec5 --- /dev/null +++ b/bin/help.overview @@ -0,0 +1,8 @@ +#!/bin/bash +helpoverview() { + echo " + The Avalanche CLI + " +} + +helpoverview diff --git a/bin/install b/bin/install index 6ca759a..83a0c28 100755 --- a/bin/install +++ b/bin/install @@ -5,7 +5,7 @@ set -euo pipefail current_script_path=${BASH_SOURCE[0]} plugin_dir=$(dirname "$(dirname "$current_script_path")") -# shellcheck source=./lib/utils.bash +#shellcheck source=./lib/utils.bash source "${plugin_dir}/lib/utils.bash" install_version "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" diff --git a/bin/uninstall b/bin/uninstall new file mode 100755 index 0000000..d6f499a --- /dev/null +++ b/bin/uninstall @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +current_script_path=${BASH_SOURCE[0]} +plugin_dir=$(dirname "$(dirname "$current_script_path")") + +# shellcheck source=./lib/utils.bash +# source "${plugin_dir}/lib/utils.bash" + +rm -rf $ASDF_INSTALL_PATH diff --git a/lib/utils.bash b/lib/utils.bash index 542ce3b..885545c 100755 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -42,9 +42,20 @@ download_release() { filename="$2" # TODO: Adapt the release URL convention for avalanche-cli - url="$GH_REPO/archive/v${version}.tar.gz" + #url="$GH_REPO/archive/v${version}.tar.gz" + arch="" + case $(uname -m) in + i386 | i686) arch="386" ;; + x86_64) arch="amd64" ;; + arm) dpkg --print-arch | grep -q "arm64" && arch="arm64" || arch="arm" ;; + esac + os="linux" + if [[ -n "$(uname -a | grep Darwin)" ]]; then + os="darwin" + fi + url="$GH_REPO/releases/download/v${version}/avalanche-cli_${version}_${os}_${arch}.tar.gz" - echo "* Downloading $TOOL_NAME release $version..." + echo "* Downloading $TOOL_NAME release $version" curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url" }