Skip to content

Commit

Permalink
scripts: Split installing Rust to its own script
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd authored and jackpot51 committed Oct 3, 2023
1 parent 51e3e1a commit b22e8de
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pipeline {

sh """#!/bin/bash
# Install dependencies
#./scripts/deps.sh
#./scripts/install-deps.sh
. "${HOME}/.cargo/env"
# Reset
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ For a list of important changes please see the [changelog](./CHANGELOG.md).

Dependencies can be installed with the provided script.

```
./scripts/deps.sh
```sh
./scripts/install-deps.sh
```

If rustup was installed for the first time, it will be required to source the
Expand Down
24 changes: 3 additions & 21 deletions scripts/deps.sh → scripts/install-deps.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only

set -eE

Expand Down Expand Up @@ -101,22 +102,8 @@ curl -sSf https://review.coreboot.org/tools/hooks/commit-msg \
-o .git/modules/coreboot/hooks/commit-msg && \
chmod +x .git/modules/coreboot/hooks/commit-msg

RUSTUP_NEW_INSTALL=0
if which rustup &> /dev/null; then
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 Rust toolchain and components"
./scripts/install-rust.sh

msg "Installing EC dependencies"
pushd ec
Expand All @@ -129,10 +116,5 @@ make CPUS="$(nproc)" crossgcc-i386
make CPUS="$(nproc)" crossgcc-x64
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"
echo "Ready to run ./scripts/build.sh [model]" >&2
31 changes: 31 additions & 0 deletions scripts/install-rust.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b22e8de

Please sign in to comment.