-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·150 lines (127 loc) · 4.46 KB
/
setup.sh
File metadata and controls
executable file
·150 lines (127 loc) · 4.46 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
set -euo pipefail
# ----------------------------------------
# Check and install Rust
# ----------------------------------------
check_rust() {
if command -v rustc &> /dev/null && rustc -V &> /dev/null; then
echo "✅ Rust is already installed: $(rustc -V)"
else
echo "⚠️ Rust is not installed or 'rustc' is not available. Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
echo "🔧 Rust installation completed."
fi
}
# ----------------------------------------
# Check and install Buck2
# ----------------------------------------
check_buck2() {
if command -v buck2 &> /dev/null && buck2 --version &> /dev/null; then
echo "✅ Buck2 is already installed: $(buck2 --version | head -n1)"
else
echo "⚠️ Buck2 is not installed or 'buck2' command is not available. Installing Buck2..."
export ARCH="$(uname -m)"
curl "https://github.com/facebook/buck2/releases/download/latest/buck2-${ARCH}-unknown-linux-gnu.zst" --output /tmp/buck2-${ARCH}-unknown-linux-gnu.zst --location
zstd -d /tmp/buck2-${ARCH}-unknown-linux-gnu.zst -o $HOME/.cargo/bin/buck2 -f
chmod +x $HOME/.cargo/bin/buck2
echo "🔧 Buck2 installation completed."
fi
}
# ----------------------------------------
# Check and install cargo-buckal
# ----------------------------------------
check_buckal() {
if command -v cargo-buckal &> /dev/null; then
echo "✅ cargo-buckal is already installed: $(cargo-buckal -V)"
else
echo "⚠️ cargo-buckal is not installed. Installing..."
cargo install --git https://github.com/buck2hub/cargo-buckal.git
echo "🔧 cargo-buckal installation completed."
fi
}
# ----------------------------------------
# Install system dependencies
# ----------------------------------------
install_system_deps() {
echo "🔍 Detecting Linux distribution..."
DISTRO=""
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO_ID="${ID}"
DISTRO_VERSION="${VERSION_ID:-}"
elif command -v lsb_release &> /dev/null; then
DISTRO_ID="$(lsb_release -si | tr '[:upper:]' '[:lower:]')"
else
echo "❌ Cannot detect Linux distribution."
exit 1
fi
case "${DISTRO_ID}" in
ubuntu|debian)
echo "🧾 Detected: ${DISTRO_ID^} (version: ${DISTRO_VERSION})"
echo "📦 Installing system dependencies via APT..."
sudo apt-get update
sudo apt-get install -y \
build-essential \
clang \
lld \
pkg-config \
protobuf-compiler \
seccomp \
libseccomp-dev \
libpython3-dev \
openssl \
libssl-dev \
zstd
;;
fedora)
echo "🧾 Detected: Fedora (version: ${DISTRO_VERSION})"
echo "📦 Installing system dependencies via DNF..."
sudo dnf group install -y development-tools
sudo dnf install -y \
clang \
lld \
pkgconf \
protobuf-devel \
protobuf-compiler \
libseccomp \
libseccomp-devel \
python3-devel \
openssl \
openssl-devel \
zstd
;;
arch)
echo "🧾 Detected: Arch Linux"
echo "📦 Installing system dependencies via Pacman..."
sudo pacman -Sy --noconfirm
sudo pacman -S --noconfirm \
base-devel \
clang \
lld \
pkgconf \
protobuf \
protobuf-c \
libseccomp \
python \
python-setuptools \
openssl \
zstd
;;
*)
echo "⚠️ Unknown or unsupported distribution: ${DISTRO_ID}"
echo "💡 You may need to manually install dependencies."
exit 1
;;
esac
echo "✅ System dependencies installation complete."
}
# ----------------------------------------
# Execute workflow
# ----------------------------------------
echo "🚀 Starting setup script..."
install_system_deps
check_rust
check_buck2
check_buckal
echo "🎉 All setup completed successfully!"