Skip to content

Commit

Permalink
scripts working
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Baker committed Sep 15, 2024
1 parent a408519 commit 4d54b1d
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 10 deletions.
30 changes: 25 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

5 changes: 3 additions & 2 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions bin/help.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo ""
8 changes: 8 additions & 0 deletions bin/help.links
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
helplinks() {
echo "
Git Repository: https://github.com/ava-labs/avalanche-cli
"
}

helplinks
8 changes: 8 additions & 0 deletions bin/help.overview
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
helpoverview() {
echo "
The Avalanche CLI
"
}

helpoverview
2 changes: 1 addition & 1 deletion bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 11 additions & 0 deletions bin/uninstall
Original file line number Diff line number Diff line change
@@ -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
15 changes: 13 additions & 2 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down

0 comments on commit 4d54b1d

Please sign in to comment.