# Maintainer: Thomas Liske <thomas@fiasko-nw.net>
pkgname=birdwatcher
pkgver=2.2.5
pkgrel=12
pkgdesc="A JSON API for BIRD"
url="https://github.com/alice-lg/birdwatcher"
arch="all"
license="BSD-3-Clause"
makedepends="go"
options="net"
install="$pkgname.pre-install"
source="birdwatcher-$pkgver.tar.gz::https://github.com/alice-lg/birdwatcher/archive/refs/tags/$pkgver.tar.gz
	birdwatcher6.initd
	birdwatcher.initd
	"
subpackages="$pkgname-openrc"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -o birdwatcher
}

check() {
	go test -v
}

package() {
	install -Dm755 birdwatcher "$pkgdir"/usr/bin/birdwatcher
	install -Dm644 etc/birdwatcher/birdwatcher.conf "$pkgdir"/etc/birdwatcher/birdwatcher.conf
	# fix the default config for bird 2.x+
	sed -i -e 's@birdc6@birdc@' -e 's@bird6.conf@bird.conf@' "$pkgdir"/etc/birdwatcher/birdwatcher.conf
	install -Dm755 "$srcdir"/birdwatcher.initd "$pkgdir"/etc/init.d/birdwatcher
	install -Dm755 "$srcdir"/birdwatcher6.initd "$pkgdir"/etc/init.d/birdwatcher6
}

sha512sums="
1e0292635b5eedb987ed0da2f077f94730039274bc194c5686246c83fbd329f59809ffb55d32fe1810fd06d69f86a648daf7facecb93aba572b6e12a1cc4440e  birdwatcher-2.2.5.tar.gz
c4b0ab6b386ad7b4741c5a34e23ddcf9f7b5be3c23fb5dd1a34b5be0eb81a40e281f18d1e89b17a744e6b98a7b1331f6a32b4dc1902cbcaa4765e9d7d668ad82  birdwatcher6.initd
2297d192e54d565c1a465956ee6a68934f46df53c1cc14292dfc344dae92c412fca3531179bf2a9542fe62c54a87aaef1f2e76302dc650ccebc81e5b32525ad3  birdwatcher.initd
"
