-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-prerequisites
More file actions
executable file
·297 lines (268 loc) · 9.01 KB
/
check-prerequisites
File metadata and controls
executable file
·297 lines (268 loc) · 9.01 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/bash
# BrightSign Python CV Extension - Prerequisites Validation
# Checks system requirements before allowing builds to start
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
ERRORS=0
WARNINGS=0
log() {
echo -e "${BLUE}[CHECK] $1${NC}"
}
warn() {
echo -e "${YELLOW}⚠️ WARNING: $1${NC}"
((WARNINGS++))
}
error() {
echo -e "${RED}❌ ERROR: $1${NC}"
((ERRORS++))
}
success() {
echo -e "${GREEN}✅ $1${NC}"
}
info() {
echo -e " ${BLUE}→${NC} $1"
}
echo "================================================================"
echo " BrightSign Python CV Extension - Prerequisites Check"
echo "================================================================"
echo ""
# Check 1: Architecture
log "Checking system architecture..."
ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]; then
success "Architecture: x86_64 (compatible)"
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
error "Architecture: $ARCH (INCOMPATIBLE)"
info "This project requires x86_64 due to RKNN toolchain limitations"
info "Detected: Apple Silicon, ARM64, or similar ARM system"
info ""
info "Solutions:"
info " 1. Use x86_64 cloud VM (AWS, Google Cloud, Azure)"
info " 2. Use Intel/AMD Linux machine"
info " 3. Use Docker Desktop with x86_64 emulation (slow)"
info ""
info "Cloud VM example:"
info " AWS EC2: t3.xlarge (4 vCPU, 16GB RAM)"
info " Google Cloud: n2-standard-4"
info ""
else
error "Architecture: $ARCH (unknown)"
info "Expected: x86_64"
fi
echo ""
# Check 2: Operating System
log "Checking operating system..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
success "OS: Linux (optimal)"
elif [[ "$OSTYPE" == "darwin"* ]]; then
success "OS: macOS"
if [[ "$ARCH" == "arm64" ]]; then
error "Detected Apple Silicon - see architecture error above"
fi
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
warn "OS: Windows (WSL2 recommended)"
info "If using WSL, ensure Docker Desktop integration is enabled"
else
warn "OS: $OSTYPE (untested)"
fi
echo ""
# Check 3: Docker
log "Checking Docker installation..."
if command -v docker &> /dev/null; then
DOCKER_VERSION=$(docker --version 2>&1 || echo "unknown")
success "Docker installed: $DOCKER_VERSION"
# Check if Docker daemon is running
if docker info &> /dev/null; then
success "Docker daemon is running"
# Check Docker permissions
if docker ps &> /dev/null; then
success "Docker permissions OK (no sudo required)"
else
warn "Docker may require sudo"
info "Run: sudo usermod -aG docker $USER"
info "Then log out and back in"
fi
else
error "Docker daemon is not running"
info "Start Docker:"
info " Linux: sudo systemctl start docker"
info " Mac/Windows: Start Docker Desktop"
fi
else
error "Docker not installed"
info "Install Docker:"
info " Ubuntu: sudo apt-get install docker.io"
info " Mac: brew install --cask docker"
info " Or: https://docs.docker.com/get-docker/"
fi
echo ""
# Check 4: Disk Space
log "Checking available disk space..."
if command -v df &> /dev/null; then
# Get available space in current directory (in KB)
AVAILABLE_KB=$(df . | awk 'NR==2 {print $4}')
AVAILABLE_GB=$((AVAILABLE_KB / 1024 / 1024))
REQUIRED_GB=50
if [[ $AVAILABLE_GB -ge $REQUIRED_GB ]]; then
success "Disk space: ${AVAILABLE_GB}GB available (need ${REQUIRED_GB}GB)"
elif [[ $AVAILABLE_GB -ge 25 ]]; then
warn "Disk space: ${AVAILABLE_GB}GB available (recommended ${REQUIRED_GB}GB+)"
info "Build may succeed but could be tight"
info "Consider freeing up space if possible"
else
error "Disk space: ${AVAILABLE_GB}GB available (need ${REQUIRED_GB}GB minimum)"
info "Breakdown: Docker image (~20GB), Build artifacts (~20GB), SDK (~10GB)"
info "Free up space before continuing"
fi
else
warn "Cannot check disk space (df command not found)"
fi
echo ""
# Check 5: Memory
log "Checking available memory..."
if command -v free &> /dev/null; then
TOTAL_MEM_MB=$(free -m | awk 'NR==2 {print $2}')
TOTAL_MEM_GB=$((TOTAL_MEM_MB / 1024))
if [[ $TOTAL_MEM_GB -ge 16 ]]; then
success "Memory: ${TOTAL_MEM_GB}GB (recommended 16GB+)"
elif [[ $TOTAL_MEM_GB -ge 8 ]]; then
warn "Memory: ${TOTAL_MEM_GB}GB (recommended 16GB+)"
info "Builds may be slow with 8GB"
info "Close other applications during build"
else
warn "Memory: ${TOTAL_MEM_GB}GB (low, recommended 16GB+)"
info "Builds may fail or be very slow"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
TOTAL_MEM_GB=$(sysctl -n hw.memsize 2>/dev/null | awk '{print int($1/1024/1024/1024)}' || echo "unknown")
if [[ "$TOTAL_MEM_GB" != "unknown" && $TOTAL_MEM_GB -ge 16 ]]; then
success "Memory: ${TOTAL_MEM_GB}GB (recommended 16GB+)"
else
info "Memory: $TOTAL_MEM_GB GB"
fi
else
info "Memory check not available on this platform"
fi
echo ""
# Check 6: Required Tools
log "Checking required tools..."
REQUIRED_TOOLS=("git" "wget" "tar")
MISSING_TOOLS=()
for tool in "${REQUIRED_TOOLS[@]}"; do
if command -v "$tool" &> /dev/null; then
success "$tool is installed"
else
error "$tool is not installed"
MISSING_TOOLS+=("$tool")
fi
done
if [[ ${#MISSING_TOOLS[@]} -gt 0 ]]; then
echo ""
info "Install missing tools:"
info " Ubuntu/Debian: sudo apt-get install ${MISSING_TOOLS[*]}"
info " Mac: brew install ${MISSING_TOOLS[*]}"
fi
echo ""
# Check 7: Internet Connectivity
log "Checking internet connectivity..."
if ping -c 1 8.8.8.8 &> /dev/null; then
success "Internet connectivity OK"
# Test GitHub connectivity (where sources are downloaded from)
if timeout 5 wget -q --spider https://github.com 2>/dev/null; then
success "GitHub is accessible"
else
warn "Cannot reach GitHub"
info "This may cause download failures"
info "Check firewall/proxy settings"
fi
else
error "No internet connectivity"
info "Internet required for:"
info " - Downloading BrightSign OS source (~2-3GB)"
info " - Cloning RKNN toolkit"
info " - Docker image pulls"
fi
echo ""
# Check 8: Network Speed (optional)
log "Checking network speed (optional)..."
info "Build requires downloading ~3GB of sources"
info "Estimated download time:"
info " 10 Mbps: ~40 minutes"
info " 50 Mbps: ~8 minutes"
info " 100 Mbps: ~4 minutes"
echo ""
# Check 9: Docker Image
log "Checking for existing Docker image..."
if docker images | grep -q "bsoe-build"; then
success "Docker image 'bsoe-build' exists (setup already run)"
info "Skip ./setup and go directly to ./build"
else
info "Docker image 'bsoe-build' not found"
info "Run ./setup to build the Docker image first"
fi
echo ""
# Check 10: Existing Build Artifacts
log "Checking for existing build artifacts..."
if [[ -d "sdk" ]]; then
success "SDK directory exists (previous build detected)"
info "You can rebuild incrementally or clean rebuild"
elif [[ -d "brightsign-oe" ]]; then
warn "Old brightsign-oe directory exists"
info "This may be from pre-Docker workflow"
info "Consider removing: rm -rf brightsign-oe"
fi
echo ""
# Summary
echo "================================================================"
echo " Prerequisites Check Summary"
echo "================================================================"
echo ""
if [[ $ERRORS -eq 0 && $WARNINGS -eq 0 ]]; then
success "All checks passed! You're ready to build."
echo ""
echo "Next steps:"
echo " 1. Run: ./setup -y (if not done already)"
echo " 2. Run: ./build --extract-sdk (30-60 min)"
echo " 3. Run: ./package (5 min)"
echo ""
echo "Or see QUICKSTART.md for detailed walkthrough"
elif [[ $ERRORS -eq 0 ]]; then
echo -e "${YELLOW}✓ No critical errors, but $WARNINGS warning(s) detected${NC}"
echo ""
echo "You can proceed, but be aware of the warnings above."
echo "Builds may be slower or less reliable."
echo ""
echo "To proceed anyway:"
echo " 1. Run: ./setup -y"
echo " 2. Run: ./build --extract-sdk"
else
echo -e "${RED}✗ Found $ERRORS critical error(s) and $WARNINGS warning(s)${NC}"
echo ""
echo "Fix the errors above before proceeding."
echo "Building will likely fail without addressing these issues."
echo ""
echo "Common fixes:"
echo " - Wrong architecture: Use x86_64 machine or cloud VM"
echo " - Docker not running: Start Docker daemon"
echo " - Disk space: Free up 50GB+ space"
echo " - Missing tools: Install git, wget, tar"
echo ""
exit 1
fi
# Optional: Offer to continue
if [[ $ERRORS -eq 0 ]]; then
echo ""
read -p "Continue to setup? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Running ./setup -y..."
exec ./setup -y
else
echo "Setup cancelled. Run ./setup when ready."
fi
fi