Skip to content

Commit 98b197c

Browse files
committed
Rewrite scripts to set up Rust on dev desktops
The scripts to set up Rust for a user on the dev desktops have been refactored for a better onboarding experience and error handling. The init script installs rustup now, and can be extended in the future to also set the user's git username and email. For users who want to set up their own Rust toolchain, the setup_rust script clones their fork of the rust-lang/rust repository, compiles it, and links the build artifacts. This is optional, however, and not required if users want to use the dev desktop to work with different repositories.
1 parent 014278b commit 98b197c

File tree

4 files changed

+58
-27
lines changed

4 files changed

+58
-27
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#!/usr/bin/env bash
22

3-
username=`id -u -n`
4-
gh_name=${username#"gh-"}
3+
# Enable strict mode for Bash
4+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
5+
set -euo pipefail
6+
IFS=$'\n\t'
57

6-
# Using https instead of git urls because vscode only handles login on push/pull
7-
git clone https://github.com/$gh_name/rust.git
8-
pushd rust
9-
git remote add upstream https://github.com/rust-lang/rust.git
10-
git fetch upstream
11-
git checkout upstream/master
12-
popd
8+
# Check if rustup is already installed and exit if that's the case.
9+
if command -v rustup &>/dev/null; then
10+
rustup --version
11+
exit 0
12+
fi
1313

1414
init_git.py
15-
setup_rustup.sh
15+
16+
echo "Installing rustup..."
17+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/usr/bin/env bash
22

3+
# Enable strict mode for Bash
4+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
5+
set -euo pipefail
6+
IFS=$'\n\t'
7+
38
for D in rust*; do
49
if [ -d "${D}" ]; then
5-
pushd $D
6-
ln -s ../config.toml
7-
popd
10+
pushd "${D}" || exit
11+
if [[ ! -f config.toml ]]; then
12+
ln -s ~/config.toml .
13+
fi
14+
popd || exit
815
fi
916
done
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
# Enable strict mode for Bash
4+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
5+
set -euo pipefail
6+
IFS=$'\n\t'
7+
8+
username=$(id -u -n)
9+
gh_name=${username#"gh-"}
10+
11+
set -x
12+
13+
if [[ ! -d "rust" ]]; then
14+
# Using https instead of git urls because vscode only handles login on push/pull
15+
git clone "https://github.com/${gh_name}/rust.git"
16+
fi
17+
18+
pushd rust
19+
20+
if ! git remote | grep upstream; then
21+
git remote add upstream https://github.com/rust-lang/rust.git
22+
fi
23+
24+
git fetch upstream
25+
git checkout upstream/master
26+
popd
27+
28+
set_defaults.sh
29+
30+
for D in rust*; do
31+
if [ -d "${D}" ]; then
32+
cd "${D}" && ./x.py build
33+
rustup toolchain link "$D"_stage1 "$D/build/x86_64-unknown-linux-gnu/stage1"
34+
rustup toolchain link "$D"_stage2 "$D/build/x86_64-unknown-linux-gnu/stage2"
35+
fi
36+
done

ansible/roles/dev-desktop/files/scripts/setup_rustup.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)