forked from boxlite-ai/boxlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-ubuntu.sh
More file actions
executable file
·174 lines (137 loc) · 4.64 KB
/
Copy pathsetup-ubuntu.sh
File metadata and controls
executable file
·174 lines (137 loc) · 4.64 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
# Setup script for BoxLite development on Ubuntu/Debian
#
# This script installs all required dependencies for building BoxLite on Linux.
# Run this once when setting up a new development environment.
#
# Usage:
# bash scripts/setup/setup-ubuntu.sh
set -e
# Source common utilities
SETUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_DIR="$(cd "$SETUP_DIR/.." && pwd)"
source "$SCRIPT_DIR/common.sh"
source "$SETUP_DIR/setup-common.sh"
# Check if running on Linux
check_platform() {
if [[ "$(uname)" != "Linux" ]]; then
print_error "This script is for Linux only"
echo " For macOS, use: bash scripts/setup/setup-macos.sh"
exit 1
fi
# Warn if running in manylinux container
if command -v yum >/dev/null 2>&1 && ! command -v apt-get >/dev/null 2>&1; then
print_error "This script is for Ubuntu/Debian systems"
echo " For manylinux/RHEL/CentOS, use: bash scripts/setup/setup-manylinux.sh"
exit 1
fi
}
# Check if a package is installed
apt_installed() {
dpkg -l "$1" 2>/dev/null | grep -q "^ii"
}
# Run apt-get with network retry settings. `apt-get update` can otherwise exit
# successfully after failed index downloads, then package install fails later.
apt_get() {
run_with_sudo apt-get \
-o Acquire::Retries="${APT_RETRIES:-5}" \
-o Acquire::http::Timeout="${APT_TIMEOUT:-30}" \
-o Acquire::https::Timeout="${APT_TIMEOUT:-30}" \
"$@"
}
# Update package lists
update_apt() {
print_section "🔄 Updating package lists..."
apt_get -o APT::Update::Error-Mode=any update -qq
echo ""
}
# Install system dependencies
install_system_deps() {
print_section "📦 Installing system dependencies..."
local packages=(
# Core build tools
build-essential # gcc, g++, make
git
curl
wget
file # file type detection
pkg-config
patchelf # ELF binary patching for wheel repair
# Rust/cargo dependencies
libssl-dev # OpenSSL development headers
# Guest binary (static musl build)
musl-tools # musl-gcc for static linking
gperf # libseccomp build dep (used by build-libseccomp.sh)
# Python SDK
python3
python3-pip
python3-venv
# Note: Go is installed separately via setup_go (distro packages are too old)
# libkrun build dependencies
llvm # llvm-config for clang-sys
libclang-dev # libclang.so for bindgen
# libkrunfw kernel build dependencies
flex # Lexical analyzer (kernel build)
bison # Parser generator (kernel build)
bc # Calculator (kernel build)
libelf-dev # ELF library (kernel objtool)
python3-pyelftools # ELF parsing (bin2cbundle.py)
# bubblewrap build dependencies (jailer sandbox)
meson # Meson build system
ninja-build # Ninja build backend
libcap-dev # Linux capabilities library
# gRPC/protobuf (boxlite-shared)
protobuf-compiler # protoc compiler
# C SDK test harness (sdks/c/tests/CMakeLists.txt)
cmake # Configure/build/run C SDK unit + integration tests
)
for pkg in "${packages[@]}"; do
print_step "Checking for $pkg... "
if apt_installed "$pkg"; then
print_success "Already installed"
else
echo -e "${YELLOW}Installing...${NC}"
apt_get install -y -qq "$pkg"
print_success "$pkg installed"
fi
done
echo ""
}
# Setup Python dev tools
setup_python() {
print_section "🐍 Checking Python..."
check_python
echo ""
}
# Node.js install delegates to setup_nodejs in setup-common.sh.
# Distro packages on Ubuntu 24.04 ship Node 18 (EOL), so the shared installer
# uses NodeSource to pull the active LTS line instead.
install_nodejs() {
setup_nodejs
}
# Main installation flow
main() {
local actual_user="${SUDO_USER:-$USER}"
print_header "BoxLite Development Setup for Ubuntu/Debian"
check_platform
require_root_or_sudo
print_section "📋 Checking prerequisites..."
echo ""
update_apt
install_system_deps
setup_go
setup_python
install_nodejs
init_submodules
# Track if Rust was just installed
local rust_just_installed=false
if ! check_rust; then
install_rust
rust_just_installed=true
fi
detect_guest_target
check_rust_target "$GUEST_TARGET"
run_dev_extras
print_header "Setup Complete"
}
main "$@"