# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=heplify
pkgver=1.66.2
pkgrel=4
pkgdesc="Multi-Protocol Go HEP Capture Agent made Simple"
url="http://sipcapture.io"
arch="all !riscv64 !ppc64le !loongarch64" # FTBFS, luajit
license="AGPL-3.0-or-later"
makedepends="go libpcap-dev linux-headers luajit-dev"
subpackages="$pkgname-openrc"
options="net !check" #https://github.com/sipcapture/heplify/issues/286
source="$pkgname-$pkgver.tar.gz::https://github.com/sipcapture/heplify/archive/refs/tags/v$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	"

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

prepare() {
	default_prepare
	go mod download
	# required for tests
	go get -t github.com/sipcapture/heplify/ip6defrag
}

build() {
	go build -ldflags "-s -w"  -o heplify main.go
}

check() {
	go test -v -skip "sniffer" ./...
}

package() {
	install -D -m755 heplify "$pkgdir"/usr/bin/$pkgname
	install -D -m755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -D -m644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="
1ddc412c2a596e0b546681882dccf904d7b2958e71a3cc268dfdc75744f6c3917a811cfac4268bcc810b7c39fe63144940137acc0963756ebd6356e4fb3ed63a  heplify-1.66.2.tar.gz
d71005c23c156526ece1bece54e432f6e35748caba756adaee195ed6873a303ae5926e693bd5cfbe0560e3ecd74d3b66f8319869bfc5997541a6dab52ea71c01  heplify.initd
9fc9e65e2bd83f52f78759c1aff2a45326deb1ccc66423957ca024b4c648c8c0430af0ab423020d4a4da67b27b1411999d756d3b82ec1b3ddc802ee8b38c1ac7  heplify.confd
"
