From c9806cce78990942b87bd38a2bca479cfbb13cea Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Wed, 24 May 2023 18:22:41 +1000 Subject: [PATCH] Add one-liner for installing `cargo-binstall` on Linux/MacOS (#1074) Fixed #1073 Signed-off-by: Jiahao XU --- README.md | 6 ++++++ install-from-binstall-release.sh | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 install-from-binstall-release.sh diff --git a/README.md b/README.md index 8618d5ccc..d34a419c3 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,12 @@ You probably want to **[see this page as it was when the latest version was publ ## Installation +Here are the one-liners for installing pre-compiled `cargo-binstall` binary from release on Linux and acOS: + +``` +curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash +``` + To get started _using_ `cargo-binstall` first install the binary (either via `cargo install cargo-binstall` or by downloading a pre-compiled [release](https://github.com/cargo-bins/cargo-binstall/releases)), then extract it using `tar` or `unzip` and move it into `$HOME/.cargo/bin`. We recommend using the pre-compiled ones because we optimize those more than a standard source build does. diff --git a/install-from-binstall-release.sh b/install-from-binstall-release.sh new file mode 100755 index 000000000..0163b9f75 --- /dev/null +++ b/install-from-binstall-release.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -euxo pipefail + +cd "$(mktemp -d)" + +base_url="https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-" + +os="$(uname -o)" +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" == "GNU/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 - +else + echo "Unupporteed OS ${os}" + exit 1 +fi + +./cargo-binstall -y --force cargo-binstall + +if ! [[ ":$PATH:" == *":$HOME/.cargo/bin:"* ]]; then + echo + printf "\033[0;31mYour path is missing ~/.cargo/bin, you might want to add it.\033[0m\n" + echo +fi