242 lines
No EOL
7.9 KiB
Bash
242 lines
No EOL
7.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Test Official ComposeFS Package Installation and Functionality
|
|
# This script tests the newly available official ComposeFS package in Debian
|
|
|
|
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
|
|
|
|
# Logging functions
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
log_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Test configuration
|
|
TEST_DIR="/tmp/particle-os-composefs-test"
|
|
TEST_IMAGE="test-official-composefs"
|
|
TEST_MOUNT="/tmp/composefs-test-mount"
|
|
|
|
# Cleanup function
|
|
cleanup() {
|
|
log_info "Cleaning up test environment..."
|
|
|
|
# Unmount if mounted
|
|
if mountpoint -q "$TEST_MOUNT" 2>/dev/null; then
|
|
sudo umount "$TEST_MOUNT" 2>/dev/null || true
|
|
fi
|
|
|
|
# Remove test directories
|
|
rm -rf "$TEST_DIR" 2>/dev/null || true
|
|
rm -rf "$TEST_MOUNT" 2>/dev/null || true
|
|
|
|
log_info "Cleanup completed"
|
|
}
|
|
|
|
# Set up trap for cleanup
|
|
trap cleanup EXIT
|
|
|
|
# Main test function
|
|
main() {
|
|
log_info "Starting Official ComposeFS Package Test"
|
|
log_info "========================================"
|
|
|
|
# Check if running as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
log_error "This script must be run as root (use sudo)"
|
|
exit 1
|
|
fi
|
|
|
|
# Phase 1: Check package availability
|
|
log_info "Phase 1: Checking package availability"
|
|
echo "----------------------------------------"
|
|
|
|
# Update package list
|
|
log_info "Updating package list..."
|
|
apt update
|
|
|
|
# Check if composefs-tools package is available
|
|
log_info "Checking for composefs-tools package..."
|
|
if apt-cache search composefs-tools | grep -q composefs-tools; then
|
|
log_success "composefs-tools package found in repositories"
|
|
else
|
|
log_warning "composefs-tools package not found in repositories"
|
|
log_info "This is expected if the package hasn't propagated yet"
|
|
log_info "Checking for alternative package names..."
|
|
|
|
# Check for alternative package names
|
|
if apt-cache search composefs | grep -q composefs; then
|
|
log_info "Found composefs-related packages:"
|
|
apt-cache search composefs
|
|
else
|
|
log_warning "No composefs packages found in repositories"
|
|
fi
|
|
fi
|
|
|
|
# Phase 2: Install package (if available)
|
|
log_info ""
|
|
log_info "Phase 2: Installing composefs-tools package"
|
|
echo "---------------------------------------------"
|
|
|
|
# Try to install the package
|
|
if apt-cache search composefs-tools | grep -q composefs-tools; then
|
|
log_info "Installing composefs-tools package..."
|
|
if apt install -y composefs-tools; then
|
|
log_success "composefs-tools package installed successfully"
|
|
else
|
|
log_error "Failed to install composefs-tools package"
|
|
exit 1
|
|
fi
|
|
else
|
|
log_warning "Skipping package installation (package not available)"
|
|
log_info "This test will continue with source-built tools if available"
|
|
fi
|
|
|
|
# Phase 3: Check tool availability
|
|
log_info ""
|
|
log_info "Phase 3: Checking tool availability"
|
|
echo "-------------------------------------"
|
|
|
|
# Check for mkcomposefs
|
|
if command -v mkcomposefs >/dev/null 2>&1; then
|
|
log_success "mkcomposefs found: $(which mkcomposefs)"
|
|
mkcomposefs --version 2>/dev/null || log_info "mkcomposefs version: available"
|
|
else
|
|
log_warning "mkcomposefs not found"
|
|
fi
|
|
|
|
# Check for mount.composefs
|
|
if command -v mount.composefs >/dev/null 2>&1; then
|
|
log_success "mount.composefs found: $(which mount.composefs)"
|
|
mount.composefs --help 2>/dev/null | head -5 || log_info "mount.composefs help: available"
|
|
else
|
|
log_warning "mount.composefs not found"
|
|
fi
|
|
|
|
# Check for fsverity
|
|
if command -v fsverity >/dev/null 2>&1; then
|
|
log_success "fsverity found: $(which fsverity)"
|
|
else
|
|
log_warning "fsverity not found (optional for integrity verification)"
|
|
fi
|
|
|
|
# Phase 4: Test Particle-OS integration
|
|
log_info ""
|
|
log_info "Phase 4: Testing Particle-OS integration"
|
|
echo "------------------------------------------"
|
|
|
|
# Check if Particle-OS composefs script exists
|
|
if [[ -f "/usr/local/bin/composefs-alternative.sh" ]]; then
|
|
log_success "Particle-OS composefs script found"
|
|
|
|
# Test official status command
|
|
log_info "Testing official status command..."
|
|
if /usr/local/bin/composefs-alternative.sh official-status; then
|
|
log_success "Official status command works"
|
|
else
|
|
log_warning "Official status command failed"
|
|
fi
|
|
else
|
|
log_warning "Particle-OS composefs script not found at /usr/local/bin/composefs-alternative.sh"
|
|
fi
|
|
|
|
# Phase 5: Test basic functionality (if tools available)
|
|
log_info ""
|
|
log_info "Phase 5: Testing basic functionality"
|
|
echo "-------------------------------------"
|
|
|
|
if command -v mkcomposefs >/dev/null 2>&1 && command -v mount.composefs >/dev/null 2>&1; then
|
|
log_info "Creating test environment..."
|
|
|
|
# Create test directories
|
|
mkdir -p "$TEST_DIR"
|
|
mkdir -p "$TEST_MOUNT"
|
|
|
|
# Create test content
|
|
log_info "Creating test content..."
|
|
echo "Hello from Official ComposeFS!" > "$TEST_DIR/test.txt"
|
|
mkdir -p "$TEST_DIR/testdir"
|
|
echo "Test file in subdirectory" > "$TEST_DIR/testdir/subfile.txt"
|
|
|
|
# Create ComposeFS image
|
|
log_info "Creating ComposeFS image..."
|
|
if mkcomposefs --content-dir="$TEST_DIR" --metadata-tree="$TEST_DIR.cfs"; then
|
|
log_success "ComposeFS image created successfully"
|
|
|
|
# Mount ComposeFS image
|
|
log_info "Mounting ComposeFS image..."
|
|
if mount.composefs "$TEST_DIR.cfs" -o "basedir=$TEST_DIR" "$TEST_MOUNT"; then
|
|
log_success "ComposeFS image mounted successfully"
|
|
|
|
# Test content
|
|
log_info "Testing mounted content..."
|
|
if [[ -f "$TEST_MOUNT/test.txt" ]]; then
|
|
log_success "Test file found in mount"
|
|
cat "$TEST_MOUNT/test.txt"
|
|
else
|
|
log_warning "Test file not found in mount"
|
|
fi
|
|
|
|
if [[ -f "$TEST_MOUNT/testdir/subfile.txt" ]]; then
|
|
log_success "Subdirectory file found in mount"
|
|
cat "$TEST_MOUNT/testdir/subfile.txt"
|
|
else
|
|
log_warning "Subdirectory file not found in mount"
|
|
fi
|
|
|
|
# Unmount
|
|
log_info "Unmounting ComposeFS image..."
|
|
umount "$TEST_MOUNT"
|
|
log_success "ComposeFS image unmounted successfully"
|
|
|
|
else
|
|
log_error "Failed to mount ComposeFS image"
|
|
fi
|
|
|
|
# Clean up image
|
|
rm -f "$TEST_DIR.cfs"
|
|
|
|
else
|
|
log_error "Failed to create ComposeFS image"
|
|
fi
|
|
|
|
else
|
|
log_warning "Skipping functionality test (tools not available)"
|
|
fi
|
|
|
|
# Phase 6: Summary
|
|
log_info ""
|
|
log_info "Phase 6: Test Summary"
|
|
echo "---------------------"
|
|
|
|
log_info "Official ComposeFS Package Test completed"
|
|
log_info "Check the output above for any issues or warnings"
|
|
|
|
if command -v mkcomposefs >/dev/null 2>&1 && command -v mount.composefs >/dev/null 2>&1; then
|
|
log_success "✅ Official ComposeFS tools are available and functional"
|
|
log_info "Particle-OS can now use official ComposeFS backend"
|
|
else
|
|
log_warning "⚠️ Official ComposeFS tools not available"
|
|
log_info "Particle-OS will fall back to alternative implementation"
|
|
fi
|
|
}
|
|
|
|
# Run main function
|
|
main "$@" |