From 1d2675b9ac0370a9bfee031a1193027b986e6833 Mon Sep 17 00:00:00 2001
From: Dan Theisen <djt@hxx.in>
Date: Thu, 27 Sep 2018 23:47:03 -0700
Subject: [PATCH] user/iperf3: new package

---
 user/iperf3/APKBUILD              | 57 +++++++++++++++++++++++++++++++
 user/iperf3/build-fixes.patch     | 20 +++++++++++
 user/iperf3/iperf.confd           |  3 ++
 user/iperf3/iperf.initd           | 18 ++++++++++
 user/iperf3/remove-pg-flags.patch | 29 ++++++++++++++++
 5 files changed, 127 insertions(+)
 create mode 100644 user/iperf3/APKBUILD
 create mode 100644 user/iperf3/build-fixes.patch
 create mode 100644 user/iperf3/iperf.confd
 create mode 100644 user/iperf3/iperf.initd
 create mode 100644 user/iperf3/remove-pg-flags.patch

diff --git a/user/iperf3/APKBUILD b/user/iperf3/APKBUILD
new file mode 100644
index 0000000000..1e1fad9656
--- /dev/null
+++ b/user/iperf3/APKBUILD
@@ -0,0 +1,57 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Dan Theisen <djt@hxx.in>
+pkgname=iperf3
+_pkgname=iperf
+pkgver=3.6
+pkgrel=0
+pkgdesc="A tool to measure IP bandwidth using UDP or TCP"
+url="https://software.es.net/iperf/"
+arch="all"
+license="BSD-3-Clause"
+depends=""
+makedepends=""
+install=""
+subpackages="$pkgname-doc $pkgname-openrc"
+source="$pkgname-$pkgver.tar.gz::https://downloads.es.net/pub/$_pkgname/$_pkgname-$pkgver.tar.gz
+	$_pkgname.initd
+	$_pkgname.confd
+
+	build-fixes.patch
+	remove-pg-flags.patch
+	"
+builddir="$srcdir/$_pkgname-$pkgver"
+
+build() {
+	cd "$builddir"
+	CFLAGS="$CFLAGS -D_GNU_SOURCE"
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--prefix=/usr \
+		--sysconfdir=/etc \
+		--mandir=/usr/share/man \
+		--infodir=/usr/share/info
+	make
+}
+
+check() {
+	cd "$builddir"
+	make check
+}
+
+package() {
+	cd "$builddir"
+	make DESTDIR="$pkgdir" install
+
+	install -Dm755 "$srcdir"/$_pkgname.initd \
+		"$pkgdir"/etc/init.d/$_pkgname
+	install -Dm644 "$srcdir"/$_pkgname.confd \
+		"$pkgdir"/etc/conf.d/$_pkgname
+}
+
+sha512sums="322a6893ad28c6ce9c9849e8a0326408ed76f09bbb13591c01c3d051bd4777a2acdb8f5032b9d1bb37d47ad3818d8b18ab6c0be4d40559040eb7e57bbfc06f39  iperf3-3.6.tar.gz
+339fb04b41cce11e8ea8694d95c13af9c88e0d1143356d913ec810c9b11efa27212d585b5dcc49cc2eb860a6d8bc557092c8659d7d5cfe532c5afdb36f8eedf8  iperf.initd
+fb5e155fff568a72488cc1511d30358835a48bcce309f8f46d040160932b4a4ccb85040c27c60dee477900a25bd34c50eac21d1d0bea984b40faa401be2ba7e8  iperf.confd
+126043503eebf84bccf26758f18715eaf81131e2fc9ef1fe829e55acb2f14e97db18e9b890b8bf13c230ac80c7537615272af4e072808e25bde8ddd6f326f198  build-fixes.patch
+ed0fb3a3af0dae3e9f58ff6643cb15defdd31f65cf966a6013fdf2a7fd67a7f8ef522a7c8f3269bd43d5ca991a86d758526c384ebc0984b1403bb24f61a1779b  remove-pg-flags.patch"
diff --git a/user/iperf3/build-fixes.patch b/user/iperf3/build-fixes.patch
new file mode 100644
index 0000000000..b797e70ea5
--- /dev/null
+++ b/user/iperf3/build-fixes.patch
@@ -0,0 +1,20 @@
+--- a/src/t_timer.c
++++ b/src/t_timer.c
+@@ -33,6 +33,7 @@
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <sys/time.h>
++#include <sys/types.h>
+ 
+ #include "timer.h"
+ 
+--- a/src/t_uuid.c
++++ b/src/t_uuid.c
+@@ -28,6 +28,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <sys/time.h>
++#include <sys/types.h>
+ 
+ #include "iperf_util.h"
+  
diff --git a/user/iperf3/iperf.confd b/user/iperf3/iperf.confd
new file mode 100644
index 0000000000..1f425faa67
--- /dev/null
+++ b/user/iperf3/iperf.confd
@@ -0,0 +1,3 @@
+# Default option for iperf: --server (runs in TCP/5001 mode)
+# For further server options check --help flag
+command_args=""
diff --git a/user/iperf3/iperf.initd b/user/iperf3/iperf.initd
new file mode 100644
index 0000000000..a135bafc92
--- /dev/null
+++ b/user/iperf3/iperf.initd
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+
+command="/usr/bin/iperf"
+pidfile="/var/run/$SVCNAME/$SVCNAME.pid"
+
+depend() {
+	need net
+	after firewall
+}
+
+start() {
+	ebegin "Starting $SVCNAME"
+	start-stop-daemon --start --make-pid --user ${exec_user:-nobody} \
+		--pidfile ${pidfile} --background --exec $command \
+		-- --server ${command_args}
+	eend
+}
+
diff --git a/user/iperf3/remove-pg-flags.patch b/user/iperf3/remove-pg-flags.patch
new file mode 100644
index 0000000000..1ed47eebf5
--- /dev/null
+++ b/user/iperf3/remove-pg-flags.patch
@@ -0,0 +1,29 @@
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -50,9 +50,9 @@
+ iperf3_profile_SOURCES  = main.c \
+ 						  $(libiperf_la_SOURCES)
+ 
+-iperf3_profile_CFLAGS   = -pg -g
++iperf3_profile_CFLAGS   = -g
+ iperf3_profile_LDADD    = libiperf.la
+-iperf3_profile_LDFLAGS  = -pg -g
++iperf3_profile_LDFLAGS  = -g
+ 
+ # Specify the sources and various flags for the test cases
+ t_timer_SOURCES         = t_timer.c
+
+--- a/src/Makefile.in
++++ b/src/Makefile.in
+@@ -643,9 +643,9 @@
+ iperf3_profile_SOURCES = main.c \
+ 						  $(libiperf_la_SOURCES)
+ 
+-iperf3_profile_CFLAGS = -pg -g
++iperf3_profile_CFLAGS = -g
+ iperf3_profile_LDADD = libiperf.la
+-iperf3_profile_LDFLAGS = -pg -g
++iperf3_profile_LDFLAGS = -g
+ 
+ # Specify the sources and various flags for the test cases
+ t_timer_SOURCES = t_timer.c
-- 
GitLab