# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=nebula
pkgver=1.9.5
pkgrel=3
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="
efdbceb05e0aa3958f81e6915d94f08a18e979ecf7cdf52c3158750a4b6131a72f15f1cb67b6756f8520ec7b2e2a57a437212d5386373abe9545ba7709bacbb3  nebula-1.9.5.tar.gz
0db0013e3cecb761c89c92ddd1a2a58d7630673b47d387f7c0c757987d5aa8d9b0f21ffa462ebec814c821bfe3b19b026941414950681c560239d479f9893ae6  unset-CGO_ENABLED.patch
b86a38a0e558f2bc00b062d713cd3ad3e6b5e7a0695c92d7bfe5633edb80184fcd64ebf5af6c35677c91719159dad8cd38c2278b5f4d9f5d2e42f101e6e354b2  nebula.initd
"
