pkgname=extore
pkgver=0.11.1
pkgrel=1
pkgdesc='Single-merchant redemption and fulfillment service'
arch=('x86_64')
url='https://github.com/TokenNotIncluded/extore'
license=('MIT')
depends=('python' 'bubblewrap>=0.12' 'libseccomp')
makedepends=('uv')
options=('!strip' '!debug')
backup=('etc/extore/extore.env')
source=('extore-source.tar.gz')
sha256sums=('SKIP')

build() {
  cd "$srcdir/extore-source"
  uv sync --frozen --no-dev --no-editable --python /usr/bin/python --no-managed-python
}

package() {
  cd "$srcdir/extore-source"
  install -d "$pkgdir/usr/lib/extore"
  cp -a .venv "$pkgdir/usr/lib/extore/"
  # Services and scripts launch via python -m; omit source-bound entrypoints.
  find "$pkgdir/usr/lib/extore/.venv/bin" -type f -delete
  rm -f "$pkgdir"/usr/lib/extore/.venv/lib/python*/site-packages/extore-*.dist-info/direct_url.json
  install -Dm644 deploy/arch/extore-api.service "$pkgdir/usr/lib/systemd/system/extore-api.service"
  install -Dm644 deploy/arch/extore-worker.service "$pkgdir/usr/lib/systemd/system/extore-worker.service"
  install -Dm644 deploy/arch/extore.sysusers "$pkgdir/usr/lib/sysusers.d/extore.conf"
  install -Dm644 deploy/arch/extore.env "$pkgdir/etc/extore/extore.env"
  install -Dm755 deploy/arch/extore-admin "$pkgdir/usr/bin/extore-admin"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 processors/official/LICENSE "$pkgdir/usr/share/licenses/$pkgname/official-processors-LICENSE"
}
