- ✅ Real package installation (replaced mock installation) - ✅ Real OSTree commit creation from installed packages - ✅ OCI image creation from both commits and rootfs - ✅ Full bootc compatibility with proper labels - ✅ Comprehensive test suite (test-bootc-apt-ostree.sh) - ✅ Container tool validation (skopeo, podman) - ✅ Updated compatibility reports for Ubuntu Questing - ✅ Fixed OCI schema version and field naming issues - ✅ Temporary directory lifecycle fixes - ✅ Serde rename attributes for OCI JSON compliance Ready for Aurora-style workflow deployment!
174 lines
No EOL
4 KiB
Bash
Executable file
174 lines
No EOL
4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Safe Test Environment Setup for apt-ostree
|
|
# This script creates an isolated container environment for testing apt-ostree
|
|
# without affecting the host system
|
|
|
|
set -e
|
|
|
|
echo "🔒 Setting up SAFE apt-ostree test environment..."
|
|
|
|
# Configuration
|
|
TEST_DIR="/tmp/apt-ostree-safe-test"
|
|
CONTAINER_NAME="apt-ostree-test"
|
|
IMAGE_NAME="debian:bookworm-slim"
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
print_status() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Check if we're in a container
|
|
if [ -f /.dockerenv ] || grep -q docker /proc/1/cgroup; then
|
|
print_error "Already running in a container. This script should be run on the host system."
|
|
exit 1
|
|
fi
|
|
|
|
# Check for required tools
|
|
print_status "Checking required tools..."
|
|
if ! command -v podman &> /dev/null; then
|
|
print_error "podman is required but not installed"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v ostree &> /dev/null; then
|
|
print_warning "ostree not found on host - will install in container"
|
|
fi
|
|
|
|
# Create test directory
|
|
print_status "Creating test directory..."
|
|
mkdir -p "$TEST_DIR"
|
|
|
|
# Build apt-ostree binary
|
|
print_status "Building apt-ostree binary..."
|
|
if [ ! -f "./target/release/simple-cli" ]; then
|
|
cargo build --bin simple-cli --release
|
|
fi
|
|
|
|
# Copy binary to test directory
|
|
cp ./target/release/simple-cli "$TEST_DIR/apt-ostree"
|
|
|
|
# Create Dockerfile for test environment
|
|
print_status "Creating test container..."
|
|
cat > "$TEST_DIR/Dockerfile" << 'EOF'
|
|
FROM debian:bookworm-slim
|
|
|
|
# Install required packages
|
|
RUN apt-get update && apt-get install -y \
|
|
ostree \
|
|
apt \
|
|
dpkg \
|
|
systemd \
|
|
curl \
|
|
wget \
|
|
gnupg \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create test user
|
|
RUN useradd -m -s /bin/bash testuser
|
|
|
|
# Create test directories
|
|
RUN mkdir -p /test/ostree-repo /test/deploy /test/apt-ostree
|
|
|
|
# Copy apt-ostree binary
|
|
COPY apt-ostree /usr/local/bin/apt-ostree
|
|
RUN chmod +x /usr/local/bin/apt-ostree
|
|
|
|
# Set working directory
|
|
WORKDIR /test
|
|
|
|
# Switch to test user
|
|
USER testuser
|
|
|
|
# Initialize OSTree repository
|
|
RUN ostree --repo=ostree-repo init --mode=bare
|
|
|
|
# Create test script
|
|
COPY test-script.sh /test/test-script.sh
|
|
RUN chmod +x /test/test-script.sh
|
|
|
|
CMD ["/test/test-script.sh"]
|
|
EOF
|
|
|
|
# Create test script that runs inside container
|
|
cat > "$TEST_DIR/test-script.sh" << 'EOF'
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "🧪 Running apt-ostree tests in isolated environment..."
|
|
|
|
# Test 1: Basic commands
|
|
echo "Test 1: Basic commands"
|
|
apt-ostree --help
|
|
apt-ostree status
|
|
apt-ostree list | head -10
|
|
apt-ostree search bash | head -5
|
|
|
|
# Test 2: OCI commands
|
|
echo "Test 2: OCI commands"
|
|
apt-ostree oci --help
|
|
apt-ostree oci build --help
|
|
apt-ostree oci inspect --help
|
|
apt-ostree oci validate --help
|
|
|
|
# Test 3: Compose commands
|
|
echo "Test 3: Compose commands"
|
|
apt-ostree compose --help
|
|
apt-ostree compose tree --help
|
|
apt-ostree compose install --help
|
|
|
|
# Test 4: Package management (dry-run only)
|
|
echo "Test 4: Package management (dry-run)"
|
|
apt-ostree install --dry-run curl
|
|
apt-ostree upgrade --check
|
|
|
|
# Test 5: OSTree operations
|
|
echo "Test 5: OSTree operations"
|
|
ostree --repo=ostree-repo refs
|
|
ostree --repo=ostree-repo summary --update
|
|
|
|
echo "✅ All tests completed successfully in isolated environment!"
|
|
EOF
|
|
|
|
# Build container image
|
|
print_status "Building test container image..."
|
|
cd "$TEST_DIR"
|
|
podman build -t "$CONTAINER_NAME" .
|
|
|
|
# Run tests in container
|
|
print_status "Running tests in isolated container..."
|
|
podman run --rm \
|
|
-v "$TEST_DIR:/test:Z" \
|
|
"$CONTAINER_NAME"
|
|
|
|
# Cleanup
|
|
print_status "Cleaning up..."
|
|
podman rmi "$CONTAINER_NAME" 2>/dev/null || true
|
|
|
|
print_success "Safe test environment completed!"
|
|
echo ""
|
|
echo "🔒 Tests were run in an isolated container environment"
|
|
echo "📁 Test artifacts are in: $TEST_DIR"
|
|
echo "🧹 Container has been cleaned up"
|
|
echo ""
|
|
echo "✅ No changes were made to the host system" |