cargo-binstall/install-from-binstall-release.sh
Jacob Hummer b415b0d7e6
Fix install-from-binstall-release.sh for Git Bash users on Windows (#1562)
* Update install-from-binstall-release.sh

* Update install-from-binstall-release.sh

* Update install-from-binstall-release.sh

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update install-from-binstall-release.sh

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update install-script.yml

* Update install-from-binstall-release.sh

* Update install-script.yml

---------

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-01-13 02:22:51 +00:00

42 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
set -euxo pipefail
cd "$(mktemp -d)"
base_url="https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-"
os="$(uname -s)"
if [ "$os" == "Darwin" ]; then
url="${base_url}universal-apple-darwin.zip"
curl -LO --proto '=https' --tlsv1.2 -sSf "$url"
unzip cargo-binstall-universal-apple-darwin.zip
elif [ "$os" == "Linux" ]; then
machine="$(uname -m)"
target="${machine}-unknown-linux-musl"
if [ "$machine" == "armv7" ]; then
target="${target}eabihf"
fi
url="${base_url}${target}.tgz"
curl -L --proto '=https' --tlsv1.2 -sSf "$url" | tar -xvzf -
elif [ "${OS-}" = "Windows_NT" ]; then
machine="$(uname -m)"
target="${machine}-pc-windows-msvc"
url="${base_url}${target}.zip"
curl -LO --proto '=https' --tlsv1.2 -sSf "$url"
unzip "cargo-binstall-${target}.zip"
else
echo "Unsupported OS ${os}"
exit 1
fi
./cargo-binstall -y --force cargo-binstall
CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
if ! [[ ":$PATH:" == *":$CARGO_HOME/bin:"* ]]; then
echo
printf "\033[0;31mYour path is missing %s, you might want to add it.\033[0m\n" "$CARGO_HOME/bin"
echo
fi