_pkgname=slidcord
pkgname="$_pkgname-git"
pkgver=r327.b3ad55d
pkgrel=1
pkgdesc='A feature-rich Discord to XMPP gateway'
arch=('x86_64' 'armv7h' 'aarch64')
url="https://codeberg.org/slidge/slidcord"
license=('AGPL-3.0-or-later')
depends=('python' 'python-slidge' 'python-emoji' 'python-discord.py-self')
makedepends=('git' 'python-setuptools' 'python-setuptools-scm')
source=(
	"git+$url"
	"$_pkgname.service"
	"$_pkgname.sysusers"
	"$_pkgname.tmpfiles"
)
sha256sums=('SKIP'
            '7d5091ec61bfb57e4e1a28726ca70b3c50b9f07a07cb0d6181d9bb39493c823d'
            '11ec643e2bb3ff65455e5d966053be62141c51a7e2521ede76ce78034360ae74'
            'c7b387b8b2f2b266fcefb3f69552d605398858e378c0c88288ca6d371e605590')

pkgver() {
  cd $_pkgname
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

prepare() {
	git -C "${srcdir}/${_pkgname}" clean -dfx
}

build() {
  cd $_pkgname
  python -m build --wheel --no-isolation
}

package() {
  # systemd files
  install -Dm755 $_pkgname.service "$pkgdir/usr/lib/systemd/system/$_pkgname.service"
  install -Dm755 $_pkgname.sysusers "$pkgdir/usr/lib/sysusers.d/$_pkgname.conf"
  install -Dm755 $_pkgname.tmpfiles "$pkgdir/usr/lib/tmpfiles.d/$_pkgname.conf"

  cd $_pkgname
  python -m installer --destdir="$pkgdir" dist/*.whl
}
