#!/bin/bash

# libostree-dev Download Script
# This script helps download the latest libostree-dev backport

set -e

echo "=== libostree-dev Download Script ==="
echo ""

# Get the latest successful build
LATEST_BUILD_URL="https://git.raines.xyz/robojerk/libostree-dev/actions/runs/97"
echo "Latest successful build: $LATEST_BUILD_URL"
echo ""

echo "To download the latest libostree-dev packages:"
echo "1. Visit: $LATEST_BUILD_URL"
echo "2. Scroll down to the 'Artifacts' section"
echo "3. Download the 'release-assets' artifact"
echo "4. Extract the archive to get the .deb files"
echo ""

echo "Available packages:"
echo "- libostree-dev_2025.2-1~noble1_amd64.deb"
echo "- libostree-dev-dbgsym_2025.2-1~noble1_amd64.ddeb"
echo ""

echo "Installation command (after downloading):"
echo "sudo dpkg -i libostree-dev_2025.2-1~noble1_amd64.deb"
echo "sudo apt-get install -f"
echo ""

echo "Verification:"
echo "pkg-config --modversion ostree-1"
echo ""

echo "Opening build page in browser..."
if command -v xdg-open >/dev/null 2>&1; then
    xdg-open "$LATEST_BUILD_URL"
elif command -v open >/dev/null 2>&1; then
    open "$LATEST_BUILD_URL"
else
    echo "Please manually visit: $LATEST_BUILD_URL"
fi 