#!/bin/bash
# MTK Flash Tool for macOS - Installation Script
echo "==================================="
echo "  MTK Flash Tool for macOS"
echo "  Installation"
echo "==================================="
echo ""

# Check Python
if ! command -v python3 &> /dev/null; then
    echo "ERROR: Python 3 is required. Install via: brew install python3"
    exit 1
fi

# Check brew
if ! command -v brew &> /dev/null; then
    echo "ERROR: Homebrew is required. Install from https://brew.sh"
    exit 1
fi

# Install libusb
echo "[1/3] Installing libusb..."
brew list libusb &>/dev/null || brew install libusb

# Install Python packages
echo "[2/3] Installing Python packages..."
pip3 install pyusb PySide6 --break-system-packages 2>/dev/null || pip3 install pyusb PySide6

# Make executable
echo "[3/3] Setting permissions..."
chmod +x gui.py mtk_flash.py

echo ""
echo "Installation complete!"
echo ""
echo "To run:"
echo "  sudo python3 $(pwd)/gui.py"
echo ""
echo "NOTE: sudo is required for USB access on macOS."
