# Maintainer: LAN.party Team <packaging@lan.party>
pkgname=discord-gameserver-notifier
pkgver=VERSION_PLACEHOLDER
pkgrel=1
pkgdesc="Automated Discord notifications for LAN gameservers"
arch=('any')
url="https://github.com/lan-dot-party/Discord-Gameserver-Notifier"
license=('GPL3')
depends=('python>=3.7' 'python-pip' 'python-virtualenv' 'python-yaml' 'systemd')
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-hatchling')
install=discord-gameserver-notifier.install
source=("WHEEL_FILENAME_PLACEHOLDER"
        "discord-gameserver-notifier.service"
        "discord-gameserver-notifier-exec"
        "discord-gameserver-notifier.install"
        "config.yaml.example"
        "config.yaml.service-example"
        "config.yaml.unified")
sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')

build() {
    # No build step needed for wheel installation
    true
}

package() {
    # Get Python version dynamically
    PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
    
    # Install the wheel to site-packages for the install script to find it
    install -Dm644 "$srcdir/WHEEL_FILENAME_PLACEHOLDER" \
        "$pkgdir/usr/lib/python${PYTHON_VERSION}/site-packages/WHEEL_FILENAME_PLACEHOLDER"
    
    # Install systemd service (from source directory)
    install -Dm644 "$srcdir/discord-gameserver-notifier.service" \
        "$pkgdir/usr/lib/systemd/system/discord-gameserver-notifier.service"
    
    # Install executable wrapper (from source directory)
    install -Dm755 "$srcdir/discord-gameserver-notifier-exec" \
        "$pkgdir/usr/bin/discord-gameserver-notifier"
    
    # Create required directories
    install -dm755 "$pkgdir/etc/dgn"
    install -dm755 "$pkgdir/var/lib/dgn"
    install -dm755 "$pkgdir/var/log/dgn"
    install -dm755 "$pkgdir/opt"
    
    # Install example configurations (from source directory)
    install -Dm644 "$srcdir/config.yaml.example" \
        "$pkgdir/usr/share/doc/$pkgname/config.yaml.example"
    install -Dm644 "$srcdir/config.yaml.service-example" \
        "$pkgdir/usr/share/doc/$pkgname/config.yaml.service-example"
    install -Dm644 "$srcdir/config.yaml.unified" \
        "$pkgdir/usr/share/doc/$pkgname/config.yaml.unified"
} 