commit:     22ea1a2297215693cd3d7d485c1b776258c21aa2
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 18 17:44:48 2022 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Fri Mar 18 17:46:27 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=22ea1a22

net-firewall/nftlb: add 1.0

Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>

 net-firewall/nftlb/Manifest                    |  1 +
 net-firewall/nftlb/files/nftlb-1.0-musl.patch  | 73 ++++++++++++++++++++++++++
 net-firewall/nftlb/files/nftlb-1.0-tests.patch | 45 ++++++++++++++++
 net-firewall/nftlb/nftlb-1.0.ebuild            | 61 +++++++++++++++++++++
 4 files changed, 180 insertions(+)

diff --git a/net-firewall/nftlb/Manifest b/net-firewall/nftlb/Manifest
index db2d378839cc..6fc0af900ead 100644
--- a/net-firewall/nftlb/Manifest
+++ b/net-firewall/nftlb/Manifest
@@ -1 +1,2 @@
 DIST nftlb-0.6.tar.gz 121216 BLAKE2B 
98b69c35070eb733a218ac1b1aaa7816de1e4f149c8447fee298b4cf50c57610c816fb178d4115e1e7af5cea0f5b20df36eb5b79655e0d7c69ff30e363985104
 SHA512 
95b879cfc187fe94cc6876f4af3fe77795c1e0228850cfb38b95206685d9065076b6905d365da7ec5f92773cf8f72f6e441d9140d9b10b02eaf9b6c862c31006
+DIST nftlb-1.0.tar.gz 195057 BLAKE2B 
b8237b7ba6f6f61dde726d53b63f2488bf38646984b252317ba0f47727ae91e5f4d58c32c0f0d609b134124efd29fdce2b9c10a981a3892220dac78c84946f48
 SHA512 
f93db34e4372d8f16e99650f3ade62908ce65722fadd521c6d698ab81b24502f6d82e1945b06b166876ebeb39e1907c97a40776ddf985b035b883e93f62e8766

