Skip to content

Commit

Permalink
chore(devops): Import setup command (#3864)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
bitdivine authored Dec 9, 2024
1 parent 4b0a1f0 commit 6b378f5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6b378f5

Please sign in to comment.