9
9
# If RUSTUP_UPDATE_ROOT is unset or empty, default it.
10
10
RUSTUP_UPDATE_ROOT=" ${RUSTUP_UPDATE_ROOT:- https:// static.rust-lang.org/ rustup} "
11
11
12
- ARCH=
13
-
14
12
# XXX: If you change anything here, please make the same changes in setup_mode.rs
15
13
usage () {
16
14
cat 1>&2 << EOF
@@ -48,17 +46,17 @@ main() {
48
46
need_cmd rmdir
49
47
50
48
get_architecture || return 1
51
- ARCH =" $RETVAL "
52
- assert_nz " $ARCH " " arch"
49
+ local _arch =" $RETVAL "
50
+ assert_nz " $_arch " " arch"
53
51
54
52
local _ext=" "
55
- case " $ARCH " in
53
+ case " $_arch " in
56
54
* windows* )
57
55
_ext=" .exe"
58
56
;;
59
57
esac
60
58
61
- local _url=" ${RUSTUP_UPDATE_ROOT} /dist/${ARCH } /rustup-init${_ext} "
59
+ local _url=" ${RUSTUP_UPDATE_ROOT} /dist/${_arch } /rustup-init${_ext} "
62
60
63
61
local _dir
64
62
_dir=" $( mktemp -d 2> /dev/null || ensure mktemp -d -t rustup) "
@@ -99,7 +97,7 @@ main() {
99
97
fi
100
98
101
99
ensure mkdir -p " $_dir "
102
- ensure downloader " $_url " " $_file "
100
+ ensure downloader " $_url " " $_file " " $_arch "
103
101
ensure chmod u+x " $_file "
104
102
if [ ! -x " $_file " ]; then
105
103
printf ' %s\n' " Cannot execute $_file (likely because of mounting /tmp as noexec)." 1>&2
@@ -389,14 +387,14 @@ downloader() {
389
387
if [ " $1 " = --check ]; then
390
388
need_cmd " $_dld "
391
389
elif [ " $_dld " = curl ]; then
392
- if ! check_help_for curl --proto --tlsv1.2; then
390
+ if ! check_help_for " $3 " curl --proto --tlsv1.2; then
393
391
echo " Warning: Not forcing TLS v1.2, this is potentially less secure"
394
392
curl --silent --show-error --fail --location " $1 " --output " $2 "
395
393
else
396
394
curl --proto ' =https' --tlsv1.2 --silent --show-error --fail --location " $1 " --output " $2 "
397
395
fi
398
396
elif [ " $_dld " = wget ]; then
399
- if ! check_help_for wget --https-only --secure-protocol; then
397
+ if ! check_help_for " $3 " wget --https-only --secure-protocol; then
400
398
echo " Warning: Not forcing TLS v1.2, this is potentially less secure"
401
399
wget " $1 " -O " $2 "
402
400
else
@@ -408,14 +406,17 @@ downloader() {
408
406
}
409
407
410
408
check_help_for () {
409
+ local _arch
411
410
local _cmd
412
411
local _arg
413
412
local _ok
413
+ _arch=" $1 "
414
+ shift
414
415
_cmd=" $1 "
415
416
_ok=" y"
416
417
shift
417
418
418
- case " $ARCH " in
419
+ case " $_arch " in
419
420
420
421
# If we're running on OS-X, older than 10.13, then we always
421
422
# fail to find these options to force fallback
0 commit comments