# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=grommunio-index
pkgdesc="Generator for grommunio-web search indexes"
pkgver=1.3
pkgrel=0
arch="all"
url="https://grommunio.com"
license="AGPL-3.0-only"
subpackages="$pkgname-doc"
options="!check" # No test suite
install="$pkgname.pre-install $pkgname.pre-upgrade $pkgname.post-upgrade"
makedepends="cmake samurai libexmdbpp-dev libhx-dev libxml2-dev sqlite-dev>=3.27 mariadb-connector-c-dev"

source="$pkgname-$pkgver.tar.gz::https://github.com/grommunio/grommunio-index/archive/refs/tags/$pkgver.tar.gz
	0001-makefile.patch

	$pkgname.cron
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_SKIP_INSTALL_RPATH=ON

	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

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

	# install cronjob
	install -Dm755 "$srcdir"/$pkgname.cron "$pkgdir"/etc/periodic/15min/$pkgname

}

sha512sums="
ec04fdbbd4c71a54bce6a4406818516b2540944cb659dc660be8d24474f118d7f4d3273dddf422e47890a1ce93edae5cfcc075ab1f0455fe67b85b7fa7706365  grommunio-index-1.3.tar.gz
da97bc2ae8294dc843b52e101a940af4bc5201b417fea9928face2de25a91e92b6800b3837dbaf3841ae7e7e8037c3e014fe08be180911f4aa65eb174f17d858  0001-makefile.patch
6b594679d6ca937b6b52ece05b3a7dca908d693ab823b866dea5105defcc8ab7462a3aba9101ac6e4eb61b9397d81dd20ecc20598efb5521062e3611bb8b050d  grommunio-index.cron
"
