#!/bin/bash echo "=== Fixing OCI Implementation ===" echo "" # Backup the current main.rs echo "1. Creating backup..." cp src/main.rs src/main.rs.backup echo "✅ Backup created: src/main.rs.backup" # Fix the OCI implementation by uncommenting the working code echo "" echo "2. Fixing OCI implementation..." # Create a temporary file with the fixed implementation cat > src/main.rs.fixed << 'EOF' ComposeSubcommand::BuildImage { source, output, format } => { info!("Building OCI image from source: {} -> {} ({})", source, output, format); // Create OCI image builder let oci_builder = crate::oci::OciImageBuilder::new().await?; // Build the image match oci_builder.build_image_from_commit(source, &output, &format).await { Ok(image_path) => { println!("OCI image created successfully: {}", image_path); }, Err(e) => { eprintln!("Failed to create OCI image: {}", e); return Err(e.into()); } } }, EOF # Replace the broken implementation with the fixed one echo "3. Replacing broken implementation..." sed -i '/ComposeSubcommand::BuildImage { source, output, format } => {/,/^ },$/c\'"$(cat src/main.rs.fixed)" src/main.rs # Clean up temporary file rm src/main.rs.fixed echo "✅ OCI implementation fixed" # Build the project echo "" echo "4. Building project..." if cargo build --release; then echo "✅ Build successful" # Install the binaries echo "" echo "5. Installing binaries..." sudo cp target/release/apt-ostree /usr/bin/apt-ostree sudo cp target/release/apt-ostreed /usr/libexec/apt-ostreed echo "✅ Binaries installed" # Test the compose command echo "" echo "6. Testing compose command..." if apt-ostree compose build-image --help 2>/dev/null; then echo "✅ Compose build-image command working" else echo "❌ Compose build-image command still not working" fi else echo "❌ Build failed" echo "Restoring backup..." cp src/main.rs.backup src/main.rs exit 1 fi echo "" echo "=== FIX COMPLETE ===" echo "" echo "The OCI implementation has been restored. You can now use:" echo " apt-ostree compose build-image --output --format oci" echo "" echo "If you need to restore the backup:" echo " cp src/main.rs.backup src/main.rs"