#!/bin/bash # Create Test OSTree Environment with apt-ostree # This script sets up a test environment to validate apt-ostree functionality set -e echo "๐Ÿงช Setting up apt-ostree test environment..." # Configuration TEST_DIR="/tmp/apt-ostree-test" OSTREE_REPO="$TEST_DIR/repo" DEPLOY_DIR="$TEST_DIR/deploy" APT_OSTREE_BIN="./target/release/apt-ostree" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Function to print colored output 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 apt-ostree binary exists if [ ! -f "$APT_OSTREE_BIN" ]; then print_error "apt-ostree binary not found at $APT_OSTREE_BIN" print_status "Building apt-ostree..." cargo build --release fi # Create test directory structure print_status "Creating test directory structure..." mkdir -p "$TEST_DIR" mkdir -p "$OSTREE_REPO" mkdir -p "$DEPLOY_DIR" # Initialize OSTree repository print_status "Initializing OSTree repository..." ostree --repo="$OSTREE_REPO" init --mode=bare # Create a basic package list for testing print_status "Creating test package list..." cat > "$TEST_DIR/packages.txt" << EOF # Basic system packages for testing base-files base-passwd bash coreutils dpkg apt apt-utils # Development tools for testing build-essential git curl wget # System utilities systemd systemd-sysv # Network tools net-tools iproute2 EOF # Create apt-ostree configuration print_status "Creating apt-ostree configuration..." cat > "$TEST_DIR/apt-ostree.conf" << EOF [ostree] repo = $OSTREE_REPO branch = test/debian/stable [apt] sources = deb http://deb.debian.org/debian stable main sources = deb http://deb.debian.org/debian-security stable-security main sources = deb http://deb.debian.org/debian stable-updates main [packages] file = $TEST_DIR/packages.txt EOF print_success "Test environment setup complete!" echo "" echo "๐Ÿ“ Test environment created at: $TEST_DIR" echo "๐Ÿ“ฆ OSTree repository: $OSTREE_REPO" echo "๐Ÿ”ง apt-ostree binary: $APT_OSTREE_BIN" echo "" echo "๐Ÿš€ Next steps:" echo "1. Initialize apt-ostree: $APT_OSTREE_BIN init --repo=$OSTREE_REPO" echo "2. Install packages: $APT_OSTREE_BIN install --repo=$OSTREE_REPO --packages-file=$TEST_DIR/packages.txt" echo "3. Deploy system: $APT_OSTREE_BIN deploy --repo=$DEPLOY_DIR" echo "" echo "๐Ÿ“‹ Test commands:" echo "- Status: $APT_OSTREE_BIN status" echo "- List packages: $APT_OSTREE_BIN list" echo "- Search packages: $APT_OSTREE_BIN search bash" echo "- Show info: $APT_OSTREE_BIN info bash"