X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=setup-toolchain.sh;h=469cba1874d652446b61bb14216f835926cf9ef2;hb=6527c3d99c2a33c5b44441b49b8664e554d12365;hp=89de40d40bcdac825d2a228ee4651fcf96717d76;hpb=8d38a07fb6e90f7f312165e8ae8eb0f63bdf21af;p=rust.git diff --git a/setup-toolchain.sh b/setup-toolchain.sh index 89de40d40bc..469cba1874d 100755 --- a/setup-toolchain.sh +++ b/setup-toolchain.sh @@ -5,9 +5,32 @@ set -e cd "$(dirname "$0")" -if [[ "$CI" == true ]] || ! command -v rustup-toolchain-install-master > /dev/null; then - cargo install -Z install-upgrade rustup-toolchain-install-master --bin rustup-toolchain-install-master +RTIM_PATH=$(command -v rustup-toolchain-install-master) || INSTALLED=false +CARGO_HOME=${CARGO_HOME:-$HOME/.cargo} + +# Check if RTIM is not installed or installed in other locations not in ~/.cargo/bin +if [[ "$INSTALLED" == false || "$RTIM_PATH" == $CARGO_HOME/bin/rustup-toolchain-install-master ]]; then + cargo +nightly install rustup-toolchain-install-master +else + VERSION=$(rustup-toolchain-install-master -V | grep -o "[0-9.]*") + REMOTE=$(cargo +nightly search rustup-toolchain-install-master | grep -o "[0-9.]*") + echo "info: skipping updating rustup-toolchain-install-master at $RTIM_PATH" + echo " current version : $VERSION" + echo " remote version : $REMOTE" +fi + +RUST_COMMIT=$(git ls-remote https://github.com/rust-lang/rust master | awk '{print $1}') + +if rustc +master -Vv 2>/dev/null | grep -q "$RUST_COMMIT"; then + echo "info: master toolchain is up-to-date" + exit 0 +fi + +if [[ -n "$HOST_TOOLCHAIN" ]]; then + TOOLCHAIN=('--host' "$HOST_TOOLCHAIN") +else + TOOLCHAIN=() fi -rustup-toolchain-install-master -f -n master -c rustc-dev +rustup-toolchain-install-master -f -n master "${TOOLCHAIN[@]}" -c rustc-dev -- "$RUST_COMMIT" rustup override set master