Manage package info as JSON

This commit is contained in:
Taiki Endo
2022-12-24 21:49:18 +09:00
parent 830660609d
commit f1683d2c7c
31 changed files with 1152 additions and 360 deletions

546
main.sh
View File

@@ -30,10 +30,33 @@ warn() {
info() {
echo "info: $*"
}
download() {
download_and_checksum() {
local url="$1"
local bin_dir="$2"
local bin="$3"
local checksum="$2"
if [[ -z "${enable_checksum}" ]]; then
checksum=""
fi
info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" -o tmp
if [[ -n "${checksum}" ]]; then
info "verifying sha256 checksum for $(basename "${url}")"
echo "${checksum} *tmp" >tmp.sha256sum
if type -P sha256sum &>/dev/null; then
sha256sum -c tmp.sha256sum >/dev/null
elif type -P shasum &>/dev/null; then
# GitHub-hosted macOS runner does not install GNU Coreutils by default.
# https://github.com/actions/runner-images/issues/90
shasum -a 256 -c tmp.sha256sum >/dev/null
else
bail "checksum requires 'sha256sum' or 'shasum' command; consider installing one of them or setting 'checksum' input option to 'false'"
fi
fi
}
download_and_extract() {
local url="$1"
local checksum="$2"
local bin_dir="$3"
local bin_in_archive="$4" # path to bin in archive
if [[ "${bin_dir}" == "/usr/"* ]]; then
if [[ ! -d "${bin_dir}" ]]; then
bin_dir="${HOME}/.install-action/bin"
@@ -44,6 +67,9 @@ download() {
fi
fi
fi
local installed_bin
installed_bin="${bin_dir}/$(basename "${bin_in_archive}")"
local tar_args=()
case "${url}" in
*.tar.gz | *.tgz) tar_args+=("xzf") ;;
@@ -70,32 +96,100 @@ download() {
debian | alpine | fedora) sys_install unzip ;;
esac
fi
mkdir -p .install-action-tmp
(
cd .install-action-tmp
info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" -o tmp.zip
unzip tmp.zip
mv "${bin}" "${bin_dir}/"
)
rm -rf .install-action-tmp
return 0
;;
*) bail "unrecognized archive format '${url}' for ${tool}" ;;
esac
tar_args+=("-")
local components
components=$(tr <<<"${bin}" -cd '/' | wc -c)
if [[ "${components}" != "0" ]]; then
tar_args+=(--strip-components "${components}")
mkdir -p "${tmp_dir}"
(
cd "${tmp_dir}"
download_and_checksum "${url}" "${checksum}"
if [[ ${#tar_args[@]} -gt 0 ]]; then
tar_args+=("tmp")
local components
components=$(tr <<<"${bin_in_archive}" -cd '/' | wc -c)
if [[ "${components}" != "0" ]]; then
tar_args+=(--strip-components "${components}")
fi
tar "${tar_args[@]}" -C "${bin_dir}" "${bin_in_archive}"
else
case "${url}" in
*.zip)
unzip tmp
mv "${bin_in_archive}" "${bin_dir}/"
;;
*) mv tmp "${installed_bin}" ;;
esac
fi
)
rm -rf "${tmp_dir}"
case "${host_os}" in
linux | macos)
if [[ ! -x "${installed_bin}" ]]; then
chmod +x "${installed_bin}"
fi
;;
esac
}
read_manifest() {
local tool="$1"
local version="$2"
local manifest
manifest=$(jq -r ".\"${version}\"" "${manifest_dir}/${tool}.json")
local download_info
case "${host_os}" in
linux)
# Static-linked binaries compiled for linux-musl will also work on linux-gnu systems and are
# usually preferred over linux-gnu binaries because they can avoid glibc version issues.
# (rustc enables statically linking for linux-musl by default, except for mips.)
download_info=$(jq <<<"${manifest}" -r ".${host_arch}_linux_musl")
if [[ "${download_info}" == "null" ]]; then
# Even if host_env is musl, we won't issue an error here because it seems that in
# some cases linux-gnu binaries will work on linux-musl hosts.
# https://wiki.alpinelinux.org/wiki/Running_glibc_programs
# TODO: However, a warning may make sense.
download_info=$(jq <<<"${manifest}" -r ".${host_arch}_linux_gnu")
elif [[ "${host_env}" == "gnu" ]]; then
case "${tool}" in
cargo-nextest | nextest)
# musl build of nextest is slow, so use glibc build if host_env is gnu.
# https://github.com/taiki-e/install-action/issues/13
download_info=$(jq <<<"${manifest}" -r ".${host_arch}_linux_gnu")
;;
esac
fi
;;
macos | windows)
# Binaries compiled for x86_64 macOS will usually also work on aarch64 macOS.
# Binaries compiled for x86_64 Windows will usually also work on aarch64 Windows 11+.
download_info=$(jq <<<"${manifest}" -r ".${host_arch}_${host_os}")
if [[ "${download_info}" == "null" ]] && [[ "${host_arch}" != "x86_64" ]]; then
download_info=$(jq <<<"${manifest}" -r ".download_info.x86_64_${host_os}")
fi
;;
*) bail "unsupported OS type '${host_os}' for ${tool}" ;;
esac
if [[ "${download_info}" == "null" ]]; then
bail "${tool}@${version} for '${host_os}' is not supported"
fi
info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" \
| tar "${tar_args[@]}" -C "${bin_dir}" "${bin}"
url=$(jq <<<"${download_info}" -r '.url')
checksum=$(jq <<<"${download_info}" -r '.checksum')
bin_dir=$(jq <<<"${download_info}" -r '.bin_dir')
bin_in_archive=$(jq <<<"${download_info}" -r '.bin')
if [[ "${bin_dir}" == "null" ]]; then
bin_dir="${cargo_bin}"
fi
if [[ "${bin_in_archive}" == "null" ]]; then
bin_in_archive="${tool}${exe}"
fi
}
download_from_manifest() {
read_manifest "$@"
download_and_extract "${url}" "${checksum}" "${bin_dir}" "${bin_in_archive}"
}
install_cargo_binstall() {
# https://github.com/cargo-bins/cargo-binstall/releases
local binstall_version="0.18.1"
local binstall_version
binstall_version=$(jq -r '.latest.version' "${manifest_dir}/cargo-binstall.json")
local install_binstall='1'
if [[ -f "${cargo_bin}/cargo-binstall${exe}" ]]; then
if [[ "$(cargo binstall -V)" == "cargo-binstall ${binstall_version}" ]]; then
@@ -109,16 +203,7 @@ install_cargo_binstall() {
if [[ -n "${install_binstall}" ]]; then
info "installing cargo-binstall"
base_url="https://github.com/cargo-bins/cargo-binstall/releases/download/v${binstall_version}/cargo-binstall"
case "${OSTYPE}" in
linux*) url="${base_url}-${host_arch}-unknown-linux-musl.tgz" ;;
darwin*) url="${base_url}-${host_arch}-apple-darwin.zip" ;;
cygwin* | msys*) url="${base_url}-x86_64-pc-windows-msvc.zip" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for cargo-binstall" ;;
esac
download "${url}" "${cargo_bin}" "cargo-binstall${exe}"
download_from_manifest "cargo-binstall" "latest"
info "cargo-binstall installed at $(type -P "cargo-binstall${exe}")"
x cargo binstall -V
fi
@@ -198,6 +283,7 @@ if [[ $# -gt 0 ]]; then
fi
export DEBIAN_FRONTEND=noninteractive
manifest_dir="$(dirname "$0")/manifests"
# Inputs
tool="${INPUT_TOOL:-}"
@@ -206,6 +292,13 @@ if [[ -n "${tool}" ]]; then
while read -rd,; do tools+=("${REPLY}"); done <<<"${tool},"
fi
enable_checksum="${INPUT_CHECKSUM:-}"
case "${enable_checksum}" in
true) ;;
false) enable_checksum='' ;;
*) bail "'checksum' input option must be 'true' or 'false': '${enable_checksum}'" ;;
esac
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
case "$(uname -m)" in
aarch64 | arm64) host_arch="aarch64" ;;
@@ -226,8 +319,9 @@ case "$(uname -m)" in
esac
base_distro=""
exe=""
case "${OSTYPE}" in
linux*)
case "$(uname -s)" in
Linux)
host_os=linux
host_env="gnu"
if (ldd --version 2>&1 || true) | grep -q 'musl'; then
host_env="musl"
@@ -260,17 +354,32 @@ case "${OSTYPE}" in
;;
esac
;;
cygwin* | msys*) exe=".exe" ;;
Darwin) host_os=macos ;;
MINGW* | MSYS* | CYGWIN* | Windows_NT)
host_os=windows
exe=".exe"
;;
*) bail "unrecognized OS type '$(uname -s)'" ;;
esac
tmp_dir="${HOME}/.install-action/tmp"
cargo_bin="${CARGO_HOME:-"${HOME}/.cargo"}/bin"
if [[ ! -d "${cargo_bin}" ]]; then
cargo_bin=/usr/local/bin
fi
if ! type -P curl &>/dev/null || ! type -P tar &>/dev/null; then
if ! type -P jq &>/dev/null || ! type -P curl &>/dev/null || ! type -P tar &>/dev/null; then
case "${base_distro}" in
debian | alpine | fedora) sys_install ca-certificates curl tar ;;
debian | alpine) sys_install ca-certificates curl jq tar ;;
fedora)
if [[ "${dnf}" == "yum" ]]; then
# On RHEL7-based distribution jq requires EPEL
sys_install ca-certificates curl tar epel-release
sys_install jq --enablerepo=epel
else
sys_install ca-certificates curl jq tar
fi
;;
esac
fi
@@ -284,154 +393,10 @@ for tool in "${tools[@]}"; do
version="latest"
fi
tool="${tool%@*}"
bin="${tool}${exe}"
info "installing ${tool}@${version}"
case "${tool}" in
cargo-hack | cargo-llvm-cov | cargo-minimal-versions | parse-changelog)
case "${tool}" in
# https://github.com/taiki-e/cargo-hack/releases
cargo-hack) latest_version="0.5.24" ;;
# https://github.com/taiki-e/cargo-llvm-cov/releases
cargo-llvm-cov) latest_version="0.5.3" ;;
# https://github.com/taiki-e/cargo-minimal-versions/releases
cargo-minimal-versions) latest_version="0.1.8" ;;
# https://github.com/taiki-e/parse-changelog/releases
parse-changelog) latest_version="0.5.2" ;;
*) exit 1 ;;
esac
repo="taiki-e/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in
linux*) target="${host_arch}-unknown-linux-musl" ;;
darwin*) target="${host_arch}-apple-darwin" ;;
cygwin* | msys*)
case "${tool}" in
cargo-llvm-cov) target="x86_64-pc-windows-msvc" ;;
*) target="${host_arch}-pc-windows-msvc" ;;
esac
;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz"
download "${url}" "${cargo_bin}" "${tool}${exe}"
;;
cargo-udeps)
# https://github.com/est31/cargo-udeps/releases
latest_version="0.1.35"
repo="est31/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}"
case "${OSTYPE}" in
linux*)
target="x86_64-unknown-linux-gnu"
url="${base_url}-${target}.tar.gz"
;;
darwin*)
target="x86_64-apple-darwin"
url="${base_url}-${target}.tar.gz"
;;
cygwin* | msys*)
target="x86_64-pc-windows-msvc"
url="${base_url}-${target}.zip"
;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
# leading `./` is required for cargo-udeps to work
download "${url}" "${cargo_bin}" "./${tool}-v${version}-${target}/${tool}${exe}"
;;
cargo-valgrind)
# https://github.com/jfrimmel/cargo-valgrind/releases
latest_version="2.1.0"
repo="jfrimmel/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-${version}"
case "${OSTYPE}" in
linux*)
target="x86_64-unknown-linux-musl"
url="${base_url}-${target}.tar.gz"
;;
darwin*)
target="x86_64-apple-darwin"
url="${base_url}-${target}.tar.gz"
;;
cygwin* | msys*)
target="x86_64-pc-windows-msvc"
url="${base_url}-${target}.zip"
;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
download "${url}" "${cargo_bin}" "${tool}${exe}"
;;
cargo-deny)
# https://github.com/EmbarkStudios/cargo-deny/releases
latest_version="0.13.5"
repo="EmbarkStudios/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;;
darwin*) target="${host_arch}-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
url="https://github.com/${repo}/releases/download/${version}/${tool}-${version}-${target}.tar.gz"
download "${url}" "${cargo_bin}" "${tool}-${version}-${target}/${tool}${exe}"
;;
cross)
# https://github.com/cross-rs/cross/releases
latest_version="0.2.4"
repo="cross-rs/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;;
darwin*) target="x86_64-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
case "${version}" in
0.1.* | 0.2.[0-1]) url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}-${target}.tar.gz" ;;
*) url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz" ;;
esac
download "${url}" "${cargo_bin}" "${tool}${exe}"
;;
nextest | cargo-nextest)
bin="cargo-nextest"
# https://nexte.st/book/pre-built-binaries.html
case "${OSTYPE}" in
linux*)
# musl build of nextest is slow, so use glibc build if host_env is gnu.
# https://github.com/taiki-e/install-action/issues/13
case "${host_env}" in
gnu) url="https://get.nexte.st/${version}/linux" ;;
*) url="https://get.nexte.st/${version}/linux-musl" ;;
esac
;;
darwin*) url="https://get.nexte.st/${version}/mac" ;;
cygwin* | msys*) url="https://get.nexte.st/${version}/windows-tar" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" \
| tar xzf - -C "${cargo_bin}"
;;
protoc)
# https://github.com/protocolbuffers/protobuf/releases
latest_version="3.21.12"
repo="protocolbuffers/protobuf"
case "${version}" in
latest) version="${latest_version}" ;;
esac
miner_patch_version="${version#*.}"
base_url="https://github.com/${repo}/releases/download/v${miner_patch_version}/protoc-${miner_patch_version}"
read_manifest "protoc" "${version}"
# Copying files to /usr/local/include requires sudo, so do not use it.
bin_dir="${HOME}/.install-action/bin"
include_dir="${HOME}/.install-action/include"
@@ -441,109 +406,38 @@ for tool in "${tools[@]}"; do
echo "${bin_dir}" >>"${GITHUB_PATH}"
export PATH="${PATH}:${bin_dir}"
fi
case "${OSTYPE}" in
linux*) url="${base_url}-linux-${host_arch/aarch/aarch_}.zip" ;;
darwin*) url="${base_url}-osx-${host_arch/aarch/aarch_}.zip" ;;
cygwin* | msys*) url="${base_url}-win64.zip" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
if ! type -P unzip &>/dev/null; then
case "${base_distro}" in
debian | alpine | fedora) sys_install unzip ;;
esac
fi
mkdir -p .install-action-tmp
mkdir -p "${tmp_dir}"
(
cd .install-action-tmp
info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" -o tmp.zip
unzip tmp.zip
cd "${tmp_dir}"
download_and_checksum "${url}" "${checksum}"
unzip tmp
mv "bin/protoc${exe}" "${bin_dir}/"
mkdir -p "${include_dir}/"
cp -r include/. "${include_dir}/"
case "${OSTYPE}" in
cygwin* | msys*) bin_dir=$(sed <<<"${bin_dir}" 's/^\/c\//C:\\/') ;;
case "${host_os}" in
windows) bin_dir=$(sed <<<"${bin_dir}" 's/^\/c\//C:\\/') ;;
esac
if [[ -z "${PROTOC:-}" ]]; then
info "setting PROTOC environment variable"
echo "PROTOC=${bin_dir}/protoc${exe}" >>"${GITHUB_ENV}"
fi
)
rm -rf .install-action-tmp
;;
shellcheck)
# https://github.com/koalaman/shellcheck/releases
latest_version="0.9.0"
repo="koalaman/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}"
bin="${tool}-v${version}/${tool}${exe}"
case "${OSTYPE}" in
linux*)
if type -P shellcheck &>/dev/null; then
apt_remove shellcheck
fi
url="${base_url}.linux.${host_arch}.tar.xz"
;;
darwin*) url="${base_url}.darwin.x86_64.tar.xz" ;;
cygwin* | msys*)
url="${base_url}.zip"
bin="${tool}${exe}"
;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
download "${url}" /usr/local/bin "${bin}"
;;
shfmt)
# https://github.com/mvdan/sh/releases
latest_version="3.6.0"
repo="mvdan/sh"
case "${version}" in
latest) version="${latest_version}" ;;
esac
bin_dir="/usr/local/bin"
case "${OSTYPE}" in
linux*)
case "${host_arch}" in
aarch64) target="linux_arm64" ;;
*) target="linux_amd64" ;;
esac
;;
darwin*)
case "${host_arch}" in
aarch64) target="darwin_arm64" ;;
*) target="darwin_amd64" ;;
esac
;;
cygwin* | msys*)
target="windows_amd64"
bin_dir="${HOME}/.install-action/bin"
if [[ ! -d "${bin_dir}" ]]; then
mkdir -p "${bin_dir}"
echo "${bin_dir}" >>"${GITHUB_PATH}"
export PATH="${PATH}:${bin_dir}"
fi
;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
url="https://github.com/${repo}/releases/download/v${version}/${tool}_v${version}_${target}${exe}"
info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 -o "${bin_dir}/${tool}${exe}" "${url}"
case "${OSTYPE}" in
linux* | darwin*) chmod +x "${bin_dir}/${tool}${exe}" ;;
esac
rm -rf "${tmp_dir}"
;;
valgrind)
case "${version}" in
latest) ;;
*) warn "specifying the version of ${tool} is not supported yet by this action" ;;
esac
case "${OSTYPE}" in
linux*) ;;
darwin* | cygwin* | msys*) bail "${tool} for non-linux is not supported yet by this action" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
case "${host_os}" in
linux) ;;
macos | windows) bail "${tool} for non-linux is not supported yet by this action" ;;
*) bail "unsupported host OS '${host_os}' for ${tool}" ;;
esac
# libc6-dbg is needed to run Valgrind
apt_install libc6-dbg
@@ -551,102 +445,48 @@ for tool in "${tools[@]}"; do
# https://snapcraft.io/install/valgrind/ubuntu
snap_install valgrind --classic
;;
wasm-pack)
# https://github.com/rustwasm/wasm-pack/releases
latest_version="0.10.3"
repo="rustwasm/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in
linux*) target="${host_arch}-unknown-linux-musl" ;;
darwin*) target="x86_64-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}-${target}.tar.gz"
download "${url}" "${cargo_bin}" "${tool}-v${version}-${target}/${tool}${exe}"
;;
wasmtime)
# https://github.com/bytecodealliance/wasmtime/releases
latest_version="4.0.0"
repo="bytecodealliance/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}"
case "${OSTYPE}" in
linux*)
target="${host_arch}-linux"
url="${base_url}-${target}.tar.xz"
;;
darwin*)
target="${host_arch}-macos"
url="${base_url}-${target}.tar.xz"
;;
cygwin* | msys*)
target="x86_64-windows"
url="${base_url}-${target}.zip"
;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
download "${url}" "${cargo_bin}" "${tool}-v${version}-${target}/${tool}${exe}"
;;
mdbook)
# https://github.com/rust-lang/mdBook/releases
latest_version="0.4.25"
repo="rust-lang/mdBook"
case "${version}" in
latest) version="${latest_version}" ;;
esac
base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}"
case "${OSTYPE}" in
linux*)
case "${version}" in
0.[1-3].* | 0.4.? | 0.4.1? | 0.4.2[0-1]) url="${base_url}-x86_64-unknown-linux-gnu.tar.gz" ;;
*) url="${base_url}-${host_arch}-unknown-linux-musl.tar.gz" ;;
esac
;;
darwin*) url="${base_url}-x86_64-apple-darwin.tar.gz" ;;
cygwin* | msys*) url="${base_url}-x86_64-pc-windows-msvc.zip" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
download "${url}" "${cargo_bin}" "${tool}${exe}"
;;
mdbook-linkcheck)
# https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases
latest_version="0.7.7"
repo="Michael-F-Bryan/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-gnu" ;;
darwin*) target="x86_64-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
url="https://github.com/${repo}/releases/download/v${version}/${tool}.${target}.zip"
download "${url}" "${cargo_bin}" "${tool}${exe}"
case "${OSTYPE}" in
linux* | darwin*) chmod +x "${cargo_bin}/${tool}${exe}" ;;
esac
;;
cargo-binstall)
case "${version}" in
latest) ;;
*) warn "specifying the version of ${tool} is not supported by this action" ;;
esac
install_cargo_binstall
echo
continue
;;
*)
cargo_binstall "${tool}" "${version}"
continue
# Handle aliases
case "${tool}" in
cargo-nextest | nextest) tool="cargo-nextest" ;;
esac
# Use cargo-binstall fallback if tool is not available.
if [[ ! -f "${manifest_dir}/${tool}.json" ]]; then
cargo_binstall "${tool}" "${version}"
continue
fi
# Pre-install
case "${tool}" in
shellcheck)
case "${host_os}" in
linux)
if type -P shellcheck &>/dev/null; then
apt_remove -y shellcheck
fi
;;
esac
;;
esac
download_from_manifest "${tool}" "${version}"
;;
esac
info "${tool} installed at $(type -P "${bin}")"
case "${bin}" in
"cargo-udeps${exe}") x cargo udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option
"cargo-valgrind${exe}") x cargo valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option
info "${tool} installed at $(type -P "${tool}${exe}")"
case "${tool}" in
cargo-udeps) x cargo udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option
cargo-valgrind) x cargo valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option
cargo-*) x cargo "${tool#cargo-}" --version ;;
*) x "${tool}" --version ;;
esac