Debian Codegraph @

.woodpecker/scripts/prepare-toolchain.sh

raw
1 #!/bin/sh
2 set -eu
3
4 cd "$(readlink -f "$(dirname "$0")/../..")"
5
6 set -x
7
8 RUST_CHANNEL="$1"
9
10 # Use the preset for CI environment.
11 cp .woodpecker/cargo-config.toml ${CARGO_HOME}/config.toml
12
13 # The repository should not have a directory which would be used as the cached `$RUSTUP_HOME`.
14 CACHED_RUSTUP_HOME=${CI_WORKSPACE}/.tmp-rustup-home && test ! -e ${CACHED_RUSTUP_HOME}
15
16 # Copy the pre-installed toolchains of the Docker container into the new `$RUSTUP_HOME`.
17 cp -a /usr/local/rustup ${CACHED_RUSTUP_HOME} && test -d ${CACHED_RUSTUP_HOME}
18
19 # Use the new `$RUSTUP_HOME` variable.
20 export RUSTUP_HOME=${CACHED_RUSTUP_HOME}
21
22 # Install the toolchain of the specified version (if not yet available locally).
23 rustup update --no-self-update ${RUST_CHANNEL} && rustup default ${RUST_CHANNEL}
24
25 rustc --version && cargo --version