# Maintainer:
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>

pkgname=cjdns
pkgver=20
pkgrel=1
pkgdesc="A routing engine designed for security, scalability, speed and ease of use"
url="https://github.com/cjdelisle/cjdns"
arch="all !x86 !s390x"
license="GPL-3.0"
makedepends="nodejs python2 linux-headers libseccomp-dev"
install="$pkgname.post-install"
subpackages="$pkgname-doc"
source="${pkgname}-${pkgver}.tar.gz::https://github.com/cjdelisle/${pkgname}/archive/cjdns-v${pkgver}.tar.gz"

builddir="$srcdir/$pkgname-$pkgname-v$pkgver"

build() {
	cd "$builddir"
	export CJDNS_RELEASE_VERSION="${pkgver}"
	sh 'do'
}

check() {
	cd "$builddir"
	./cjdroute --help >/dev/null
}

package() {
	cd "$builddir"
	install -Dm755 cjdroute "$pkgdir/usr/sbin/cjdroute"
	install -Dm755 contrib/openrc/cjdns "$pkgdir/etc/init.d/cjdns"
	install -Dm644 doc/man/cjdroute.conf.5 \
		"${pkgdir}/usr/share/man/man5/cjdroute.conf.5"
	install -Dm 644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
	install -Dm644 -t "${pkgdir}/usr/share/doc/${pkgname}" \
		doc/admin-api.md \
		doc/configure.md \
		doc/djc_layer_model.md \
		doc/nat-gateway.md \
		doc/network-services.md \
		doc/non-root-user.md \
		doc/security_specification.md \
		doc/shorewall_and_vpn_gateway_howto.md \
		doc/tunnel.md
}

sha512sums="afa63daea3c3bd3e16dd0a326ebdc2afcb411c595e66552c3156c59c36af21c0b2278b3299b1053b98d381790311beeb14547afdf3d182170c446867d2199a94  cjdns-20.tar.gz"
