From 31800b17cc5aacb880c42b8785fa8a78ad22be05 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 25 Jul 2022 14:47:39 +0900 Subject: [PATCH] Fix cargo-binstall installation Fixes #10 --- CHANGELOG.md | 2 ++ main.sh | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5006922b..2313eb9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [Unreleased] +- Fix cargo-binstall installation on macOS and Windows. + ## [1.5.10] - 2022-07-24 - Update `parse-changelog@latest` to 0.5.0. diff --git a/main.sh b/main.sh index 8a1c2cbc..a8288442 100755 --- a/main.sh +++ b/main.sh @@ -33,7 +33,7 @@ info() { install_cargo_binstall() { cargo_bin="${CARGO_HOME:-$HOME/.cargo}/bin" - if [ ! -f "${cargo_bin}/cargo-binstall" ]; then + if [[ ! -f "${cargo_bin}/cargo-binstall" ]]; then info "installing cargo-binstall" target="$(rustc -vV | grep host | cut -c 7-)" @@ -62,20 +62,25 @@ install_cargo_binstall() { *) bail "unsupported target '${target}' for cargo-binstall" ;; esac - if [ $is_zip = true ]; then - retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "$url" -o "cargo-binstall-${target}.zip" - unzip "cargo-binstall-${target}.zip" - rm "cargo-binstall-${target}.zip" - else - retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "$url" | tar xzf - - fi + mkdir -p .install-action-tmp + ( + cd .install-action-tmp + if [[ "${is_zip}" == "true" ]]; then + retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "$url" -o "cargo-binstall-${target}.zip" + unzip "cargo-binstall-${target}.zip" + rm "cargo-binstall-${target}.zip" + else + retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "$url" | tar xzf - + fi - mkdir -p "{cargo_bin}/" + mkdir -p "{cargo_bin}/" - case "${OSTYPE}" in - cygwin* | msys*) mv cargo-binstall.exe "${cargo_bin}/" ;; - *) mv cargo-binstall "${cargo_bin}/" ;; - esac + case "${OSTYPE}" in + cygwin* | msys*) mv cargo-binstall.exe "${cargo_bin}/" ;; + *) mv cargo-binstall "${cargo_bin}/" ;; + esac + ) + rm -rf .install-action-tmp else info "cargo-binstall already installed on in ${cargo_bin}/cargo-binstall" fi