deb-bootc-image-builder/scripts/integration-scripts/demo-alternative-solution.sh
robojerk 126ee1a849
Some checks failed
particle-os CI / Test particle-os (push) Failing after 1s
particle-os CI / Integration Test (push) Has been skipped
particle-os CI / Security & Quality (push) Failing after 1s
Test particle-os Basic Functionality / test-basic (push) Failing after 1s
particle-os CI / Build and Release (push) Has been skipped
cleanup
2025-08-27 12:30:24 -07:00

156 lines
4.5 KiB
Bash
Executable file

#!/bin/bash
# Demonstration of working alternative solution
# Shows complete Debian Atomic pipeline: debootstrap + ostree → bootable image
set -euo pipefail
echo "🚀 Debian Atomic Pipeline Demonstration"
echo "Using working alternative solution: debootstrap + ostree"
echo "=" * 60
# Configuration
WORKSPACE_PATH="/home/rob/Documents/Projects/overseer"
DEB_BOOTC_PATH="$WORKSPACE_PATH/deb-bootc-image-builder"
ATOMIC_CONFIGS_PATH="$WORKSPACE_PATH/debian-atomic-configs"
# Step 1: Create OSTree commit using alternative solution
echo
echo "Step 1: Creating OSTree commit using debootstrap + ostree"
echo "Running: create-debian-atomic.py minimal"
cd "$ATOMIC_CONFIGS_PATH"
# Run the alternative solution with a persistent work directory
WORK_DIR="/tmp/debian-atomic-demo"
if [[ -d "$WORK_DIR" ]]; then
rm -rf "$WORK_DIR"
fi
echo "Creating persistent build in: $WORK_DIR"
if distrobox-enter debian-trixie -- bash -c "cd '$ATOMIC_CONFIGS_PATH' && sudo python3 create-debian-atomic.py minimal '$WORK_DIR'"; then
echo "✅ Step 1 completed: OSTree commit created successfully"
else
echo "❌ Step 1 failed"
exit 1
fi
# Step 2: Verify the repository and commit
echo
echo "Step 2: Verifying OSTree repository and commit"
REPO_PATH="$WORK_DIR/repo"
if [[ ! -d "$REPO_PATH" ]]; then
echo "❌ Repository not found at $REPO_PATH"
exit 1
fi
echo "✅ Repository found at: $REPO_PATH"
# List references
echo "Repository references:"
ostree refs --repo="$REPO_PATH" || echo "No references found"
# List commits
echo "Repository commits:"
find "$REPO_PATH/objects" -type d -name "????????????????????????????????????????????????????????????????" 2>/dev/null | head -5 || echo "No commits found"
# Step 3: Extract rootfs from OSTree commit
echo
echo "Step 3: Extracting rootfs from OSTree commit"
ROOTFS_PATH="/tmp/debian-atomic-rootfs"
if [[ -d "$ROOTFS_PATH" ]]; then
rm -rf "$ROOTFS_PATH"
fi
# Get the reference
REF_FILE=$(find "$REPO_PATH/refs" -type f | head -1)
if [[ -z "$REF_FILE" ]]; then
echo "❌ No reference found"
exit 1
fi
COMMIT_ID=$(cat "$REF_FILE")
echo "Using commit: $COMMIT_ID"
# Extract rootfs
echo "Extracting rootfs to: $ROOTFS_PATH"
if ostree checkout --repo="$REPO_PATH" --subpath=/ "$COMMIT_ID" "$ROOTFS_PATH"; then
echo "✅ Rootfs extracted successfully"
else
echo "❌ Failed to extract rootfs"
exit 1
fi
# Verify rootfs structure
if [[ -d "$ROOTFS_PATH/usr" ]] && [[ -d "$ROOTFS_PATH/etc" ]]; then
echo "✅ Rootfs structure verified"
else
echo "❌ Invalid rootfs structure"
exit 1
fi
# Step 4: Create bootable image
echo
echo "Step 4: Creating bootable image using deb-bootc-image-builder"
# Build deb-bootc-image-builder if needed
BIB_BIN="$DEB_BOOTC_PATH/bib/create-ostree-bootable-image"
if [[ ! -f "$BIB_BIN" ]]; then
echo "Building deb-bootc-image-builder..."
cd "$DEB_BOOTC_PATH"
if ! go build -o bib/create-ostree-bootable-image ./bib/create-ostree-bootable-image.go; then
echo "❌ Failed to build deb-bootc-image-builder"
exit 1
fi
echo "✅ deb-bootc-image-builder built successfully"
fi
# Create bootable image
OUTPUT_IMAGE="/tmp/debian-atomic-minimal.img"
echo "Creating bootable image: $OUTPUT_IMAGE"
if "$BIB_BIN" "$ROOTFS_PATH" "$OUTPUT_IMAGE"; then
echo "✅ Bootable image created successfully"
# Show image information
if [[ -f "$OUTPUT_IMAGE" ]]; then
IMAGE_SIZE=$(du -h "$OUTPUT_IMAGE" | cut -f1)
echo "Image size: $IMAGE_SIZE"
# Copy to workspace
FINAL_IMAGE="$WORKSPACE_PATH/debian-atomic-minimal-demo.img"
cp "$OUTPUT_IMAGE" "$FINAL_IMAGE"
echo "Image copied to: $FINAL_IMAGE"
echo
echo "🎉 Pipeline completed successfully!"
echo
echo "📋 Summary:"
echo "✅ OSTree commit created using debootstrap + ostree"
echo "✅ Rootfs extracted from OSTree commit"
echo "✅ Bootable image created: $FINAL_IMAGE"
echo
echo "🧪 To test the image:"
echo "qemu-system-x86_64 -m 2G -drive file=$FINAL_IMAGE,format=raw -nographic"
else
echo "❌ Output image not found"
exit 1
fi
else
echo "❌ Failed to create bootable image"
exit 1
fi
echo
echo "🔍 Repository details:"
echo "Repository: $REPO_PATH"
echo "Commit: $COMMIT_ID"
echo "Rootfs: $ROOTFS_PATH"
echo "Image: $OUTPUT_IMAGE"
echo
echo "💡 This demonstrates that the alternative solution (debootstrap + ostree)"
echo " is fully functional and can generate bootable images, bypassing the"
echo " apt-ostree integration issues."