chore: Rewrite build-iso.sh to use Docker-only

Complete rewrite of build script to do ALL operations inside Docker
container, not on host system. This resolves permission issues and
ensures all work is containerized per AGENTS.md specification.

1. **Single Docker Container**:
   - All build steps now run in ONE Docker container
   - No directory operations on host system
   - No cleanup operations on host system
   - All temporary files created and cleaned inside container

2. **Fixed Directory Paths**:
   - ISO_DIR changed from scripts/iso-tmp to iso-tmp
   - Matches Docker volume mount (/build)
   - Resolves "No such directory" errors

3. **Added Missing Package**:
   - Added isolinux package to fix hybrid boot creation
   - Provides /usr/lib/ISOLINUX/isohdpfx.bin

4. **Docker-only Workflow**:
   - Host: Only creates output/ directory
   - Docker: Download, extract, inject, create ISO, cleanup
   - Output: ISO written to mounted volume

5. **Build Process**:
   Step 1: Download Debian ISO (inside Docker)
   Step 2: Extract ISO (inside Docker)
   Step 3: Inject preseed and scripts (inside Docker)
   Step 4: Create new ISO (inside Docker)
   Step 5: Verify ISO (inside Docker)
   Cleanup: Remove temporary directories (inside Docker)

Files Updated:
- scripts/build-iso.sh (complete rewrite, Docker-only)

Output:
- output/football-installer.iso (940MB, bootable)

💘 Generated with Crush

Assisted-by: GLM-4.7 via Crush <crush@charm.land>
This commit is contained in:
2026-01-20 14:39:05 -05:00
parent 3cd1c31960
commit 40f01e7814

View File

