-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathinstall-1.82-toolchain.sh
executable file
·58 lines (46 loc) · 1.65 KB
/
install-1.82-toolchain.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -euo pipefail
# Constants
RUSTUP_TOOLCHAIN_NAME="succinct"
ROOT_DIR="$HOME/.sp1"
TOOLCHAINS_DIR="$ROOT_DIR/toolchains"
# Function to get the target triple
get_target() {
local target=$(rustc -vV | grep "host:" | awk '{print $2}')
if [[ "$target" == *"-musl" ]]; then
target="${target/musl/gnu}"
fi
echo "$target"
}
# Ensure Rust and Rustup are installed
if ! command -v rustup &>/dev/null; then
echo "Rust is not installed. Please install Rust from https://rustup.rs/ and try again."
exit 1
fi
# Prepare directories
mkdir -p "$ROOT_DIR" "$TOOLCHAINS_DIR"
# Get target triple
TARGET=$(get_target)
TOOLCHAIN_ASSET_NAME="rust-toolchain-${TARGET}.tar.gz"
TOOLCHAIN_ARCHIVE_PATH="$ROOT_DIR/$TOOLCHAIN_ASSET_NAME"
TOOLCHAIN_URL="https://github.com/succinctlabs/rust/releases/download/v1.82.0/$TOOLCHAIN_ASSET_NAME"
# Download the toolchain
echo "Downloading toolchain from $TOOLCHAIN_URL..."
curl -fSL "$TOOLCHAIN_URL" -o "$TOOLCHAIN_ARCHIVE_PATH"
# Unpack the toolchain
NEW_TOOLCHAIN_DIR="$TOOLCHAINS_DIR/1.82.0"
mkdir -p "$NEW_TOOLCHAIN_DIR"
echo "Unpacking toolchain to $NEW_TOOLCHAIN_DIR..."
tar -xzf "$TOOLCHAIN_ARCHIVE_PATH" -C "$NEW_TOOLCHAIN_DIR" --strip-components=1
# Link the toolchain to rustup
echo "Linking toolchain to rustup as $RUSTUP_TOOLCHAIN_NAME..."
rustup toolchain link "$RUSTUP_TOOLCHAIN_NAME" "$NEW_TOOLCHAIN_DIR"
# Ensure permissions for binaries
BIN_DIR="$NEW_TOOLCHAIN_DIR/bin"
RUSTLIB_BIN_DIR="$NEW_TOOLCHAIN_DIR/lib/rustlib/$TARGET/bin"
for DIR in "$BIN_DIR" "$RUSTLIB_BIN_DIR"; do
if [[ -d "$DIR" ]]; then
chmod -R 755 "$DIR"
fi
done
echo "Toolchain installed and linked successfully."