202 lines
No EOL
5.5 KiB
Bash
202 lines
No EOL
5.5 KiB
Bash
#!/bin/bash
|
|
|
|
# ParticleOS Build Test Script
|
|
# Tests the build environment and system definition
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
RED='\033[0;31m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
print_status() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
print_header() {
|
|
echo ""
|
|
echo -e "${BLUE}================================${NC}"
|
|
echo -e "${BLUE}$1${NC}"
|
|
echo -e "${BLUE}================================${NC}"
|
|
}
|
|
|
|
# Test apt-ostree availability
|
|
test_apt_ostree() {
|
|
print_header "Test 1: apt-ostree Availability"
|
|
|
|
# Test if apt-ostree is available locally
|
|
if command -v apt-ostree &> /dev/null; then
|
|
print_success "apt-ostree is available locally"
|
|
apt-ostree --version
|
|
else
|
|
print_status "apt-ostree not found locally, will be downloaded during build"
|
|
fi
|
|
|
|
# Test if apt-ostree can be downloaded
|
|
print_status "Testing apt-ostree download availability..."
|
|
if curl -s -I "https://git.raines.xyz/robojerk/apt-ostree/raw/branch/main/apt-ostree_0.1.0-1_amd64.deb" | head -n 1 | grep "HTTP/[12] [23].." > /dev/null; then
|
|
print_success "apt-ostree package is available for download"
|
|
else
|
|
print_error "apt-ostree package not available for download"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Test system definition
|
|
test_system_definition() {
|
|
print_header "Test 2: System Definition"
|
|
|
|
if [ -f "aurora-system.yaml" ]; then
|
|
print_success "System definition found: aurora-system.yaml"
|
|
|
|
# Validate YAML syntax
|
|
if command -v python3 &> /dev/null; then
|
|
python3 -c "import yaml; yaml.safe_load(open('aurora-system.yaml'))" 2>/dev/null
|
|
if [ $? -eq 0 ]; then
|
|
print_success "YAML syntax is valid"
|
|
else
|
|
print_error "YAML syntax is invalid"
|
|
return 1
|
|
fi
|
|
else
|
|
print_warning "Python3 not available, skipping YAML validation"
|
|
fi
|
|
else
|
|
print_error "System definition not found: aurora-system.yaml"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Test build prerequisites
|
|
test_prerequisites() {
|
|
print_header "Test 3: Build Prerequisites"
|
|
|
|
local missing_packages=()
|
|
|
|
for package in mmdebstrap ostree squashfs-tools xorriso grub-pc-bin; do
|
|
if ! dpkg -l | grep -q "^ii $package "; then
|
|
missing_packages+=("$package")
|
|
fi
|
|
done
|
|
|
|
if [ ${#missing_packages[@]} -gt 0 ]; then
|
|
print_warning "Missing packages: ${missing_packages[*]}"
|
|
print_status "Installing missing packages..."
|
|
sudo apt update
|
|
sudo apt install -y "${missing_packages[@]}"
|
|
else
|
|
print_success "All build prerequisites satisfied"
|
|
fi
|
|
}
|
|
|
|
# Test minimal system build
|
|
test_minimal_build() {
|
|
print_header "Test 4: mmdebstrap Test"
|
|
|
|
print_status "Testing mmdebstrap functionality..."
|
|
|
|
# Create a minimal test directory
|
|
mkdir -p test-mmdebstrap
|
|
|
|
# Test mmdebstrap with minimal packages (just systemd)
|
|
sudo mmdebstrap \
|
|
--architectures=amd64 \
|
|
--variant=minbase \
|
|
--include=systemd \
|
|
noble \
|
|
test-mmdebstrap \
|
|
http://archive.ubuntu.com/ubuntu/
|
|
|
|
if [ $? -eq 0 ]; then
|
|
print_success "mmdebstrap test successful"
|
|
|
|
# Check if system was created
|
|
if [ -d "test-mmdebstrap" ]; then
|
|
print_success "Test build directory created"
|
|
ls -la test-mmdebstrap/
|
|
|
|
# Check if systemd is installed
|
|
if [ -f "test-mmdebstrap/usr/bin/systemctl" ]; then
|
|
print_success "systemd found in test build"
|
|
else
|
|
print_warning "systemd not found in test build"
|
|
fi
|
|
else
|
|
print_error "Test build directory not found"
|
|
return 1
|
|
fi
|
|
else
|
|
print_error "mmdebstrap test failed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Cleanup test files
|
|
cleanup() {
|
|
print_header "Test 5: Cleanup"
|
|
|
|
if [ -f "test-minimal.yaml" ]; then
|
|
rm -f test-minimal.yaml
|
|
print_status "Removed test-minimal.yaml"
|
|
fi
|
|
|
|
if [ -d "test-build" ]; then
|
|
sudo rm -rf test-build
|
|
print_status "Removed test-build directory"
|
|
fi
|
|
|
|
if [ -d "test-mmdebstrap" ]; then
|
|
sudo rm -rf test-mmdebstrap
|
|
print_status "Removed test-mmdebstrap directory"
|
|
fi
|
|
|
|
print_success "Cleanup complete"
|
|
}
|
|
|
|
# Main test process
|
|
main() {
|
|
echo "🧪 ParticleOS Build Test"
|
|
echo "========================"
|
|
echo "Testing build environment and system definition"
|
|
echo ""
|
|
|
|
# Run tests
|
|
test_apt_ostree || exit 1
|
|
test_system_definition || exit 1
|
|
test_prerequisites || exit 1
|
|
test_minimal_build || exit 1
|
|
cleanup
|
|
|
|
print_header "Test Results"
|
|
echo ""
|
|
print_success "All tests passed! 🎉"
|
|
echo ""
|
|
echo "✅ apt-ostree is available and working"
|
|
echo "✅ System definition is valid"
|
|
echo "✅ Build prerequisites are satisfied"
|
|
echo "✅ mmdebstrap functionality works"
|
|
echo ""
|
|
echo "🚀 Ready to build ParticleOS ISO!"
|
|
echo " Run: ./build-iso-mmdebstrap.sh"
|
|
echo ""
|
|
echo "📋 Next: Add apt-ostree to Forgejo repository"
|
|
echo ""
|
|
}
|
|
|
|
# Run main function
|
|
main "$@" |