Skip to content

Commit 798ef38

Browse files
authored
Merge pull request #2435 from pickfire/unsupported-platform
Report error for unsupported platform on 404
2 parents 82efab5 + f0b0547 commit 798ef38

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

rustup-init.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ ignore() {
386386
downloader() {
387387
local _dld
388388
local _ciphersuites
389+
local _err
390+
local _status
389391
if check_cmd curl; then
390392
_dld=curl
391393
elif check_cmd wget; then
@@ -400,30 +402,50 @@ downloader() {
400402
get_ciphersuites_for_curl
401403
_ciphersuites="$RETVAL"
402404
if [ -n "$_ciphersuites" ]; then
403-
curl --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2"
405+
_err=$(curl --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2" 2>&1)
406+
_status=$?
404407
else
405408
echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
406409
if ! check_help_for "$3" curl --proto --tlsv1.2; then
407410
echo "Warning: Not enforcing TLS v1.2, this is potentially less secure"
408-
curl --silent --show-error --fail --location "$1" --output "$2"
411+
_err=$(curl --silent --show-error --fail --location "$1" --output "$2" 2>&1)
412+
_status=$?
409413
else
410-
curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2"
414+
_err=$(curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2" 2>&1)
415+
_status=$?
411416
fi
412417
fi
418+
if [ -n "$_err" ]; then
419+
echo "$_err" >&2
420+
if echo "$_err" | grep -q 404$; then
421+
err "installer for platform '$3' not found, this may be unsupported"
422+
fi
423+
fi
424+
return $_status
413425
elif [ "$_dld" = wget ]; then
414426
get_ciphersuites_for_wget
415427
_ciphersuites="$RETVAL"
416428
if [ -n "$_ciphersuites" ]; then
417-
wget --https-only --secure-protocol=TLSv1_2 --ciphers "$_ciphersuites" "$1" -O "$2"
429+
_err=$(wget --https-only --secure-protocol=TLSv1_2 --ciphers "$_ciphersuites" "$1" -O "$2" 2>&1)
430+
_status=$?
418431
else
419432
echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
420433
if ! check_help_for "$3" wget --https-only --secure-protocol; then
421434
echo "Warning: Not enforcing TLS v1.2, this is potentially less secure"
422-
wget "$1" -O "$2"
435+
_err=$(wget "$1" -O "$2" 2>&1)
436+
_status=$?
423437
else
424-
wget --https-only --secure-protocol=TLSv1_2 "$1" -O "$2"
438+
_err=$(wget --https-only --secure-protocol=TLSv1_2 "$1" -O "$2" 2>&1)
439+
_status=$?
440+
fi
441+
fi
442+
if [ -n "$_err" ]; then
443+
echo "$_err" >&2
444+
if echo "$_err" | grep -q ' 404 Not Found$'; then
445+
err "installer for platform '$3' not found, this may be unsupported"
425446
fi
426447
fi
448+
return $_status
427449
else
428450
err "Unknown downloader" # should not reach here
429451
fi

0 commit comments

Comments
 (0)