From 6b378f538b10dd93a2b9fd041d1f23c4a3aeebe6 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 9 Dec 2024 16:53:05 +0100 Subject: [PATCH] chore(devops): Import setup command (#3864) # Motivation The setup command is a general purpose command for installing command line tools. # Changes - Copy the `scripts/setup` from the chain-fusion-signer codebase. - Use the `.sh` suffix to adhere to Oisy policy. # Tests The tool is exercised extensively elsewhere. The only adjustments are formatting and naming to match local policies. --- scripts/setup.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/setup.sh diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000000..0b06a9811f --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -euo pipefail + +for tool in "${@}"; do + echo "Installing '$tool'..." + export tool + install_method="$(jq -r '.[env.tool].method' dev-tools.json)" + echo " install_method: $install_method" + case "$install_method" in + "curl") + url="$(jq -r '.[env.tool].url' dev-tools.json)" + target="$HOME/.local/bin/$tool" + mkdir -p "$(dirname "$target")" + curl -Lf "$url" | install -m 755 /dev/stdin "$target" + ;; + "sh") + version="$(jq -r '.[env.tool].version' dev-tools.json)" "$0-$tool" + ;; + "cargo-install") + cargo install "$tool@$(jq -r '.[env.tool].version' dev-tools.json)" + ;; + "cargo-binstall") + cargo binstall --force --no-confirm "${tool}@$(jq -r '.[env.tool].version' dev-tools.json)" + ;; + "go") + GOBIN="$HOME/.local/bin" go install "$(jq -r '.[env.tool].source' dev-tools.json)@$(jq -r '.[env.tool].version' dev-tools.json)" + ;; + "snap") + sudo snap install "$tool" + ;; + *) + echo "ERROR: Unsupported install method '$install_method'" + exit 1 + ;; + esac +done