scripts: Update rustup or inform user of env vars

Ensure rustup is up-to-date to avoid users having a version that is too
old to support the TOML format.

If rustup was just installed, tell the user to source the new env vars
to use the correct version of the toolchain.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford 2022-01-14 09:24:24 -07:00 committed by Jeremy Soller
parent 10c256d6fa
commit cf7fc2c540

View file

@ -114,7 +114,12 @@ curl -sSf https://review.coreboot.org/tools/hooks/commit-msg \
-o .git/modules/coreboot/hooks/commit-msg && \ -o .git/modules/coreboot/hooks/commit-msg && \
chmod +x .git/modules/coreboot/hooks/commit-msg chmod +x .git/modules/coreboot/hooks/commit-msg
if ! which rustup &> /dev/null; then RUSTUP_NEW_INSTALL=0
if which rustup &> /dev/null; then
msg "Updating rustup"
rustup self update
else
RUSTUP_NEW_INSTALL=1
msg "Installing Rust" msg "Installing Rust"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --default-toolchain none | sh -s -- -y --default-toolchain none
@ -126,5 +131,10 @@ fi
msg "Installing pinned Rust toolchain and components" msg "Installing pinned Rust toolchain and components"
rustup show rustup show
if [[ $RUSTUP_NEW_INSTALL = 1 ]]; then
msg "\x1B[33m>> rustup was just installed. Ensure cargo is on the PATH with:"
echo -e " source ~/.cargo/env\n"
fi
msg "\x1B[32mSuccessfully installed dependencies" msg "\x1B[32mSuccessfully installed dependencies"
echo "Ready to run ./scripts/build.sh [model]" >&2 echo "Ready to run ./scripts/build.sh [model]" >&2