File tree Expand file tree Collapse file tree 7 files changed +106
-29
lines changed
ansible/roles/dev-desktop/files/scripts Expand file tree Collapse file tree 7 files changed +106
-29
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
3
echo " # Available scripts for managing your Rust checkouts"
4
- echo " init .sh | first time setup, you should only have to execute this once on a new machine"
4
+ echo " setup_rustup .sh | first time setup, you should only have to execute this once on a new machine"
5
5
echo " status.sh | list the branches and git status of all copies of the Rust repo"
6
6
echo " new_worktree.sh | creates a worktree (shallow copy of the main git checkout of Rust, sharing the .git folder)"
7
7
echo " detach_merged_prs.sh | invokes \" git pull --fast-forward-only\" on all worktrees and detaches those that are equal to the \" master\" branch"
8
8
echo " "
9
9
echo " # Rarer commands:"
10
- echo " set_defaults.sh | connects the global config.toml with all worktrees. Use this when your setup is broken"
11
-
10
+ echo " set_defaults.sh | connects the global config.toml with all worktrees. Use this when your setup is broken"
11
+ echo " setup_rust.sh | Clone your fork of rust-lang/rust, compile, and then link it "
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- username=` id -u -n`
4
- gh_name=${username# " gh-" }
5
-
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
3
+ # Enable strict mode for Bash
4
+ # http://redsymbol.net/articles/unofficial-bash-strict-mode/
5
+ set -euo pipefail
6
+ IFS=$' \n\t '
13
7
14
8
init_git.py
15
9
setup_rustup.sh
Original file line number Diff line number Diff line change
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
+ # Discover target triple (e.g. "aarch64-unknown-linux-gnu")
9
+ target=" $( rustc -vV | awk ' /host/ { print $2 }' ) "
10
+
11
+ rustc_dummy=$(
12
+ cat << EOF
13
+ #!/usr/bin/env bash
14
+ echo "This is a dummy file to trick rustup into thinking this is a sysroot"
15
+ echo 'Run "x.py build --stage 1 library/std" to create a real sysroot you can use with rustup'
16
+ EOF
17
+ )
18
+
19
+ for D in rust* ; do
20
+ if [ -d " $D " ]; then
21
+ pushd " $D "
22
+
23
+ bootstrap_version=$( grep ' pub const VERSION' src/bootstrap/lib.rs | grep -o ' [0-9]*' )
24
+
25
+ if [ " $bootstrap_version " -gt 2 ]; then
26
+ stages=(stage1-sysroot stage2-sysroot)
27
+ else
28
+ stages=(stage1 stage2)
29
+ fi
30
+
31
+ for stage in " ${stages[@]} " ; do
32
+ directory=" build/${target} /${stage} "
33
+
34
+ if [ ! -d " $directory " ]; then
35
+ mkdir -p " ${directory} /lib"
36
+ mkdir -p " ${directory} /bin"
37
+ echo " $rustc_dummy " >> " ${directory} /bin/rustc"
38
+ chmod +x " ${directory} /bin/rustc"
39
+ fi
40
+
41
+ rustup toolchain link " ${D} _${stage} " " $directory "
42
+ done
43
+
44
+ popd
45
+ fi
46
+ done
Original file line number Diff line number Diff line change @@ -13,4 +13,4 @@ git checkout upstream/master
13
13
ln -s ../config.toml
14
14
popd
15
15
16
- setup_rustup .sh
16
+ link_rust .sh
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
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
+
3
8
for D in rust* ; do
4
9
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
8
15
fi
9
16
done
Original file line number Diff line number Diff line change
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
+ link_rust.sh
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- set -x
4
-
5
- rustup --version || curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6
-
7
- source " $HOME /.cargo/env"
8
-
9
- for D in rust* ; do
10
- if [ -d " ${D} " ]; then
11
- rustup toolchain link " $D " _stage1 " $D /build/x86_64-unknown-linux-gnu/stage1"
12
- rustup toolchain link " $D " _stage2 " $D /build/x86_64-unknown-linux-gnu/stage2"
13
- fi
14
- done
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
+ # 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
13
+
14
+ echo " Installing rustup..."
15
+ curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
You can’t perform that action at this time.
0 commit comments