-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathinstall_build_env.sh
More file actions
112 lines (91 loc) · 4.09 KB
/
Copy pathinstall_build_env.sh
File metadata and controls
112 lines (91 loc) · 4.09 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# If binaries are compiled in CI then skip this script
if [ -n "$BUILT_IN_CI" ]; then
echo "[*] BUILT_IN_CI is set to '$BUILT_IN_CI'. Skipping script..."
exit 0
fi
echo ""
echo "######################################################################"
echo "### Install build environment dependencies ###"
echo "######################################################################"
echo "### WARNING: DO NOT MODIFY THIS SCRIPT UNLESS YOU KNOW WHY! ###"
echo "### ###"
echo "### This script is used by: ###"
echo "### • .github/workflows/docker-localnet.yml ###"
echo "### • Dockerfile-localnet ###"
echo "### ###"
echo "### Any changes may break CI builds or local Docker environments. ###"
echo "######################################################################"
echo ""
set -e
echo "[*] Detecting platform..."
UNAME_OUT="$(uname -s)"
case "${UNAME_OUT}" in
Linux*) OS=Linux;;
Darwin*) OS=Mac;;
*) OS="UNKNOWN:${UNAME_OUT}"
esac
echo "[+] Platform: $OS"
# Determine if we have root privileges
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
else
if command -v sudo &>/dev/null; then
SUDO="sudo"
else
SUDO=""
fi
fi
# System Dependencies
if [ "$OS" = "Linux" ]; then
echo "[+] Installing dependencies on Linux..."
if [ -z "$SUDO" ] && [ "$(id -u)" -ne 0 ]; then
echo "[!] Warning: No sudo and not root. Skipping apt install."
else
# The canonical ports endpoint is intermittently unreachable from
# GitHub's ARM runners. KAIST is a registered Ubuntu Ports mirror
# serving the same signed archive. Start over HTTP so a minimal
# Ubuntu image can install CA roots, then upgrade it to HTTPS below.
$SUDO sed -i 's|http://ports.ubuntu.com/ubuntu-ports|http://ftp.kaist.ac.kr/ubuntu-ports|g' \
/etc/apt/sources.list /etc/apt/sources.list.d/ubuntu.sources || true
$SUDO apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true update
$SUDO apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true install -y ca-certificates
$SUDO sed -i 's|http://archive.ubuntu.com/ubuntu|https://mirrors.edge.kernel.org/ubuntu|g' /etc/apt/sources.list || true
$SUDO sed -i 's|http://ftp.kaist.ac.kr/ubuntu-ports|https://ftp.kaist.ac.kr/ubuntu-ports|g' \
/etc/apt/sources.list /etc/apt/sources.list.d/ubuntu.sources || true
$SUDO apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true update
$SUDO apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true install -y --no-install-recommends \
curl build-essential protobuf-compiler clang git pkg-config libssl-dev llvm libudev-dev \
python3 python3-dev \
gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
fi
elif [ "$OS" = "Mac" ]; then
echo "[+] Installing dependencies on macOS..."
if ! command -v brew &> /dev/null; then
echo "[!] Homebrew not found. Installing..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
brew install protobuf openssl llvm pkg-config
LDFLAGS="-L$(brew --prefix openssl)/lib"
export LDFLAGS
CPPFLAGS="-I$(brew --prefix openssl)/include"
export CPPFLAGS
else
echo "[!] Unsupported OS: $OS"
exit 1
fi
# Rust Toolchain
echo "[+] Installing Rust toolchain..."
curl https://sh.rustup.rs -sSf | sh -s -- -y
# Activate rust in shell
source "$HOME/.cargo/env" || export PATH="$HOME/.cargo/bin:$PATH"
# Keep in sync with rust-toolchain.toml (the repo's canonical pin).
rustup toolchain install 1.89 --profile minimal
rustup default 1.89
# Add Rust Targets
echo "Adding Rust targets for wasm + cross-arch binaries..."
rustup target add wasm32v1-none
rustup target add aarch64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-gnu
echo "[✓] Environment setup complete."