net-libs/liboping: remove -Werror
authorThomas Deutschmann <whissi@gentoo.org>
Mon, 14 Jan 2019 03:06:58 +0000 (04:06 +0100)
committerThomas Deutschmann <whissi@gentoo.org>
Mon, 14 Jan 2019 03:06:58 +0000 (04:06 +0100)
...and while we are here, add some upstream patches
for issues reported by Gentoo users.

Closes: https://bugs.gentoo.org/675344
Package-Manager: Portage-2.3.55, Repoman-2.3.12
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
net-libs/liboping/files/liboping-1.10.0-do-not-quit-when-ping_send-fail.patch [new file with mode: 0644]
net-libs/liboping/files/liboping-1.10.0-no-werror.patch [new file with mode: 0644]
net-libs/liboping/files/liboping-1.10.0-report-right-error-msg-when-select-fails.patch [new file with mode: 0644]
net-libs/liboping/liboping-1.10.0-r2.ebuild [new file with mode: 0644]

diff --git a/net-libs/liboping/files/liboping-1.10.0-do-not-quit-when-ping_send-fail.patch b/net-libs/liboping/files/liboping-1.10.0-do-not-quit-when-ping_send-fail.patch
new file mode 100644 (file)
index 0000000..ba0b13e
--- /dev/null
@@ -0,0 +1,53 @@
+From c768cc2270d49247357aa6c527f4c8fe2f81d493 Mon Sep 17 00:00:00 2001
+From: Florian Forster <ff@octo.it>
+Date: Thu, 14 Sep 2017 08:35:27 +0200
+Subject: [PATCH] src/oping.c: Don't quit when ping_send() fails.
+
+It appears that sendto(2) sometimes returns ENOBUFS when the upstream link
+is saturated, causing [n]oping to quit.
+
+Fixes: #28
+---
+ src/oping.c | 12 +++---------
+ 1 file changed, 3 insertions(+), 9 deletions(-)
+
+diff --git a/src/oping.c b/src/oping.c
+index 36cdf16..c087c80 100644
+--- a/src/oping.c
++++ b/src/oping.c
+@@ -2042,7 +2042,6 @@ int main (int argc, char **argv) /* {{{ */
+       while (opt_count != 0)
+       {
+               int index;
+-              int status;
+               if (gettimeofday (&tv_begin, NULL) < 0)
+               {
+@@ -2050,16 +2049,11 @@ int main (int argc, char **argv) /* {{{ */
+                       return (1);
+               }
+-              status = ping_send (ping);
+-              if (status == -EINTR)
+-              {
+-                      continue;
+-              }
+-              else if (status < 0)
++              if (ping_send (ping) < 0)
+               {
+                       fprintf (stderr, "ping_send failed: %s\n",
+                                       ping_get_error (ping));
+-                      return (1);
++                      continue;
+               }
+               index = 0;
+@@ -2086,7 +2080,7 @@ int main (int argc, char **argv) /* {{{ */
+               time_calc (&ts_wait, &ts_int, &tv_begin, &tv_end);
+               /* printf ("Sleeping for %i.%09li seconds\n", (int) ts_wait.tv_sec, ts_wait.tv_nsec); */
+-              while ((status = nanosleep (&ts_wait, &ts_wait)) != 0)
++              while (nanosleep (&ts_wait, &ts_wait) != 0)
+               {
+                       if (errno == EINTR)
+                       {
diff --git a/net-libs/liboping/files/liboping-1.10.0-no-werror.patch b/net-libs/liboping/files/liboping-1.10.0-no-werror.patch
new file mode 100644 (file)
index 0000000..3682622
--- /dev/null
@@ -0,0 +1,13 @@
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -2,10 +2,6 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
+ SUBDIRS = mans
+-if COMPILER_IS_GCC
+-AM_CFLAGS = -Wall -Werror
+-endif
+-
+ include_HEADERS = oping.h
+ lib_LTLIBRARIES = liboping.la
diff --git a/net-libs/liboping/files/liboping-1.10.0-report-right-error-msg-when-select-fails.patch b/net-libs/liboping/files/liboping-1.10.0-report-right-error-msg-when-select-fails.patch
new file mode 100644 (file)
index 0000000..ce1eea0
--- /dev/null
@@ -0,0 +1,33 @@
+From f9115d65b561adeb6d36ded952949f065ad0a572 Mon Sep 17 00:00:00 2001
+From: Florian Forster <ff@octo.it>
+Date: Thu, 14 Sep 2017 08:37:23 +0200
+Subject: [PATCH] src/liboping.c: Report right error message when select()
+ fails.
+
+After a successful call to gettimeofday(), the value of errno is
+unspecified.
+---
+ src/liboping.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/liboping.c b/src/liboping.c
+index eca5c16..5253e8c 100644
+--- a/src/liboping.c
++++ b/src/liboping.c
+@@ -1465,6 +1465,7 @@ int ping_send (pingobj_t *obj)
+                               (unsigned) timeout.tv_usec);
+               int status = select (max_fd + 1, &read_fds, &write_fds, NULL, &timeout);
++              int select_errno = errno;
+               if (gettimeofday (&nowtime, NULL) == -1)
+               {
+@@ -1474,7 +1475,7 @@ int ping_send (pingobj_t *obj)
+               if (status == -1)
+               {
+-                      ping_set_errno (obj, errno);
++                      ping_set_errno (obj, select_errno);
+                       dprintf ("select: %s\n", obj->errmsg);
+                       return (-1);
+               }
diff --git a/net-libs/liboping/liboping-1.10.0-r2.ebuild b/net-libs/liboping/liboping-1.10.0-r2.ebuild
new file mode 100644 (file)
index 0000000..e9ae55f
--- /dev/null
@@ -0,0 +1,77 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit autotools fcaps perl-module
+
+DESCRIPTION="Protocol independent ANSI-C ping library and command line utility"
+HOMEPAGE="https://noping.cc/"
+SRC_URI="https://noping.cc/files/${P}.tar.bz2"
+
+LICENSE="LGPL-2.1 GPL-2"
+SLOT="0/0.3"
+KEYWORDS="~alpha ~amd64 ~arm ~x86"
+IUSE="+filecaps ncurses perl"
+
+DEPEND="ncurses? ( sys-libs/ncurses:0= )"
+RDEPEND=${DEPEND}
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-1.10.0-no-werror.patch
+       "${FILESDIR}/${PN}-1.6.2-nouidmagic.patch"
+       "${FILESDIR}"/${P}-gcc8-fix.patch
+       "${FILESDIR}"/${P}-do-not-quit-when-ping_send-fail.patch
+       "${FILESDIR}"/${P}-report-right-error-msg-when-select-fails.patch
+)
+
+src_prepare() {
+       default
+
+       eautoreconf
+}
+
+src_configure() {
+       econf \
+               $(use_with perl perl-bindings INSTALLDIRS=vendor) \
+               $(use_with ncurses)
+}
+
+src_test() {
+       if use perl; then
+               pushd bindings/perl >/dev/null || die
+               perl-module_src_test
+               popd >/dev/null || die
+       fi
+}
+
+src_install() {
+       default
+
+       find "${ED}"usr/lib* -name '*.la' -o -name '*.a' -delete || die
+}
+
+pkg_postinst() {
+       if use filecaps; then
+               local _caps_str="CAP_NET_RAW"
+               _files=( "${EROOT%/}/usr/bin/oping")
+
+               if use ncurses; then
+                       _files+=( "${EROOT%/}/usr/bin/noping")
+               fi
+
+               fcaps "${_caps_str}" "${_files[@]}"
+
+               elog "Capabilities for"
+               elog ""
+
+               local _file=
+               for _file in "${_files[@]}"; do
+                       elog "  ${_file}"
+               done
+
+               elog ""
+               elog "set to ${_caps_str}+EP due to set 'filecaps' USE flag."
+               elog
+       fi
+}