# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=grommunio-admin-web
pkgver=3.1.0
pkgrel=0
pkgdesc="Frontend for grommunio management"
# s390x: blocked by grommunio-gromox through grommunio-admin-api
# loongarch64: blocked by grommunio-admin-api
arch="noarch !riscv64 !s390x !loongarch64"
url="https://grommunio.com/"
license="AGPL-3.0-only"
options="!check" # No test suite
depends="grommunio-admin-api grommunio-admin-common"
makedepends="npm"

source="$pkgname-$pkgver.tar.gz::https://github.com/grommunio/admin-web/archive/refs/tags/$pkgver.tar.gz
	config.json
	eslint-deps.patch
	"

builddir="$srcdir/admin-web-$pkgver"

build() {
	echo $pkgver-$pkgrel > .version
	make YARN=npm
}

package() {
	# webapp
	install -dm0755 "$pkgdir/usr/share/webapps/"
	cp -rp build "$pkgdir/usr/share/webapps/$pkgname"

	# license
	install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

	# nginx conf
	sed -i "s@/usr/share/grommunio-admin-web@/usr/share/webapps/grommunio-admin-web@" conf/web.conf
	install -Dpm644 conf/web.conf "$pkgdir/usr/share/grommunio-admin-common/nginx.d/web.conf"

	# config.json
	install -Dm644 "$srcdir/config.json" "$pkgdir/etc/grommunio-admin-common/config.json"
}

sha512sums="
284d2a94be6f749d812192ee35730b3a85f0dc4f81af314e4573d1aded6a0ecb05ebbed2241ca8c3fa18e183ff96da1c33b1312e0a41ac5b1321774d857a88bc  grommunio-admin-web-3.1.0.tar.gz
41e6df23c37b786a214e3c41e1e53ee18a3bd2e6d6344245dc0879374685b0e986f5bc3daeb9068907856810457e3deca6840837d1938af55238335b2b6e99e3  config.json
93595d31f291158d8afd58c957d73724f6caeb2049bd26bd2126202585aa8b8dec1bf8887dd79ac025c808eba7c97a210f7d114818058b16ad287305a42aab40  eslint-deps.patch
"
