- Minimal archiso profile (base + linux only) - Test script runs build in container sandbox - Verifies end-to-end ISO generation pipeline Usage: ./scripts/test-iso-build.sh Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
2 KiB
Bash
Executable file
75 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
# Test ISO build using the container sandbox
|
|
# Creates a minimal Arch ISO to verify the build pipeline works
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
|
|
# Configuration
|
|
PROFILE_DIR="$PROJECT_ROOT/tests/fixtures/archiso-test-profile"
|
|
OUTPUT_DIR="$PROJECT_ROOT/tmp/iso-test-output"
|
|
BUILD_IMAGE="debate-archiso-builder:latest"
|
|
|
|
log() {
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
|
}
|
|
|
|
# Detect container runtime
|
|
if command -v podman &> /dev/null; then
|
|
RUNTIME="podman"
|
|
elif command -v docker &> /dev/null; then
|
|
RUNTIME="docker"
|
|
else
|
|
log "ERROR: No container runtime found. Install podman or docker."
|
|
exit 1
|
|
fi
|
|
|
|
log "Using runtime: $RUNTIME"
|
|
|
|
# Check if build image exists
|
|
if ! $RUNTIME image inspect "$BUILD_IMAGE" &> /dev/null; then
|
|
log "Build image not found. Run: ./scripts/setup-sandbox.sh"
|
|
exit 1
|
|
fi
|
|
|
|
# Create output directory
|
|
mkdir -p "$OUTPUT_DIR"
|
|
log "Output directory: $OUTPUT_DIR"
|
|
|
|
# Run the build
|
|
log "Starting ISO build (this may take several minutes)..."
|
|
log "Profile: $PROFILE_DIR"
|
|
|
|
$RUNTIME run \
|
|
--name debate-test-build \
|
|
--rm \
|
|
--network=none \
|
|
--privileged \
|
|
--tmpfs=/tmp:exec,mode=1777 \
|
|
--tmpfs=/var/tmp:exec,mode=1777 \
|
|
-v "$PROFILE_DIR:/build/profile:ro" \
|
|
-v "$OUTPUT_DIR:/build/output:rw" \
|
|
-e SOURCE_DATE_EPOCH=1704067200 \
|
|
-e LC_ALL=C \
|
|
-e TZ=UTC \
|
|
"$BUILD_IMAGE" \
|
|
mkarchiso -v -w /tmp/archiso-work -o /build/output /build/profile
|
|
|
|
# Check result
|
|
if ls "$OUTPUT_DIR"/*.iso &> /dev/null; then
|
|
ISO_FILE=$(ls "$OUTPUT_DIR"/*.iso | head -1)
|
|
ISO_SIZE=$(du -h "$ISO_FILE" | cut -f1)
|
|
log "SUCCESS! ISO created: $ISO_FILE ($ISO_SIZE)"
|
|
log ""
|
|
log "To verify the ISO:"
|
|
log " sha256sum $ISO_FILE"
|
|
log ""
|
|
log "To test in a VM:"
|
|
log " qemu-system-x86_64 -cdrom $ISO_FILE -m 2G -enable-kvm"
|
|
else
|
|
log "ERROR: No ISO file found in output directory"
|
|
log "Check the build output above for errors"
|
|
exit 1
|
|
fi
|