-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-rust.sh
executable file
·50 lines (41 loc) · 989 Bytes
/
install-rust.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
set -ex
detect_arch() {
deb_arch=$(dpkg --print-architecture)
case $deb_arch in
amd64)
printf "x86_64-unknown-linux-gnu"
;;
aarch64 | arm64)
printf "aarch64-unknown-linux-gnu"
;;
armhf)
printf "armv7-unknown-linux-gnueabihf"
;;
armel)
printf "arm-unknown-linux-gnueabi"
;;
i386)
printf "i686-unknown-linux-gnu"
;;
*)
printf "unknown"
;;
esac
}
rust_triple=$(detect_arch)
[ "$rust_triple" != "unknown" ] || (echo "Unknown architecture: $deb_arch" && exit 1)
home=$(pwd)
target="target/$rust_triple/release"
# Download rustup-init
mkdir -p "$target" &&
cd "$target" &&
curl -LO "https://static.rust-lang.org/rustup/dist/$rust_triple/rustup-init" &&
chmod 755 rustup-init
cd "$home"
curl -LO "https://static.rust-lang.org/rustup/dist/$rust_triple/rustup-init.sha256"
cat rustup-init.sha256
# Verify checksum
sha256sum --check rustup-init.sha256
# Run rustup-init
exec "./$target/rustup-init" -y --default-toolchain "stable-$rust_triple"