Skip to content

Commit b22e8de

Browse files
crawfxrdjackpot51
authored andcommitted
scripts: Split installing Rust to its own script
Signed-off-by: Tim Crawford <tcrawford@system76.com>
1 parent 51e3e1a commit b22e8de

File tree

4 files changed

+37
-24
lines changed

4 files changed

+37
-24
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pipeline {
7272

7373
sh """#!/bin/bash
7474
# Install dependencies
75-
#./scripts/deps.sh
75+
#./scripts/install-deps.sh
7676
. "${HOME}/.cargo/env"
7777
7878
# Reset

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ For a list of important changes please see the [changelog](./CHANGELOG.md).
3232

3333
Dependencies can be installed with the provided script.
3434

35-
```
36-
./scripts/deps.sh
35+
```sh
36+
./scripts/install-deps.sh
3737
```
3838

3939
If rustup was installed for the first time, it will be required to source the

scripts/deps.sh renamed to scripts/install-deps.sh

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: GPL-3.0-only
23

34
set -eE
45

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

104-
RUSTUP_NEW_INSTALL=0
105-
if which rustup &> /dev/null; then
106-
msg "Updating rustup"
107-
rustup self update
108-
else
109-
RUSTUP_NEW_INSTALL=1
110-
msg "Installing Rust"
111-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
112-
| sh -s -- -y --default-toolchain stable
113-
114-
msg "Loading Rust environment"
115-
source "${HOME}/.cargo/env"
116-
fi
117-
118-
msg "Installing pinned Rust toolchain and components"
119-
rustup show
105+
msg "Installing Rust toolchain and components"
106+
./scripts/install-rust.sh
120107

121108
msg "Installing EC dependencies"
122109
pushd ec
@@ -129,10 +116,5 @@ make CPUS="$(nproc)" crossgcc-i386
129116
make CPUS="$(nproc)" crossgcc-x64
130117
popd
131118

132-
if [[ $RUSTUP_NEW_INSTALL = 1 ]]; then
133-
msg "\x1B[33m>> rustup was just installed. Ensure cargo is on the PATH with:"
134-
echo -e " source ~/.cargo/env\n"
135-
fi
136-
137119
msg "\x1B[32mSuccessfully installed dependencies"
138120
echo "Ready to run ./scripts/build.sh [model]" >&2

scripts/install-rust.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-3.0-only
3+
4+
# Install Rust via rustup, along with the pinned toolchain.
5+
6+
# shellcheck shell=dash
7+
# shellcheck disable=SC1091
8+
9+
set -Ee
10+
11+
RUSTUP_NEW_INSTALL=0
12+
13+
# NOTE: rustup is used to allow multiple toolchain installations.
14+
if command -v rustup >/dev/null 2>&1; then
15+
rustup self update
16+
else
17+
RUSTUP_NEW_INSTALL=1
18+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
19+
| sh -s -- -y --default-toolchain stable
20+
21+
. "${HOME}/.cargo/env"
22+
fi
23+
24+
# XXX: rustup has no command to install a toolchain from a TOML file.
25+
# Rely on the fact that `show` will install the default toolchain.
26+
rustup show
27+
28+
if [ "$RUSTUP_NEW_INSTALL" = "1" ]; then
29+
printf "\e[33m>> rustup was just installed. Ensure cargo is on the PATH with:\e[0m\n"
30+
printf " source ~/.cargo/env\n\n"
31+
fi

0 commit comments

Comments
 (0)