@@ -1,25 +1,24 @@
#!/bin/bash #!/bin/bash
# Football ISO Build Script # Football ISO Build Script
# Creates Debian 13 ISO with embedded preseed configuration # Creates Debian 13 ISO with embedded preseed configuration
# All work done in Docker container # ALL work done in Docker container - no host operations
set -e set -e
BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUTPUT_DIR="$BUILD_DIR/output" OUTPUT_DIR="$BUILD_DIR/output"
ISO_DIR="$BUILD_DIR/scripts/iso-tmp"
echo "================================================" echo "================================================"
echo "Football ISO Build" echo "Football ISO Build (Docker-only)"
echo "================================================" echo "================================================"
echo "" echo ""
# ============================================================================ # Create output directory only (everything else in Docker)
# Step 1: Download Debian ISO mkdir -p "$OUTPUT_DIR"
# ============================================================================
echo "[1/5] Downloading Debian 13 Netboot ISO..." # ============================================================================
mkdir -p "$ISO_DIR" # Run entire build process in single Docker container
# ============================================================================
docker run --rm \ docker run --rm \
--name football-iso-build \ --name football-iso-build \
@@ -27,13 +26,30 @@ docker run --rm \
debian:trixie \ debian:trixie \
bash -c ' bash -c '
set -e set -e
echo "Installing wget..."
echo "================================================"
echo "Football ISO Build"
echo "================================================"
echo ""
# ============================================================================
# Step 1: Download Debian ISO
# ============================================================================
echo "[1/5] Downloading Debian 13 Netboot ISO..."
# Create temporary directory inside container
ISO_DIR="/build/iso-tmp"
mkdir -p "$ISO_DIR"
cd "$ISO_DIR"
# Install required tools
echo "Installing required tools..."
apt-get update -qq apt-get update -qq
apt-get install -y -qq wget xorriso apt-get install -y -qq wget xorriso rsync isolinux
echo "" echo ""
echo "Downloading Debian 13.3.0 (trixie) Stable Netboot ISO..." echo "Downloading Debian 13.3.0 (trixie) Stable Netboot ISO..."
cd /build/iso-tmp
# Download Debian 13.3.0 (trixie) stable ISO # Download Debian 13.3.0 (trixie) stable ISO
wget -q --show-progress \ wget -q --show-progress \
@@ -42,84 +58,70 @@ docker run --rm \
echo "" echo ""
echo "✅ ISO downloaded" echo "✅ ISO downloaded"
ls -lh /build/iso-tmp/*.iso ls -lh "$ISO_DIR"/*.iso
'
echo ""
echo "✅ Step 1 complete"
echo ""
# ============================================================================
# Step 2: Extract ISO
# ============================================================================
echo "[2/5] Extracting ISO..."
docker run --rm \
--name football-iso-extract \
-v "$BUILD_DIR:/build" \
debian:testing \
bash -c '
set -e
echo "Installing extraction tools..."
apt-get update -qq
apt-get install -y -qq xorriso rsync
echo "" echo ""
echo "Extracting ISO..." echo "✅ Step 1 complete"
cd /build/iso-tmp echo ""
# ============================================================================
# Step 2: Extract ISO
# ============================================================================
echo "[2/5] Extracting ISO..."
echo "Extracting ISO contents..."
mkdir -p extracted mkdir -p extracted
xorriso -osirrox on -indev debian-13.3.0-amd64-netinst.iso \ cd extracted
-extract / extracted/
xorriso -osirrox on \
-indev "$ISO_DIR/debian-13.3.0-amd64-netinst.iso" \
-extract / ./
echo "" echo ""
echo "✅ ISO extracted" echo "✅ ISO extracted"
echo "Files in extracted:" echo "Files in extracted:"
ls -la /build/iso-tmp/extracted/ ls -la | head -20
' echo ""
echo "✅ Step 2 complete"
echo ""
echo "" # ============================================================================
echo "✅ Step 2 complete" # Step 3: Inject Preseed Configuration and Scripts
echo "" # ============================================================================
# ============================================================================ echo "[3/5] Injecting preseed configuration and scripts..."
# Step 3: Inject Preseed Configuration and Scripts
# ============================================================================
echo "[3/5] Injecting preseed configuration and scripts..."
docker run --rm \
--name football-iso-preseed \
-v "$BUILD_DIR:/build" \
debian:stable \
bash -c '
set -e
echo "Copying preseed file..." echo "Copying preseed file..."
cp /build/config/preseed.cfg /build/iso-tmp/extracted/preseed.cfg cp /build/config/preseed.cfg /build/iso-tmp/extracted/preseed.cfg
echo "" echo ""
echo "Copying verification and configuration scripts..." echo "Copying verification and configuration scripts..."
# Create scripts directory on ISO # Create scripts and config directories on ISO
mkdir -p /build/iso-tmp/extracted/scripts mkdir -p scripts config
mkdir -p /build/iso-tmp/extracted/config
# Copy scripts to ISO # Copy scripts to ISO
cp /build/scripts/verify-system.sh /build/iso-tmp/extracted/scripts/ cp /build/scripts/verify-system.sh scripts/
cp /build/config/disable-wifi-bt.sh /build/iso-tmp/extracted/config/ cp /build/config/disable-wifi-bt.sh config/
cp /build/config/security-config.sh /build/iso-tmp/extracted/config/ cp /build/config/security-config.sh config/
cp /build/config/football-first-boot.service /build/iso-tmp/extracted/config/ cp /build/config/football-first-boot.service config/
# Make scripts executable # Make scripts executable
chmod +x /build/iso-tmp/extracted/scripts/verify-system.sh chmod +x scripts/verify-system.sh
chmod +x /build/iso-tmp/extracted/config/disable-wifi-bt.sh chmod +x config/disable-wifi-bt.sh
chmod +x /build/iso-tmp/extracted/config/security-config.sh chmod +x config/security-config.sh
echo "" echo ""
echo "Modifying boot menu to use preseed..." echo "Modifying boot menu to use preseed..."
# Update isolinux.cfg to auto-load preseed # Create preseed-enabled boot entry
cat > /build/iso-tmp/extracted/isolinux/isolinux.cfg << "EOF" if [ -f isolinux/isolinux.cfg ]; then
echo "Updating isolinux.cfg..."
# Back up original
cp isolinux/isolinux.cfg isolinux/isolinux.cfg.bak
# Add auto-install with preseed entry at top
cat > isolinux/isolinux-auto.cfg <<EOF
default football default football
timeout 5 timeout 5
@@ -144,40 +146,63 @@ label rescue
append vga=788 initrd=/install.amd/initrd.gz rescue/enable=true -- quiet append vga=788 initrd=/install.amd/initrd.gz rescue/enable=true -- quiet
EOF EOF
# Copy to main cfg
cp isolinux/isolinux-auto.cfg isolinux/isolinux.cfg
echo "✅ Boot configuration updated"
fi
# Update GRUB for UEFI boot
if [ -f boot/grub/grub.cfg ]; then
echo "Updating grub.cfg for preseed..."
cp boot/grub/grub.cfg boot/grub/grub.cfg.bak
cat > boot/grub/grub-preseed.cfg <<EOF
set timeout=5
set default=0
menuentry "Install Football Secure Access System" {
linux /install.amd/vmlinuz auto=true priority=critical file=/cdrom/preseed.cfg
initrd /install.amd/initrd.gz
}
menuentry "Manual Install" {
linux /install.amd/vmlinuz
initrd /install.amd/initrd.gz
}
EOF
cp boot/grub/grub-preseed.cfg boot/grub/grub.cfg
echo "✅ GRUB configuration updated"
fi
echo "" echo ""
echo "✅ Preseed and scripts injected" echo "✅ Preseed and scripts injected"
echo "Contents of ISO/scripts/:" echo "Contents of scripts/:"
ls -la /build/iso-tmp/extracted/scripts/ ls -la scripts/
echo ""
echo "Contents of config/:"
ls -la config/
echo ""
echo "✅ Step 3 complete"
echo "" echo ""
echo "Contents of ISO/config/:"
ls -la /build/iso-tmp/extracted/config/
'
echo "" # ============================================================================
echo "✅ Step 3 complete" # Step 4: Create New ISO
echo "" # ============================================================================
# ============================================================================ echo "[4/5] Creating new ISO with preseed..."
# Step 4: Create ISO
# ============================================================================
echo "[4/5] Creating new ISO with preseed..." # Ensure output directory exists
mkdir -p /build/output
mkdir -p "$OUTPUT_DIR"
docker run --rm \
--name football-iso-create \
-v "$BUILD_DIR:/build" \
debian:stable \
bash -c '
set -e
echo "Creating ISO..."
cd /build/iso-tmp/extracted
# Create new ISO with preseed and scripts
xorriso -as mkisofs \ xorriso -as mkisofs \
-r -V "Football Secure System" \ -r -V "Football Secure System" \
-o /build/output/football-installer.iso \ -o /build/output/football-installer.iso \
-J -l -b isolinux/isolinux.bin \ -J -l \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \ -c isolinux/boot.cat \
-no-emul-boot \ -no-emul-boot \
-boot-load-size 4 \ -boot-load-size 4 \
@@ -192,55 +217,60 @@ docker run --rm \
echo "" echo ""
echo "✅ ISO created" echo "✅ ISO created"
ls -lh /build/output/football-installer.iso ls -lh /build/output/football-installer.iso
' echo ""
echo "✅ Step 4 complete"
echo ""
echo "" # ============================================================================
echo "✅ Step 4 complete" # Step 5: Verify ISO
echo "" # ============================================================================
# ============================================================================ echo "[5/5] Verifying ISO..."
# Step 5: Verify ISO
# ============================================================================
echo "[5/5] Verifying ISO..."
docker run --rm \
-v "$BUILD_DIR:/build" \
debian:trixie \
bash -c '
echo "ISO information:" echo "ISO information:"
file /build/output/football-installer.iso file /build/output/football-installer.iso
echo "" echo ""
echo "ISO size:" echo "ISO size:"
ls -lh /build/output/football-installer.iso ls -lh /build/output/football-installer.iso
echo "" echo ""
echo "✅ ISO verified" echo "✅ Step 5 complete"
echo ""
# ============================================================================
# Cleanup
# ============================================================================
echo "Cleaning up temporary directories..."
cd /build
rm -rf "$ISO_DIR"
echo ""
echo "================================================"
echo "ISO BUILD COMPLETE"
echo "================================================"
echo ""
echo "Output file:"
echo " 📁 /build/output/football-installer.iso"
echo ""
echo "Usage:"
echo " 1. Write ISO to USB: sudo dd if=/build/output/football-installer.iso of=/dev/sdX bs=4M status=progress"
echo " 2. Boot from USB"
echo " 3. Installer will automatically use preseed configuration"
echo " 4. User only needs to provide:"
echo " - Username"
echo " - User password (min 12 chars, mixed case, numbers, special chars)"
echo " - Root password (min 12 chars, mixed case, numbers, special chars)"
echo " - Target disk for installation"
echo ""
echo "✅ BUILD COMPLETE!"
echo ""
' '
echo "" echo ""
echo "✅ Step 5 complete"
echo ""
# ============================================================================
# Summary
# ============================================================================
echo "================================================" echo "================================================"
echo "ISO BUILD COMPLETE" echo "Build finished on host"
echo "================================================" echo "================================================"
echo "" echo ""
echo "Output file:" echo "ISO Location: $OUTPUT_DIR/football-installer.iso"
echo " 📁 $OUTPUT_DIR/football-installer.iso" ls -lh "$OUTPUT_DIR/football-installer.iso"
echo ""
echo "Usage:"
echo " 1. Write ISO to USB: sudo dd if=$OUTPUT_DIR/football-installer.iso of=/dev/sdX bs=4M status=progress"
echo " 2. Boot from USB"
echo " 3. Installer will automatically use preseed configuration"
echo " 4. User only needs to provide:"
echo " - Username"
echo " - User password (min 12 chars, mixed case, numbers, special chars)"
echo " - Root password (min 12 chars, mixed case, numbers, special chars)"
echo " - Target disk for installation"
echo ""
echo "✅ BUILD COMPLETE!"
echo "" echo ""