#!/bin/bash set -e # Clone or update extract-xiso source from GitHub # Tool for creating and extracting Xbox ISO images (XISO format) SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" XISO_DIR="$SCRIPT_DIR/src" XISO_REPO="https://github.com/XboxDev/extract-xiso.git" echo "╔════════════════════════════════════════════════════════════════╗" echo "║ extract-xiso Source Management ║" echo "╚════════════════════════════════════════════════════════════════╝" echo "" if [ -d "$XISO_DIR" ]; then echo "📂 extract-xiso source directory exists: $XISO_DIR" echo "" cd "$XISO_DIR" # Check if it's a git repo if [ -d .git ]; then echo "🔄 Updating existing extract-xiso repository..." # Show current status CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) CURRENT_COMMIT=$(git rev-parse --short HEAD) echo " Current branch: $CURRENT_BRANCH" echo " Current commit: $CURRENT_COMMIT" # Fetch updates echo "" echo "🌐 Fetching latest changes from GitHub..." git fetch --tags # Show available tags (recent releases) echo "" echo "📋 Recent extract-xiso releases:" git tag --sort=-version:refname | head -10 || echo " No tags found" echo "" read -p "🤔 Update to latest commit? (y/N) " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then echo "⬆️ Pulling latest changes..." git pull NEW_COMMIT=$(git rev-parse --short HEAD) echo "✅ Updated to commit: $NEW_COMMIT" else echo "ℹ️ Keeping current version" fi # Optionally checkout a specific tag echo "" read -p "🏷️ Checkout a specific release tag? (leave empty to skip) " TAG if [ -n "$TAG" ]; then echo "🔀 Checking out tag: $TAG" git checkout "$TAG" echo "✅ Now on tag: $TAG" fi else echo "⚠️ Directory exists but is not a git repository!" echo " Please remove $XISO_DIR and run this script again." exit 1 fi else echo "📥 Cloning extract-xiso repository from GitHub..." echo " Repository: $XISO_REPO" echo " Target: $XISO_DIR" echo "" # This is a small repository, no need for shallow clone echo "📚 Cloning repository..." git clone "$XISO_REPO" "$XISO_DIR" cd "$XISO_DIR" echo "" echo "✅ Clone completed successfully!" # Show available tags echo "" echo "📋 Available extract-xiso releases:" git tag --sort=-version:refname | head -10 || echo " No tags found" fi # Record version information VERSION_FILE="$SCRIPT_DIR/VERSION.txt" cd "$XISO_DIR" COMMIT=$(git rev-parse HEAD) SHORT_COMMIT=$(git rev-parse --short HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD) DATE=$(git log -1 --format=%cd --date=short) TAG=$(git describe --tags --exact-match 2>/dev/null || echo "no tag") echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "📝 Current extract-xiso Source Version" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" cat > "$VERSION_FILE" << EOF extract-xiso Source Version Information Generated: $(date) Commit: $COMMIT Short: $SHORT_COMMIT Branch: $BRANCH Tag: $TAG Date: $DATE Repository: $XISO_REPO EOF cat "$VERSION_FILE" echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "✅ extract-xiso source is ready!" echo "" echo "Next steps:" echo " 1. Run ./build.sh to build extract-xiso" echo " 2. Built binary will be in: $SCRIPT_DIR/build/extract-xiso" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"