BareGit
pkgname=nethack-mcp
pkgver=r1.g0000000
pkgrel=1
pkgdesc='Multi-game NetHack server with an MCP interface'
arch=('x86_64')
url='https://git.xeno.darksair.org/nethack-mcp.git'
license=('custom:NetHack' 'MIT')
depends=('curl' 'openssl' 'sqlite' 'systemd')
makedepends=('cmake' 'git')
backup=('etc/nethack-mcp.toml')
source=(
    'nethack-mcp::git+https://git.xeno.darksair.org/nethack-mcp.git'
    'nethack-mcp.service'
    'nethack-mcp.sysusers'
    'nethack-mcp.tmpfiles'
    'nethack-mcp.toml'
)
sha256sums=(
    'SKIP'
    'a9ef1632e3afffa4785cbe0de2cf8cb9478ca67629eb41bca52b2fd15b129ab8'
    '1c1622cbd9842aa7a466abed401de52b273b0f20eb8ac590b67d6fea7c15c2fd'
    'bca01370008de9029018618153139f446a9b287245213bdb2ff6858945be2c6c'
    '55e5a896e8fbad99d0136f6b8a978b115e7fedb628c47018b440963a62a8a01d'
)

pkgver() {
    cd "$srcdir/nethack-mcp"
    printf 'r%s.g%s' \
        "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    cd "$srcdir"
    cmake -S nethack-mcp -B build \
        -DCMAKE_BUILD_TYPE=None \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DNETHACK_BUILD_ENGINE=ON \
        -DBUILD_TESTING=OFF \
        -Wno-dev
    cmake --build build
}

package() {
    install -Dm755 "$srcdir/build/nethack_mcp" \
        "$pkgdir/usr/bin/nethack_mcp"

    local runtime_dir="$srcdir/build/nethack-work/playground"
    install -d "$pkgdir/usr/share/nethack-mcp/runtime"
    for data_file in nhdat symbols license sysconf; do
        install -Dm644 "$runtime_dir/$data_file" \
            "$pkgdir/usr/share/nethack-mcp/runtime/$data_file"
    done

    install -Dm644 "$srcdir/nethack-mcp.toml" \
        "$pkgdir/etc/nethack-mcp.toml"
    install -Dm644 "$srcdir/nethack-mcp.sysusers" \
        "$pkgdir/usr/lib/sysusers.d/nethack-mcp.conf"
    install -Dm644 "$srcdir/nethack-mcp.tmpfiles" \
        "$pkgdir/usr/lib/tmpfiles.d/nethack-mcp.conf"
    install -Dm644 "$srcdir/nethack-mcp.service" \
        "$pkgdir/usr/lib/systemd/system/nethack-mcp.service"

    install -Dm644 "$runtime_dir/license" \
        "$pkgdir/usr/share/licenses/nethack-mcp/NetHack"
    install -Dm644 "$srcdir/build/_deps/tomlplusplus-src/LICENSE" \
        "$pkgdir/usr/share/licenses/nethack-mcp/MIT"
    install -Dm644 "$srcdir/build/_deps/lua-src/src/lua.h" \
        "$pkgdir/usr/share/licenses/nethack-mcp/Lua"
}