#!/bin/bash # Simple integration test between apt-ostree and deb-bootc-image-builder # Tests each component individually to identify issues set -euo pipefail echo "๐Ÿงช Simple Integration Test: apt-ostree + deb-bootc-image-builder" echo "================================================================" # Configuration WORKSPACE_PATH="/home/rob/Documents/Projects/overseer" APT_OSTREE_PATH="$WORKSPACE_PATH/apt-ostree" DEB_BOOTC_PATH="$WORKSPACE_PATH/deb-bootc-image-builder" ATOMIC_CONFIGS_PATH="$WORKSPACE_PATH/debian-atomic-configs" # Test 1: Verify apt-ostree can create OSTree commits echo echo "โœ… Test 1: apt-ostree compose tree" echo "-----------------------------------" echo "Running apt-ostree compose tree in container..." # Create a simple working directory WORKDIR="./test-integration-$(date +%s)" mkdir -p "$WORKDIR" # Run apt-ostree compose tree echo "Command: podman run --rm --privileged -v $APT_OSTREE_PATH:/workspace:z -v $ATOMIC_CONFIGS_PATH:/configs:z -v $WORKDIR:/shared:z apt-ostree-builder:latest bash -c 'cd /workspace && ./target/release/apt-ostree compose tree /configs/treefiles/debian-minimal-apt-ostree.yaml --workdir /shared/apt-ostree-build'" if podman run --rm --privileged \ -v "$APT_OSTREE_PATH:/workspace:z" \ -v "$ATOMIC_CONFIGS_PATH:/configs:z" \ -v "$WORKDIR:/shared:z" \ apt-ostree-builder:latest \ bash -c "cd /workspace && ./target/release/apt-ostree compose tree /configs/treefiles/debian-minimal-apt-ostree.yaml --workdir /shared/apt-ostree-build"; then echo "โœ… apt-ostree compose tree completed successfully" # Check what was created echo echo "๐Ÿ“ Checking created files:" if [[ -d "$WORKDIR/apt-ostree-build" ]]; then echo "โœ… apt-ostree-build directory created" ls -la "$WORKDIR/apt-ostree-build/" if [[ -d "$WORKDIR/apt-ostree-build/repo" ]]; then echo "โœ… OSTree repository created" ls -la "$WORKDIR/apt-ostree-build/repo/" # Test 2: Verify OSTree repository is accessible echo echo "โœ… Test 2: OSTree repository access" echo "-----------------------------------" echo "Testing ostree checkout from repository..." # Extract the commit hash from the reference COMMIT_HASH=$(cat "$WORKDIR/apt-ostree-build/repo/refs/heads/debian/14/x86_64/minimal") if [[ -n "$COMMIT_HASH" ]]; then echo "Found commit: $COMMIT_HASH" # Test ostree checkout inside the container to avoid permission issues ROOTFS_DIR="$WORKDIR/rootfs" echo "Running ostree checkout in container..." if podman run --rm --privileged \ -v "$WORKDIR:/shared:z" \ apt-ostree-builder:latest \ bash -c "ostree checkout --repo=/shared/apt-ostree-build/repo --subpath=/ '$COMMIT_HASH' /shared/rootfs"; then echo "โœ… ostree checkout successful" echo "Rootfs structure:" ls -la "$ROOTFS_DIR/" # Test 3: Verify deb-bootc-image-builder can create bootable image echo echo "โœ… Test 3: deb-bootc-image-builder integration" echo "---------------------------------------------" echo "Testing create-ostree-bootable-image..." OUTPUT_IMAGE="$WORKDIR/debian-atomic-bootable.img" if "$DEB_BOOTC_PATH/bib/create-ostree-bootable-image" "$ROOTFS_DIR" "$OUTPUT_IMAGE"; then echo "โœ… Bootable image created successfully!" echo "Image: $OUTPUT_IMAGE" echo "Size: $(du -h "$OUTPUT_IMAGE" | cut -f1)" echo echo "๐ŸŽ‰ All integration tests passed!" echo "โœ… apt-ostree compose tree: Working" echo "โœ… OSTree repository access: Working" echo "โœ… deb-bootc-image-builder: Working" echo echo "๐Ÿงช To test the bootable image:" echo "qemu-system-x86_64 -m 2G -drive file=$OUTPUT_IMAGE,format=raw -nographic -serial stdio" # Copy image to persistent location for testing PERSISTENT_IMAGE="./debian-atomic-bootable-test.img" cp "$OUTPUT_IMAGE" "$PERSISTENT_IMAGE" echo "๐Ÿ“ Image copied to: $PERSISTENT_IMAGE" else echo "โŒ deb-bootc-image-builder failed" fi else echo "โŒ ostree checkout failed" fi else echo "โŒ No commit found in repository" fi else echo "โŒ OSTree repository not created" fi else echo "โŒ apt-ostree-build directory not created" fi else echo "โŒ apt-ostree compose tree failed" fi echo echo "๐Ÿงน Cleaning up test directory..." rm -rf "$WORKDIR" echo "โœ… Test completed"