# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=nebula
pkgver=1.9.4
pkgrel=5
pkgdesc="Scalable overlay networking tool with a focus on performance, simplicity and security"
url="https://github.com/slackhq/nebula"
license="MIT"
# tests seem to fail due to >32-bit allocs, probably doesn't work
# s390x: service_test timed out
arch="all !x86 !armhf !armv7 !s390x"
pkgusers="$pkgname"
pkggroups="$pkgname"
install="$pkgname.pre-install"
makedepends="go"
subpackages="$pkgname-openrc"
source="https://github.com/slackhq/nebula/archive/v$pkgver/nebula-$pkgver.tar.gz
	unset-CGO_ENABLED.patch
	$pkgname.initd
	"

# secfixes:
#   1.8.1-r0:
#     - CVE-2023-48795

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

build() {
	make BUILD_ARGS="$GOFLAGS" BUILD_NUMBER="$pkgver" bin
}

check() {
	make test
}

package() {
	install -Dm750 -o nebula -g nebula nebula -t "$pkgdir"/usr/sbin/

	install -Dm755 nebula-cert -t "$pkgdir"/usr/bin/

	install -Dm644 examples/config.yml -t "$pkgdir"/etc/$pkgname

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
95cac08d8d9d7586ca6d2625a4638ce7bae3d9a122bcab97eb5257d7c5ac1299602b2452524dff1dda0ad860072a71362bfb71e4019480ea3f7218c9548c83df  nebula-1.9.4.tar.gz
0db0013e3cecb761c89c92ddd1a2a58d7630673b47d387f7c0c757987d5aa8d9b0f21ffa462ebec814c821bfe3b19b026941414950681c560239d479f9893ae6  unset-CGO_ENABLED.patch
b86a38a0e558f2bc00b062d713cd3ad3e6b5e7a0695c92d7bfe5633edb80184fcd64ebf5af6c35677c91719159dad8cd38c2278b5f4d9f5d2e42f101e6e354b2  nebula.initd
"
