scripts: Split installing Rust to its own script

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2023-08-30 10:54:12 -06:00
committed by Jeremy Soller
parent 51e3e1a53a
commit b22e8dee41
4 changed files with 37 additions and 24 deletions

2
Jenkinsfile vendored
View File

@ -72,7 +72,7 @@ pipeline {
sh """#!/bin/bash sh """#!/bin/bash
# Install dependencies # Install dependencies
#./scripts/deps.sh #./scripts/install-deps.sh
. "${HOME}/.cargo/env" . "${HOME}/.cargo/env"
# Reset # Reset

View File

@ -32,8 +32,8 @@ For a list of important changes please see the [changelog](./CHANGELOG.md).
Dependencies can be installed with the provided script. Dependencies can be installed with the provided script.
``` ```sh
./scripts/deps.sh ./scripts/install-deps.sh
``` ```
If rustup was installed for the first time, it will be required to source the If rustup was installed for the first time, it will be required to source the

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only
set -eE set -eE
@ -101,22 +102,8 @@ 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
RUSTUP_NEW_INSTALL=0 msg "Installing Rust toolchain and components"
if which rustup &> /dev/null; then ./scripts/install-rust.sh
msg "Updating rustup"
rustup self update
else
RUSTUP_NEW_INSTALL=1
msg "Installing Rust"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --default-toolchain stable
msg "Loading Rust environment"
source "${HOME}/.cargo/env"
fi
msg "Installing pinned Rust toolchain and components"
rustup show
msg "Installing EC dependencies" msg "Installing EC dependencies"
pushd ec pushd ec
@ -129,10 +116,5 @@ make CPUS="$(nproc)" crossgcc-i386
make CPUS="$(nproc)" crossgcc-x64 make CPUS="$(nproc)" crossgcc-x64
popd popd
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

31
scripts/install-rust.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
# Install Rust via rustup, along with the pinned toolchain.
# shellcheck shell=dash
# shellcheck disable=SC1091
set -Ee
RUSTUP_NEW_INSTALL=0
# NOTE: rustup is used to allow multiple toolchain installations.
if command -v rustup >/dev/null 2>&1; then
rustup self update
else
RUSTUP_NEW_INSTALL=1
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --default-toolchain stable
. "${HOME}/.cargo/env"
fi
# XXX: rustup has no command to install a toolchain from a TOML file.
# Rely on the fact that `show` will install the default toolchain.
rustup show
if [ "$RUSTUP_NEW_INSTALL" = "1" ]; then
printf "\e[33m>> rustup was just installed. Ensure cargo is on the PATH with:\e[0m\n"
printf " source ~/.cargo/env\n\n"
fi