]> git.lizzy.rs Git - rust.git/blob - setup-toolchain.sh
Rustup to rustc 1.40.0-nightly (ac162c6ab 2019-11-09)
[rust.git] / setup-toolchain.sh
1 #!/bin/bash
2 # Set up the appropriate rustc toolchain
3
4 set -e
5
6 cd "$(dirname "$0")"
7
8 ERRNO=0
9 RTIM_PATH=$(command -v rustup-toolchain-install-master) || ERRNO=$?
10 CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}
11
12 # Check if people also install RTIM in other locations beside
13 # ~/.cargo/bin
14 if [[ "$ERRNO" -ne 0 ]] || [[ "$RTIM_PATH" == $CARGO_HOME/bin/rustup-toolchain-install-master ]]; then
15     cargo install -Z install-upgrade rustup-toolchain-install-master
16 else
17     VERSION=$(rustup-toolchain-install-master -V | grep -o "[0-9.]*")
18     REMOTE=$(cargo search rustup-toolchain-install-master | grep -o "[0-9.]*")
19     echo "info: skipping updating rustup-toolchain-install-master at $RTIM_PATH"
20     echo "      current version : $VERSION"
21     echo "      remote version  : $REMOTE"
22 fi
23
24 RUST_COMMIT=$(git ls-remote https://github.com/rust-lang/rust master | awk '{print $1}')
25
26 if rustc +master -Vv 2>/dev/null | grep -q "$RUST_COMMIT"; then
27     echo "info: master toolchain is up-to-date"
28     exit 0
29 fi
30
31 rustup-toolchain-install-master -f -n master -c rustc-dev -- "$RUST_COMMIT"
32 rustup override set master