Subject: [PATCH] testing/softether: new aport

From: Ben Weiss <[email-masked]>
Date: Wed, 23 Nov 2022 14:04:20 -0600

https://www.softether.org
SoftEther VPN client and server
---
 testing/softether/APKBUILD        | 83 +++++++++++++++++++++++++++++++
 testing/softether/Makefile.patch  | 70 ++++++++++++++++++++++++++
 testing/softether/configure.patch | 11 ++++
 testing/softether/vpnbridge.initd | 16 ++++++
 testing/softether/vpnclient.initd | 16 ++++++
 testing/softether/vpnserver.initd | 16 ++++++
 6 files changed, 212 insertions(+)
 create mode 100644 testing/softether/APKBUILD
 create mode 100644 testing/softether/Makefile.patch
 create mode 100644 testing/softether/configure.patch
 create mode 100644 testing/softether/vpnbridge.initd
 create mode 100644 testing/softether/vpnclient.initd
 create mode 100644 testing/softether/vpnserver.initd

diff --git a/testing/softether/APKBUILD b/testing/softether/APKBUILD
new file mode 100644
index 0000000000..47ad727915
--- /dev/null
+++ b/testing/softether/APKBUILD
@@ -0,0 +1,83 @@
+# Contributor: bweiss <[email-masked]>
+# Maintainer: bweiss <[email-masked]>
+_buildnumber=9760
+_buildtype=rtm
+pkgname=softether
+pkgver=4.38
+pkgrel=0
+pkgdesc="Softether VPN"
+url="http://www.softether.org"
+arch="all"
+license="Apache-2.0"
+depends_openrc="$pkgname-client ||
+	$pkgname-server ||
+	$pkgname-bridge"
+#note- if running a custom kernel, CONFIG_TUN must be set
+makedepends="readline-dev
+	openssl-dev
+	zlib-dev"
+source="https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v$pkgver-$_buildnumber-$_buildtype/softether-src-v$pkgver-$_buildnumber-$_buildtype.tar.gz
+	vpnclient.initd
+	vpnserver.initd
+	vpnbridge.initd
+	configure.patch
+	Makefile.patch"
+builddir="$srcdir/v$pkgver-$_buildnumber"
+options="!check" #no tests are implemented
+subpackages="
+	$pkgname-client
+	$pkgname-server
+	$pkgname-bridge
+	$pkgname-openrc"
+
+prepare() {
+	#need to run configure to create the Makefile, _then_ patch the Makefile
+	./configure
+	default_prepare
+}
+
+build() {
+	make
+}
+
+#base installs only libraries and management utility- then server, client, or bridge can be installed as desired seperately.
+
+package() {
+	pkgdesc="$pkgdesc main library and configuration utility"
+	make DESTDIR="$pkgdir" install
+}
+
+client() {
+	pkgdesc="$pkgdesc client"
+	depends="$depends softether"
+	echo $pkgdir
+	echo $subpkgdir
+	amove "usr/vpnclient/*"
+	amove "usr/bin/vpnclient"
+	install -Dm755 "$srcdir"/vpnclient.initd "$pkgdir"/etc/init.d/vpnclient
+}
+
+server() {
+	pkgdesc="$pkgdesc server"
+	depends="$depends softether"
+	amove "usr/vpnserver/*"
+	amove "usr/bin/vpnserver"
+	install -Dm755 "$srcdir"/vpnserver.initd "$pkgdir"/etc/init.d/vpnserver
+}
+
+bridge() {
+	pkgdesc="$pkgdesc bridge"
+	depends="$depends softether"
+	amove "usr/vpnbridge/*"
+	amove "usr/bin/vpnbridge"
+	install -Dm755 "$srcdir"/vpnbridge.initd "$pkgdir"/etc/init.d/vpnbridge
+}
+
+sha512sums="
+48be7a4a014f85967bb3beb906a7ff34b51e0828ff4cf9844520815fc83333f453fb71b6924fe62050c3e96cab03266f92465aadb8f2d83bec2addfe9f18c8a8  softether-src-v4.38-9760-rtm.tar.gz
+333b58e1c945fefc25227eba7f5de21ec12e1c12f50ddc9fa0763272c19eb9c4c64239b7e540b7e35808440913e1448be7cf4ed3495624cc9bbf209a5fd6a49f  vpnclient.initd
+d511a56418d46ca75dfb61b73850f70ed161a1129397ef6f68938004bce54540196c8e7e56a1ef8402293b81eac1a54b98220a9b2926e6a1df719d22c47cf1c3  vpnserver.initd
+a52e1d9b535957df3c0abda34d75d367f5d83278009fdad58c43cf71557cd1901039e216dda00b23cc2bbef8de14a33f5cc04d6ab3ac247b9113bf2273dfb1f6  vpnbridge.initd
+a935d7a5fcfb0794534cfbfe65fc5993f0e667303fe2caed9daa8ab020622e75ded9af971378707aed231f9b24f2b727327a8ca9cb2f5180c2889bf8d2855686  configure.patch
+cf9c2608795b41252b06c2a0308a85107bad2620e41a92ef4f1794a4c6e5e74f41926d5c05bafa8e4285ccca994d67f14174f1632f036a5c70be87f9f8693953  Makefile.patch
+"
diff --git a/testing/softether/Makefile.patch b/testing/softether/Makefile.patch
new file mode 100644
index 0000000000..9ecc25b28b
--- /dev/null
+++ b/testing/softether/Makefile.patch
@@ -0,0 +1,70 @@
+--- a/Makefile	2021-08-17 13:50:52.000000000 +0000
++++ b/Makefile	2022-04-06 17:42:59.049551598 +0000
+@@ -70,11 +70,15 @@ OPTIONS_COMPILE_RELEASE=-DNDEBUG -DVPN_S
+ 
+ OPTIONS_LINK_RELEASE=-O2 -fsigned-char -m64 -lm -ldl -lrt -lpthread -lssl -lcrypto -lreadline -lncurses -lz
+ 
+-INSTALL_BINDIR=/usr/bin/
+-INSTALL_VPNSERVER_DIR=/usr/vpnserver/
+-INSTALL_VPNBRIDGE_DIR=/usr/vpnbridge/
+-INSTALL_VPNCLIENT_DIR=/usr/vpnclient/
+-INSTALL_VPNCMD_DIR=/usr/vpncmd/
++INSTALL_BINDIR=$(DESTDIR)/usr/bin/
++INSTALL_VPNSERVER_DIR=$(DESTDIR)/usr/vpnserver/
++INSTALL_VPNBRIDGE_DIR=$(DESTDIR)/usr/vpnbridge/
++INSTALL_VPNCLIENT_DIR=$(DESTDIR)/usr/vpnclient/
++INSTALL_VPNCMD_DIR=$(DESTDIR)/usr/vpncmd/
++SCRIPT_INSTALL_VPNSERVER_DIR=/usr/vpnserver/
++SCRIPT_INSTALL_VPNBRIDGE_DIR=/usr/vpnbridge/
++SCRIPT_INSTALL_VPNCLIENT_DIR=/usr/vpnclient/
++SCRIPT_INSTALL_VPNCMD_DIR=/usr/vpncmd/
+ 
+ ifeq ($(DEBUG),YES)
+ 	OPTIONS_COMPILE=$(OPTIONS_COMPILE_DEBUG)
+@@ -429,38 +433,42 @@ install: $(INSTALL_BINDIR)vpnserver $(IN
+ 	@echo
+ 
+ $(INSTALL_BINDIR)vpnserver: bin/vpnserver/hamcore.se2 bin/vpnserver/vpnserver
++	@mkdir -p $(INSTALL_BINDIR) 
+ 	@mkdir -p $(INSTALL_VPNSERVER_DIR)
+ 	cp bin/vpnserver/hamcore.se2 $(INSTALL_VPNSERVER_DIR)hamcore.se2
+ 	cp bin/vpnserver/vpnserver $(INSTALL_VPNSERVER_DIR)vpnserver
+ 	echo "#!/bin/sh" > $(INSTALL_BINDIR)vpnserver
+-	echo $(INSTALL_VPNSERVER_DIR)vpnserver '"$$@"' >> $(INSTALL_BINDIR)vpnserver
++	echo $(SCRIPT_INSTALL_VPNSERVER_DIR)vpnserver '"$$@"' >> $(INSTALL_BINDIR)vpnserver
+ 	echo 'exit $$?' >> $(INSTALL_BINDIR)vpnserver
+ 	chmod 755 $(INSTALL_BINDIR)vpnserver
+ 
+ $(INSTALL_BINDIR)vpnbridge: bin/vpnbridge/hamcore.se2 bin/vpnbridge/vpnbridge
++	@mkdir -p $(INSTALL_BINDIR) 
+ 	@mkdir -p $(INSTALL_VPNBRIDGE_DIR)
+ 	cp bin/vpnbridge/hamcore.se2 $(INSTALL_VPNBRIDGE_DIR)hamcore.se2
+ 	cp bin/vpnbridge/vpnbridge $(INSTALL_VPNBRIDGE_DIR)vpnbridge
+ 	echo "#!/bin/sh" > $(INSTALL_BINDIR)vpnbridge
+-	echo $(INSTALL_VPNBRIDGE_DIR)vpnbridge '"$$@"' >> $(INSTALL_BINDIR)vpnbridge
++	echo $(SCRIPT_INSTALL_VPNBRIDGE_DIR)vpnbridge '"$$@"' >> $(INSTALL_BINDIR)vpnbridge
+ 	echo 'exit $$?' >> $(INSTALL_BINDIR)vpnbridge
+ 	chmod 755 $(INSTALL_BINDIR)vpnbridge
+ 
+ $(INSTALL_BINDIR)vpnclient: bin/vpnclient/hamcore.se2 bin/vpnclient/vpnclient
++	@mkdir -p $(INSTALL_BINDIR) 
+ 	@mkdir -p $(INSTALL_VPNCLIENT_DIR)
+ 	cp bin/vpnclient/hamcore.se2 $(INSTALL_VPNCLIENT_DIR)hamcore.se2
+ 	cp bin/vpnclient/vpnclient $(INSTALL_VPNCLIENT_DIR)vpnclient
+ 	echo "#!/bin/sh" > $(INSTALL_BINDIR)vpnclient
+-	echo $(INSTALL_VPNCLIENT_DIR)vpnclient '"$$@"' >> $(INSTALL_BINDIR)vpnclient
++	echo $(SCRIPT_INSTALL_VPNCLIENT_DIR)vpnclient '"$$@"' >> $(INSTALL_BINDIR)vpnclient
+ 	echo 'exit $$?' >> $(INSTALL_BINDIR)vpnclient
+ 	chmod 755 $(INSTALL_BINDIR)vpnclient
+ 
+ $(INSTALL_BINDIR)vpncmd: bin/vpncmd/hamcore.se2 bin/vpncmd/vpncmd
++	@mkdir -p $(INSTALL_BINDIR) 
+ 	@mkdir -p $(INSTALL_VPNCMD_DIR)
+ 	cp bin/vpncmd/hamcore.se2 $(INSTALL_VPNCMD_DIR)hamcore.se2
+ 	cp bin/vpncmd/vpncmd $(INSTALL_VPNCMD_DIR)vpncmd
+ 	echo "#!/bin/sh" > $(INSTALL_BINDIR)vpncmd
+-	echo $(INSTALL_VPNCMD_DIR)vpncmd '"$$@"' >> $(INSTALL_BINDIR)vpncmd
++	echo $(SCRIPT_INSTALL_VPNCMD_DIR)vpncmd '"$$@"' >> $(INSTALL_BINDIR)vpncmd
+ 	echo 'exit $$?' >> $(INSTALL_BINDIR)vpncmd
+ 	chmod 755 $(INSTALL_BINDIR)vpncmd
+ 
diff --git a/testing/softether/configure.patch b/testing/softether/configure.patch
new file mode 100644
index 0000000000..69c6910bd9
--- /dev/null
+++ b/testing/softether/configure.patch
@@ -0,0 +1,11 @@
+--- configure.orig	2021-08-17 13:56:35.000000000 +0000
++++ v4.38-9760/configure	2022-01-17 23:28:46.559026639 +0000
+@@ -83,7 +83,7 @@ esac
+ 
+ CPU=""
+ case "`uname -m`" in
+-x86_64|amd64|aarch64|arm64|armv8*|mips64|ppc64|sparc64|alpha|ia64)
++x86_64|amd64|aarch64|arm64|armv8*|mips64|ppc64|ppc64le|sparc64|alpha|ia64|s390x)
+ 	CPU=64bit
+ 	;;
+ i?86|x86pc|i86pc|armv4*|armv5*|armv6*|armv7*)
diff --git a/testing/softether/vpnbridge.initd b/testing/softether/vpnbridge.initd
new file mode 100644
index 0000000000..3d3f85fd3c
--- /dev/null
+++ b/testing/softether/vpnbridge.initd
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+
+description="Starts or Stops the Softether VPN Bridge"
+procname="vpnbridge"
+
+start(){
+	ebegin "Starting Softether VPN Bridge"
+	/usr/bin/vpnbridge start
+	eend $?
+}
+
+stop(){
+	ebegin "Stopping Softether VPN Bridge"
+	/usr/bin/vpnbridge stop
+	eend $?
+}
diff --git a/testing/softether/vpnclient.initd b/testing/softether/vpnclient.initd
new file mode 100644
index 0000000000..e391ed5353
--- /dev/null
+++ b/testing/softether/vpnclient.initd
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+
+description="Starts or Stops the Softether VPN client"
+procname="vpnclient"
+
+start(){
+	ebegin "Starting Softether VPN Client"
+	/usr/bin/vpnclient start
+	eend $?
+}
+
+stop(){
+	ebegin "Stopping Softether VPN Client"
+	/usr/bin/vpnclient stop
+	eend $?
+}
diff --git a/testing/softether/vpnserver.initd b/testing/softether/vpnserver.initd
new file mode 100644
index 0000000000..e9844c3491
--- /dev/null
+++ b/testing/softether/vpnserver.initd
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+
+description="Starts or Stops the Softether VPN Server"
+procname="vpnserver"
+
+start(){
+	ebegin "Starting Softether VPN Server"
+	/usr/bin/vpnserver start
+	eend $?
+}
+
+stop(){
+	ebegin "Stopping Softether VPN Server"
+	/usr/bin/vpnserver stop
+	eend $?
+}
-- 
2.36.3