84 lines
2.3 KiB
Bash
Executable file
84 lines
2.3 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 (prefer docker for LXC compatibility)
|
|
if command -v docker &> /dev/null; then
|
|
RUNTIME="docker"
|
|
elif command -v podman &> /dev/null; then
|
|
RUNTIME="podman"
|
|
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"
|
|
|
|
# Note: Network enabled for package downloads during build
|
|
# Production builds should use pre-cached packages for --network=none
|
|
#
|
|
# mkarchiso needs to mount /dev for chroot - requires root privileges
|
|
# Using sudo for podman, or --privileged for docker
|
|
if [ "$RUNTIME" = "podman" ]; then
|
|
# Podman rootless can't mount /dev - need sudo
|
|
RUNTIME_CMD="sudo podman"
|
|
else
|
|
RUNTIME_CMD="$RUNTIME"
|
|
fi
|
|
|
|
$RUNTIME_CMD run \
|
|
--name debate-test-build \
|
|
--rm \
|
|
--privileged \
|
|
-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
|