Subject: [PATCH v2] testing/yggdrasil: new aport

From: Drew DeVault <[email-masked]>
Date: Sun, 28 Jun 2020 14:10:14 -0600

---
This needs to run as root, I mistakenly created a user for yggdrasil in
v1.

 testing/yggdrasil/APKBUILD        | 48 +++++++++++++++++++++++++++++++
 testing/yggdrasil/modules.conf    |  1 +
 testing/yggdrasil/yggdrasil.confd |  4 +++
 testing/yggdrasil/yggdrasil.initd | 21 ++++++++++++++
 4 files changed, 74 insertions(+)
 create mode 100644 testing/yggdrasil/APKBUILD
 create mode 100644 testing/yggdrasil/modules.conf
 create mode 100644 testing/yggdrasil/yggdrasil.confd
 create mode 100644 testing/yggdrasil/yggdrasil.initd

diff --git a/testing/yggdrasil/APKBUILD b/testing/yggdrasil/APKBUILD
new file mode 100644
index 0000000000..5081fe24dd
--- /dev/null
+++ b/testing/yggdrasil/APKBUILD
@@ -0,0 +1,48 @@
+# Maintainer: Drew DeVault <[email-masked]>
+pkgname=yggdrasil
+pkgver=0.3.14
+pkgrel=0
+pkgdesc="An experiment in scalable routing as an encrypted IPv6 overlay network"
+url="https://yggdrasil-network.github.io/"
+arch="all"
+license="LGPL-3.0-only"
+makedepends="go"
+source="
+	$pkgname-$pkgver.tar.gz::https://github.com/yggdrasil-network/yggdrasil-go/archive/v$pkgver.tar.gz
+	$pkgname.confd
+	$pkgname.initd
+	modules.conf
+"
+builddir="$srcdir/$pkgname-go-$pkgver"
+options="!check" # upstream test suite is broken/unusual
+subpackages="$pkgname-openrc"
+
+build() {
+	go mod vendor
+	pkgsrc=github.com/yggdrasil-network/yggdrasil-go/src/version
+	LDFLAGS="$LDFLAGS -X $pkgsrc.buildName=$pkgname -X $PKGSRC.buildVersion=$pkgver"
+	for cmd in yggdrasil yggdrasilctl
+	do
+		go build \
+			-trimpath \
+			-mod=vendor \
+			-ldflags "-extldflags $LDFLAGS" \
+			./cmd/$cmd
+	done
+}
+
+package() {
+	install -Dm755 yggdrasil "$pkgdir"/usr/bin/yggdrasil
+	install -Dm755 yggdrasilctl "$pkgdir"/usr/bin/yggdrasilctl
+	install -Dm644 "$srcdir"/yggdrasil.confd \
+		"$pkgdir"/etc/conf.d/yggdrasil
+	install -Dm755 "$srcdir"/yggdrasil.initd \
+		"$pkgdir"/etc/init.d/yggdrasil
+	install -Dm644 "$srcdir"/modules.conf \
+		"$pkgdir"/etc/modules-load.d/yggdrasil.conf
+}
+
+sha512sums="3c3e92c7d49a08d2390a5d7226387c83b5575d55ae90b1209a103b50659ae60d978e39ee9247f548efe90228c3ce544b17bb205f9dcbc7f67262beaf9b7c38bf  yggdrasil-0.3.14.tar.gz
+089221d9dd703b21714ac5ec04f23218083d216ff259fdd76942c9b2089ee4ca908b360dca0c1f4fa2e0bb1de7d57f0c638d8db9bc782cbe0ed1733f6888171a  yggdrasil.confd
+2c08ea638be7632d930e0a80e85ce5311f6703870eada5ad41dd6033f1837a9a41b3d567af807e55004af1f06dfd69e6a49e321340e2b0113b73f5a25237879d  yggdrasil.initd
+871b650ff982be061532b4c5fe4812f41e6e2c58fc69b24f8a745f9a43389da44e742a69b0467b3c3d9e2b031af0728e20f10fa4584695c4f5ac87768a1fd34e  modules.conf"
diff --git a/testing/yggdrasil/modules.conf b/testing/yggdrasil/modules.conf
new file mode 100644
index 0000000000..0cb2f0a64b
--- /dev/null
+++ b/testing/yggdrasil/modules.conf
@@ -0,0 +1 @@
+tun
diff --git a/testing/yggdrasil/yggdrasil.confd b/testing/yggdrasil/yggdrasil.confd
new file mode 100644
index 0000000000..a162ffba4e
--- /dev/null
+++ b/testing/yggdrasil/yggdrasil.confd
@@ -0,0 +1,4 @@
+yggdrasil_config_file=/etc/yggdrasil.conf
+
+output_log=/var/log/yggdrasil.log
+error_log=/var/log/yggdrasil.log
diff --git a/testing/yggdrasil/yggdrasil.initd b/testing/yggdrasil/yggdrasil.initd
new file mode 100644
index 0000000000..9fab7d7c58
--- /dev/null
+++ b/testing/yggdrasil/yggdrasil.initd
@@ -0,0 +1,21 @@
+#!/sbin/openrc-run
+name="yggdrasil"
+description="An experiment in scalable routing as an encrypted IPv6 overlay network"
+supervisor=supervise-daemon
+command=/usr/bin/yggdrasil
+command_args="-useconffile $yggdrasil_config_file"
+command_user="yggdrasil:yggdrasil"
+
+depend() {
+	need net
+	after firewall
+	before radvd
+}
+
+start_pre() {
+	[ -n "$output_log" ] && checkpath -f "$output_log" \
+		-m 644 -o yggdrasil:yggdrasil || true
+	[ -n "$error_log" ] && checkpath -f "$error_log" \
+		-m 644 -o yggdrasil:yggdrasil || true
+	checkpath /var/run/yggdrasil.sock -m 755 -o yggdrasil:yggdrasil
+}
-- 
2.27.0