# Contributor: Johannes Heimansberg <git@jhe.dedyn.io>
# Maintainer: Johannes Heimansberg <git@jhe.dedyn.io>
pkgname=stubby
pkgver=0.4.3
pkgrel=0
pkgdesc="DNS Privacy stub resolver"
url="https://dnsprivacy.org/dns_privacy_daemon_-_stubby/"
arch="all"
license="BSD-3-Clause"
subpackages="$pkgname-doc $pkgname-openrc"
makedepends="cmake
	getdns-dev
	libcap-utils
	openssl-dev
	samurai
	yaml-dev
"
checkdepends="check"
pkgusers="stubby"
pkggroups="stubby"
source="$pkgname-$pkgver.tar.gz::https://github.com/getdnsapi/stubby/archive/refs/tags/v$pkgver.tar.gz
	stubby.confd
	stubby.initd
	"
options="!check" # no tests

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		cmake_crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DENABLE_GETDNS_STATIC_LINK=OFF \
		$cmake_crossopts
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rmdir -p "$pkgdir"/var/run || true
	install -Dm644 "$srcdir"/stubby.confd "$pkgdir"/etc/conf.d/stubby
	install -Dm755 "$srcdir"/stubby.initd "$pkgdir"/etc/init.d/stubby
}

sha512sums="
422d46b03200178acab6129d0268b5732fa2f439ad164c2ce771e68cd01737b4248d5a678ba0da716af41a24110f6b41ef3bcc567ad6fd94838a9be2d2cc8da3  stubby-0.4.3.tar.gz
1ca2464264d938f880460a27dc92325a30fa35c26461bf69dba2f17849b2d6450ba3bec704ead19148daf06f882c2d60f99dc8f970d0229e62040b793aca9517  stubby.confd
85a5be32a757de431cf419754a77ff7e10c7ab8a0277d37748fa37ec6f75acc6973cd1774c031729190ba760a11325874e1813924e5430bd3638149ffbd5c3a3  stubby.initd
"