diff --git a/net-firewall/nftlb/files/nftlb-1.0-musl.patch 
b/net-firewall/nftlb/files/nftlb-1.0-musl.patch
new file mode 100644
index 000000000000..399136754554
--- /dev/null
+++ b/net-firewall/nftlb/files/nftlb-1.0-musl.patch
@@ -0,0 +1,73 @@
+diff --git a/configure.ac b/configure.ac
+index 84bfd96..3f6f81d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2,6 +2,7 @@ AC_INIT([nftlb], [1.0], [netfilter-de...@vger.kernel.org])
+ 
+ AC_CONFIG_AUX_DIR([build-aux])
+ AC_CONFIG_MACRO_DIR([m4])
++AC_CONFIG_HEADERS([config.h])
+ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects
+         tar-pax no-dist-gzip dist-bzip2 1.6])
+ 
+@@ -25,5 +26,7 @@ AC_CHECK_HEADER([ev.h], [EVENTINC="-include ev.h"],
+                                [EVENTINC="-include libev/ev.h"],
+                                [AC_MSG_ERROR([ev.h not found])])])
+ 
++AC_CHECK_HEADERS([execinfo.h])
++
+ AC_CONFIG_FILES([Makefile src/Makefile])
+ AC_OUTPUT
+diff --git a/src/main.c b/src/main.c
+index 9854f95..8e7df1d 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -18,6 +18,7 @@
+  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  *
+  */
++#include "config.h"
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -25,7 +26,10 @@
+ #include <string.h>
+ #include <errno.h>
+ #include <unistd.h>
++
++#ifdef HAVE_EXECINFO_H
+ #include <execinfo.h>
++#endif /* HAVE_EXECINFO_H */
+ 
+ #include "config.h"
+ #include "objects.h"
+@@ -88,6 +92,7 @@ static void nftlb_sighandler(int signo)
+       exit(EXIT_SUCCESS);
+ }
+ 
++#ifdef HAVE_EXECINFO_H
+ static void nftlb_trace() {
+       void *buffer[255];
+       char **str;
+@@ -109,6 +114,7 @@ static void nftlb_trace() {
+ 
+       exit(EXIT_FAILURE);
+ }
++#endif /* HAVE_EXECINFO_H */
+ 
+ int main(int argc, char *argv[])
+ {
+@@ -166,9 +172,13 @@ int main(int argc, char *argv[])
+ 
+       if (signal(SIGINT, nftlb_sighandler) == SIG_ERR ||
+           signal(SIGTERM, nftlb_sighandler) == SIG_ERR ||
++#ifdef HAVE_EXECINFO_H
+           signal(SIGPIPE, SIG_IGN) == SIG_ERR ||
+           signal(SIGABRT, nftlb_trace) == SIG_ERR ||
+           signal(SIGSEGV, nftlb_trace) == SIG_ERR) {
++#else
++          signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
++#endif /* HAVE_EXECINFO_H */
+               tools_printlog(LOG_ERR, "Error assigning signals");
+               return EXIT_FAILURE;
+       }

diff --git a/net-firewall/nftlb/files/nftlb-1.0-tests.patch 
b/net-firewall/nftlb/files/nftlb-1.0-tests.patch
new file mode 100644
index 000000000000..48685074cb83
--- /dev/null
+++ b/net-firewall/nftlb/files/nftlb-1.0-tests.patch
@@ -0,0 +1,45 @@
+diff --git a/tests/exec_tests.sh b/tests/exec_tests.sh
+index 2a30a07..7814f5a 100755
+--- a/tests/exec_tests.sh
++++ b/tests/exec_tests.sh
+@@ -36,6 +36,8 @@ fi
+ 
+ echo "-- Executing configuration tests"
+ 
++retval=0
++
+ for test in `ls -d ${TESTS}`; do
+       if [[ ! ${test} =~ ^..._ ]]; then
+               continue;
+@@ -58,6 +60,7 @@ for test in `ls -d ${TESTS}`; do
+ 
+       if [ $statusexec -ne 0 ]; then
+               echo -e "\e[31mNFT EXEC ERROR\e[0m"
++              retval=1
+               continue;
+       fi
+ 
+@@ -65,6 +68,7 @@ for test in `ls -d ${TESTS}`; do
+ 
+       if [ ! -f ${outputfile} ]; then
+               echo "Dump file doesn't exist"
++              retval=1
+               continue;
+       fi
+ 
+@@ -76,6 +80,7 @@ for test in `ls -d ${TESTS}`; do
+               rm -f ${reportfile}
+       else
+               echo -e "\e[31mNFT DUMP ERROR\e[0m"
++              retval=1
+               if [ $APPLY_REPORTS -eq 1 ]; then
+                       cat ${reportfile} > ${outputfile}
+                       echo -e "APPLIED"
+@@ -89,4 +94,7 @@ fi
+ 
+ if [ "`grep 'nft command error' /var/log/syslog`" != "" ]; then
+       echo -e "\e[33m* command errors found, please check syslog\e[0m"
++      retval=1
+ fi
++
++exit ${retval}

diff --git a/net-firewall/nftlb/nftlb-1.0.ebuild 
b/net-firewall/nftlb/nftlb-1.0.ebuild
new file mode 100644
index 000000000000..f1e9170bcbc4
--- /dev/null
+++ b/net-firewall/nftlb/nftlb-1.0.ebuild
@@ -0,0 +1,61 @@
+# Copyright 2020-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit linux-info autotools
+
+DESCRIPTION="nftables load balancer"
+HOMEPAGE="https://github.com/zevenet/nftlb";
+SRC_URI="https://github.com/zevenet/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="AGPL-3"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+DEPEND="
+       net-firewall/nftables:=[modern-kernel]
+       dev-libs/jansson:=
+       dev-libs/libev:=
+"
+RDEPEND="${DEPEND}"
+
+# tests need root access
+RESTRICT="test"
+
+PATCHES=(
+       "${FILESDIR}/nftlb-1.0-tests.patch"
+       "${FILESDIR}/nftlb-1.0-musl.patch"
+)
+
+pkg_setup() {
+       local CONFIG_CHECK="
+               ~NF_TABLES
+               ~NFT_NUMGEN
+               ~NFT_HASH
+               ~NF_NAT
+               ~IP_NF_NAT
+       "
+
+       linux-info_pkg_setup
+
+       if kernel_is lt 4 19; then
+               eerror "${PN} requires kernel version 4.19 or newer"
+       fi
+}
+
+src_prepare() {
+       default
+       eautoreconf
+}
+
+src_test() {
+       pushd tests >/dev/null || die
+
+       sed -e "s:/var/log/syslog:\"${T}/tests.log\":" \
+               -i exec_tests.sh || die
+
+       ./exec_tests.sh || die "tests failed"
+
+       popd >/dev/null || die
+}

Reply via email to