#!/bin/bash
# WF 2026-08-24
# install cam2web including the native gphoto2 package

pip install --upgrade pip
pip install .

OS_NAME=$(uname -s)
echo "installing cam2web on $OS_NAME"
case "$OS_NAME" in
    Darwin)
        # macOS
        if command -v brew >/dev/null 2>&1; then
            brew install gphoto2
        elif command -v port >/dev/null 2>&1; then
            sudo port install gphoto2
        else
            echo "Error: Homebrew or MacPorts is required to install gphoto2 on macOS."
            exit 1
        fi
        ;;

    Linux)
        # Linux (assuming Debian-based systems)
        sudo apt-get update
        sudo apt-get install -y gphoto2 libgphoto2-dev
        ;;

    *)
        echo "Unsupported OS: $OS_NAME"
        exit 1
        ;;
esac
