From ef69bf00c00d29d804d3cfa847a0996dd0e9e5b0 Mon Sep 17 00:00:00 2001
From: prspkt <prspkt@protonmail.com>
Date: Sun, 12 Jul 2020 09:46:48 +0300
Subject: [PATCH] community/softflowd: upgrade to 1.0.0

* Import upstream patch to fix building on musl.
* Import upstream patch to fix install path for softflowd and
  softflowctl binaries.
* Clarify license, modernize and update url and source links.
---
 community/softflowd/APKBUILD           | 33 ++++++++++++++++----------
 community/softflowd/fix-musl.patch     | 27 +++++++++++++++++++++
 community/softflowd/install-sbin.patch | 20 ++++++++++++++++
 3 files changed, 68 insertions(+), 12 deletions(-)
 create mode 100644 community/softflowd/fix-musl.patch
 create mode 100644 community/softflowd/install-sbin.patch

diff --git a/community/softflowd/APKBUILD b/community/softflowd/APKBUILD
index e0396912af86..d708a51a16fe 100644
--- a/community/softflowd/APKBUILD
+++ b/community/softflowd/APKBUILD
@@ -1,24 +1,31 @@
 # Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
 # Maintainer: Valery Kartel <valery.kartel@gmail.com>
 pkgname=softflowd
-pkgver=0.9.9
-pkgrel=1
+pkgver=1.0.0
+pkgrel=0
 pkgdesc="A software NetFlow probe"
-url="https://code.google.com/p/softflowd"
+url="https://github.com/irino/softflowd"
 arch="all"
-license="BSD"
+license="BSD-2-Clause"
 options="!check"
-makedepends="libpcap-dev"
+makedepends="autoconf automake libtool libpcap-dev"
 subpackages="$pkgname-doc"
-source="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/$pkgname/$pkgname-$pkgver.tar.gz
+source="https://github.com/irino/softflowd/archive/softflowd-1.0.0.tar.gz
 	$pkgname.initd
 	$pkgname.confd
+	install-sbin.patch
+	fix-musl.patch
 	"
-builddir="$srcdir/$pkgname-$pkgver"
+builddir="$srcdir/softflowd-softflowd-$pkgver"
+
+prepare() {
+	default_prepare
+	autoreconf -vfi
+}
 
 build() {
-	cd "$builddir"
-	./configure --prefix=/usr \
+	./configure \
+		--prefix=/usr \
 		--sysconfdir=/etc \
 		--localstatedir=/var \
 		--mandir=/usr/share/man \
@@ -27,11 +34,13 @@ build() {
 }
 
 package() {
-	make -C "$builddir" DESTDIR="$pkgdir" install
+	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="4d579c2a087c0f3cd4d2020bcfbddf9dab73254e40678b3509c93bec212bf8b5692f76bfb4e766577e431ff508f0bce0a2cf326184f192e3c5dc8ddf38514dbd  softflowd-0.9.9.tar.gz
+sha512sums="01a4f89755c957a495b08c49b572b8b6aa41f5ac7672feb5e31b039fbfab84f3a206b1da95b11de2ec5882123f6ca2387c02efb874ce707c2263bf79b56012fd  softflowd-1.0.0.tar.gz
 a049158fe474bb76e497613a7e2109b92047a37210bfe695b18b50cf7f5be5407896a11927d685fc03dec899c50bd6dbfeffdccf8e918ba515cfcab5dbd2b2a9  softflowd.initd
-10b536cb5d32edbfe5d1a09e2b4ded4d95cb2bbfbe44cdcf267958efe1cde440f0caf4f60e41b4a59164a471bf430527912daf2c47df42f0dc47997352689e5d  softflowd.confd"
+10b536cb5d32edbfe5d1a09e2b4ded4d95cb2bbfbe44cdcf267958efe1cde440f0caf4f60e41b4a59164a471bf430527912daf2c47df42f0dc47997352689e5d  softflowd.confd
+5644037692f7a165a8c06bd756181669f5847dad28c6b677b047407ca9412000ee25626110ea5037892321a0d520a27cba2f8aac488830182f1152fc08448088  install-sbin.patch
+e007238442cc9017fcb4a4a1b568e884691a7335cd6f8c270dd635d3725dcae92bf370837774475582e235ec501f74e53022442152d33fba8ab443eb27d8e0a2  fix-musl.patch"
diff --git a/community/softflowd/fix-musl.patch b/community/softflowd/fix-musl.patch
new file mode 100644
index 000000000000..6290cfc7d796
--- /dev/null
+++ b/community/softflowd/fix-musl.patch
@@ -0,0 +1,27 @@
+From 020dd2a325a15ba8bd995e5ea19ba23477b85e58 Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Sat, 28 Mar 2020 17:20:00 -0700
+Subject: [PATCH] fix compilation with musl
+
+__uid_t is a glibc type.
+---
+ common.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/common.h b/common.h
+index f963bec..edb69d1 100644
+--- a/common.h
++++ b/common.h
+@@ -179,10 +179,10 @@ struct ip6_ext {
+ 
+ /* following lines are copy from unistd.h in Linux for avoidance warnings in compilation */
+ #if defined(HAVE_SETRESGID) && !defined(_GNU_SOURCE)
+-extern int setresgid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);
++extern int setresgid (uid_t __ruid, uid_t __euid, uid_t __suid);
+ #endif
+ #if defined(HAVE_SETRESUID) && !defined(_GNU_SOURCE)
+-extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);
++extern int setresuid (uid_t __ruid, uid_t __euid, uid_t __suid);
+ #endif
+ 
+ #if defined (HAVE_DECL_HTONLL) && !defined (HAVE_DECL_HTOBE64)
diff --git a/community/softflowd/install-sbin.patch b/community/softflowd/install-sbin.patch
new file mode 100644
index 000000000000..2d93b18e0d1c
--- /dev/null
+++ b/community/softflowd/install-sbin.patch
@@ -0,0 +1,20 @@
+From 3681af73d21b3f34cb555de29b464b320e41745b Mon Sep 17 00:00:00 2001
+From: Hitoshi Irino <irino@sfc.wide.ad.jp>
+Date: Sat, 24 Aug 2019 07:14:56 +0900
+Subject: [PATCH] Changing installation directory from bin to sbin which is
+ original installation directory. (Issue #16)
+
+---
+ Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index ff58d6d..ca92000 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-bin_PROGRAMS = softflowd softflowctl
++sbin_PROGRAMS = softflowd softflowctl
+ COMMON = common.h convtime.h treetype.h sys-tree.h\
+   convtime.c strlcpy.c strlcat.c closefrom.c daemon.c
+ if ENABLE_LEGACY
-- 
GitLab