# Maintainer: Joachim Schlöffel <joachim.schloeffel@financial-service-plus.de>
pkgname=nifi-registry
pkgver=2.12.0
pkgrel=0
pkgdesc="Central registry for shared NiFi and MiNiFi resources"
url="https://nifi.apache.org/registry.html"
arch="x86_64 aarch64"
license="Apache-2.0"
depends="openjdk21-jre-headless"
makedepends="unzip"
install="$pkgname.pre-install"
pkgusers="nifi-registry"
pkggroups="nifi-registry"
subpackages="
	$pkgname-openrc:_openrc:noarch
	"
options="!check !strip !tracedeps"
source="
	$pkgname-$pkgver-bin.zip::https://dlcdn.apache.org/nifi/$pkgver/nifi-registry-$pkgver-bin.zip
	nifi-registry.confd
	nifi-registry.initd
	nifi-registry.wrapper
	"

package() {
	local _dir

	install -d "$pkgdir"/usr/lib/nifi-registry "$pkgdir"/etc/nifi-registry
	cp -a "$builddir"/. "$pkgdir"/usr/lib/nifi-registry/
	chmod -R a+rX "$pkgdir"/usr/lib/nifi-registry
	install -d "$pkgdir"/usr/lib/nifi-registry/docs

	cp -a "$pkgdir"/usr/lib/nifi-registry/conf/. "$pkgdir"/etc/nifi-registry/
	rm -r "$pkgdir"/usr/lib/nifi-registry/conf
	ln -s /etc/nifi-registry "$pkgdir"/usr/lib/nifi-registry/conf

	install -d -m 0750 -o nifi-registry -g nifi-registry \
		"$pkgdir"/var/lib/nifi-registry
	for _dir in database extension_bundles flow_storage work; do
		install -d -m 0750 -o nifi-registry -g nifi-registry \
			"$pkgdir"/var/lib/nifi-registry/$_dir
		ln -s /var/lib/nifi-registry/$_dir \
			"$pkgdir"/usr/lib/nifi-registry/$_dir
	done
	install -d -m 0750 -o nifi-registry -g nifi-registry \
		"$pkgdir"/var/log/nifi-registry
	ln -s /var/log/nifi-registry "$pkgdir"/usr/lib/nifi-registry/logs
	ln -s /run/nifi-registry "$pkgdir"/usr/lib/nifi-registry/run

	chown -R nifi-registry:nifi-registry "$pkgdir"/etc/nifi-registry
	chmod 0750 "$pkgdir"/etc/nifi-registry

	install -Dm755 "$srcdir"/nifi-registry.wrapper \
		"$pkgdir"/usr/bin/nifi-registry
}

_openrc() {
	pkgdesc="$pkgdesc (OpenRC service)"
	depends="$pkgname=$pkgver-r$pkgrel openrc"

	install -Dm755 "$srcdir"/nifi-registry.initd \
		"$subpkgdir"/etc/init.d/nifi-registry
	install -Dm644 "$srcdir"/nifi-registry.confd \
		"$subpkgdir"/etc/conf.d/nifi-registry
}

sha512sums="
f4410a082f264175bd2f2c8b3366ac61636f1736d8fb3685cee20d8076509ed05f413dfffaaa3ca9a2b1ba49ab510bb006c9ccc9decef0332906a13f8fb9e52b  nifi-registry-2.12.0-bin.zip
61d8f644a0a2f87b8d6d4ef9820d4195ee4fbaaa7da6ddba347197d4202a983a82b4f376a0ddb5c80c247d7af9d5b26d7890db325e3d124c5025b41cbd19c319  nifi-registry.confd
87116490a925d9e3133d1561baa06727bcd22637332d7ac35a7e7e8921427a68dc1b52d1560c733b5f8bd38d5ba9e82868dd9fd74d91e13efaa65b764d4b1936  nifi-registry.initd
1efcb07dbc83f4f1a3e138a16d142ffd825097ef7e209383129b2bc02266f277edc3973143bcc7498982359cffd829d999c9b944acc5860059396a2dd5112950  nifi-registry.wrapper
"
