Add --retry 10 to curl call in install-from-binstall-release.sh (#2158)

* Add --retry 10 to curl call in install-from-binstall-release.sh

Fix #2157 

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix install-from-binstall-release.sh

Use do_curl() instead of function do_curl as the latter is non standard

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

---------

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
Jiahao XU 2025-05-18 13:08:47 +10:00 committed by GitHub
parent 5cbf019d8c
commit 3b64237893
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,10 @@
set -eux
do_curl() {
curl --retry 10 -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L --proto '=https' --tlsv1.2 -sSf "$@"
}
# Set pipefail if it works in a subshell, disregard if unsupported
# shellcheck disable=SC3040
(set -o pipefail 2> /dev/null) && set -o pipefail
@ -26,7 +30,7 @@ fi
os="$(uname -s)"
if [ "$os" = "Darwin" ]; then
url="${base_url}universal-apple-darwin.zip"
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -LO --proto '=https' --tlsv1.2 -sSf "$url"
do_curl -O "$url"
unzip cargo-binstall-universal-apple-darwin.zip
elif [ "$os" = "Linux" ]; then
machine="$(uname -m)"
@ -39,12 +43,12 @@ elif [ "$os" = "Linux" ]; then
fi
url="${base_url}${target}.tgz"
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L --proto '=https' --tlsv1.2 -sSf "$url" | tar -xvzf -
do_curl "$url" | tar -xvzf -
elif [ "${OS-}" = "Windows_NT" ]; then
machine="$(uname -m)"
target="${machine}-pc-windows-msvc"
url="${base_url}${target}.zip"
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -LO --proto '=https' --tlsv1.2 -sSf "$url"
do_curl -O "$url"
unzip "cargo-binstall-${target}.zip"
else
echo "Unsupported OS ${os}"