commit:     7d5b11c234adf6ff1613e045edacf6cc6e22845e
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  7 23:52:24 2025 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Tue Apr  8 00:49:54 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7d5b11c2

net-analyzer/nagios-plugins: bugfix -r1, keyword ~riscv

 * Two patches for improved pgsql and net-snmp detection.
 * Depend on net-dns/bind instead of the old net-dns/bind-tools.
 * Add ~riscv keywords.

Bug: https://bugs.gentoo.org/940193
Closes: https://bugs.gentoo.org/938467
Closes: https://bugs.gentoo.org/953349
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>

 ...agios-plugins-2.4.12-postgresql-detection.patch | 143 +++++++++++++++++++++
 .../files/nagios-plugins-2.4.12-snmpgetnext.patch  | 128 ++++++++++++++++++
 .../nagios-plugins/nagios-plugins-2.4.12-r1.ebuild | 130 +++++++++++++++++++
 3 files changed, 401 insertions(+)

diff --git 
a/net-analyzer/nagios-plugins/files/nagios-plugins-2.4.12-postgresql-detection.patch
 
b/net-analyzer/nagios-plugins/files/nagios-plugins-2.4.12-postgresql-detection.patch
new file mode 100644
index 000000000000..570b0992bf7e
--- /dev/null
+++ 
b/net-analyzer/nagios-plugins/files/nagios-plugins-2.4.12-postgresql-detection.patch
@@ -0,0 +1,143 @@
+From be90a1d9ae5b5e10015619271337e3a2c731b3bb Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <[email protected]>
+Date: Sat, 7 Sep 2024 19:51:27 -0400
+Subject: [PATCH] configure.ac: rewrite PostgreSQL detection using pg_config
+
+PostgreSQL installs a pg_config program that spits out its "include"
+and "library" paths when called with --includedir and --libdir,
+respectively. Using this we can simplify the detection of PostgreSQL,
+since in theory the problem is reduced to that of finding pg_config.
+
+This commit replaces the existing PostgreSQL detection with a more
+straightforward search for pg_config. The change is backwards-
+compatible, in the sense that --with-pgsql=foo will still find the
+postgres installation in "foo," except now it will do so through
+foo/bin/pg_config rather than foo/include and foo/lib.
+
+This solves a rare problem: on systems where only one version of
+postgres is allowed, or on systems where multiple versions exist but a
+"default" version can be chosen, the most likely path for postgres is
+--with-pgsql=/usr. With the current implementation, this leads to
+"-I/usr/include" being added to CPPFLAGS, which is fine, and
+"-L/usr/lib" being added to LDFLAGS, which is not. On some of those
+same systems, /usr/lib is for 32-bit libraries while /usr/lib64 is the
+"normal" (64-bit) library path. So as a result of detecting postgres
+under /usr, the linker is pointed to the wrong set of libraries. This
+is known to crash lld (the LLVM linker).
+---
+ configure.ac | 100 ++++++++++++++++++++++++++-------------------------
+ 1 file changed, 52 insertions(+), 48 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b67a7805..c69246c0 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -209,56 +209,60 @@ if test "$enable_extra_opts" = "yes" ; then
+       fi
+ fi
+ 
+-dnl Check for PostgreSQL libraries
+-_SAVEDLIBS="$LIBS"
+-_SAVEDCPPFLAGS="$CPPFLAGS"
++dnl Check for PostgreSQL libraries. Postgres ships a pg_config program
++dnl that gives us the -I and -L flags we need, so the problem is reduced
++dnl to finding pg_config. When the user passes --with-pgsql=foo, we expect
++dnl that "foo" is something like /usr/lib64/postgresql-16, i.e. that we
++dnl can locate "bin/pg_config" there. This supports choosing one particular
++dnl version of postgres when multiple versions are installed. If the "foo"
++dnl argument is omitted, we instead use whatever pg_config (if any) is present
++dnl on the PATH. It is an error to request postgres support when no usable
++dnl pg_config is provided and one cannot be found.
+ AC_ARG_WITH(pgsql,
+       ACX_HELP_STRING([--with-pgsql=DIR],
+-              [sets path to pgsql installation]),
+-      PGSQL=$withval,)
+-AC_CHECK_LIB(crypt,main)
+-if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
+-  if test -n "$PGSQL"; then
+-    LDFLAGS="$LDFLAGS -L$PGSQL/lib"
+-    CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
+-  fi
+-  AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
+-  if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
+-    AC_CHECK_HEADERS(pgsql/libpq-fe.h)
+-    AC_CHECK_HEADERS(postgresql/libpq-fe.h)
+-    AC_CHECK_HEADERS(libpq-fe.h)
+-    if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
+-      PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
+-      PGINCLUDE="-I$PGSQL/include"
+-    elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
+-      PGLIBS="-lpq -lcrypt"
+-      PGINCLUDE="-I/usr/include/pgsql"
+-    elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
+-      PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
+-      PGINCLUDE="-I/usr/include/postgresql"
+-    elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
+-      PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
+-      PGINCLUDE="-I$PGSQL/include"
+-    fi
+-    if test -z "$PGINCLUDE"; then
+-      AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
+-      AC_MSG_WARN([install PostgreSQL headers to compile this plugin (see 
REQUIREMENTS).])
+-    else
+-      AC_SUBST(PGLIBS)
+-      AC_SUBST(PGINCLUDE)
+-      EXTRAS="$EXTRAS check_pgsql\$(EXEEXT)"
+-    fi
+-  else
+-    AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
+-    AC_MSG_WARN([LIBS="$LIBS" CPPFLAGS="$CPPFLAGS"])
+-    AC_MSG_WARN([install PostgreSQL libs to compile this plugin (see 
REQUIREMENTS).])
+-  fi
+-else
+-  AC_MSG_WARN([Skipping PostgreSQL plugin (check_pgsql)])
+-  AC_MSG_WARN([install lib crypt and PostgreSQL libs to compile this plugin 
(see REQUIREMENTS).])
+-fi
+-LIBS="$_SAVEDLIBS"
+-CPPFLAGS="$_SAVEDCPPFLAGS"
++              [path to pgsql installation, i.e. path to bin/pg_config]),
++      PGSQL=$withval,PGSQL=no)
++
++dnl --with-pgsql sans argument gives "yes"
++dnl --without-pgsql gives "no" (this is also the default, see above)
++dnl --with-pgsql=foo gives "foo"
++AS_IF([test "x${PGSQL}" = xno],[
++  AC_MSG_WARN([Skipping PostgreSQL plugin])
++],[
++  _PG_CONFIG=""
++
++  AS_IF([test "x${PGSQL}" = xyes],[
++    AC_PATH_PROG(_PG_CONFIG, pg_config)
++    AS_IF([test -z "${_PG_CONFIG}"],[
++      AC_MSG_ERROR([postgres support requested but pg_config not found])
++    ])
++  ],[
++    AC_MSG_CHECKING([for usable ${PGSQL}/bin/pg_config])
++    AS_IF([test -f "${PGSQL}/bin/pg_config" -a -x "${PGSQL}/bin/pg_config"],[
++      AC_MSG_RESULT([yes])
++      _PG_CONFIG="${PGSQL}/bin/pg_config"
++    ],[
++      AC_MSG_RESULT([no])
++      AC_MSG_ERROR([${PGSQL}/bin/pg_config not found or not executable])
++    ])
++  ])
++
++  dnl Sanity check: look for a header using the -I flags
++  dnl that we get from pg_config.
++  _SAVED_CPPFLAGS="${CPPFLAGS}"
++  PGINCLUDE="-I$(${_PG_CONFIG} --includedir)"
++  CPPFLAGS="${CPPFLAGS} ${PGINCLUDE}"
++  AC_CHECK_HEADER(libpq-fe.h,[
++    PGLIBS="-L$(${_PG_CONFIG} --libdir) -lpq"
++    AC_SUBST(PGLIBS)
++    AC_SUBST(PGINCLUDE)
++    EXTRAS="$EXTRAS check_pgsql\$(EXEEXT)"
++  ],[
++    AC_MSG_ERROR([libpq-fe.h not found])
++  ])
++  CPPFLAGS="${_SAVED_CPPFLAGS}"
++])
++
+ 
+ AC_ARG_WITH([dbi], [AS_HELP_STRING([--without-dbi], [Skips the dbi plugin])])
+ dnl Check for DBI libraries

diff --git 
a/net-analyzer/nagios-plugins/files/nagios-plugins-2.4.12-snmpgetnext.patch 
b/net-analyzer/nagios-plugins/files/nagios-plugins-2.4.12-snmpgetnext.patch
new file mode 100644
index 000000000000..549ba3e30b71
--- /dev/null
+++ b/net-analyzer/nagios-plugins/files/nagios-plugins-2.4.12-snmpgetnext.patch
@@ -0,0 +1,128 @@
+From 37b27e058cc8a352a588c865e0319c23f6cb23d5 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <[email protected]>
+Date: Sat, 15 Feb 2025 17:45:53 -0500
+Subject: [PATCH 1/3] configure.ac: update net-snmp homepage
+
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 6b443263..0308f5cb 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1491,7 +1491,7 @@ then
+       AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget 
binary])
+       EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)"
+ else
+-      AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make 
check_hpjd and check_snmp plugins])
++      AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to make 
check_hpjd and check_snmp plugins])
+ fi
+ 
+ AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
+
+From 8246d9c987b45586b5ceca2c81a671c642ad7106 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <[email protected]>
+Date: Sat, 15 Feb 2025 17:47:34 -0500
+Subject: [PATCH 2/3] configure.ac: use AS_IF in net-snmp tests
+
+Not strictly required here, but the AS_IF macro is generally safer
+because it handles (often unintentional) AC_REQUIRE calls.
+---
+ configure.ac | 12 +++++-------
+ 1 file changed, 5 insertions(+), 7 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 0308f5cb..5aaf4eee 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1486,23 +1486,21 @@ AC_ARG_WITH(snmpget_command,
+             ACX_HELP_STRING([--with-snmpget-command=PATH],
+                             [Path to snmpget command]),
+             PATH_TO_SNMPGET=$withval)
+-if test -n "$PATH_TO_SNMPGET"
+-then
++AS_IF([test -n "$PATH_TO_SNMPGET"], [
+       AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget 
binary])
+       EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)"
+-else
++], [
+       AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to make 
check_hpjd and check_snmp plugins])
+-fi
++])
+ 
+ AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
+ AC_ARG_WITH(snmpgetnext_command,
+             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
+                             [Path to snmpgetnext command]),
+             PATH_TO_SNMPGETNEXT=$withval)
+-if test -n "$PATH_TO_SNMPGETNEXT"
+-then
++AS_IF([test -n "$PATH_TO_SNMPGETNEXT"], [
+       AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to 
snmpgetnext binary])
+-fi
++])
+ 
+ if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )
+ then
+
+From 1ceac49405e77b28e75118c5b537db84d73866a5 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <[email protected]>
+Date: Sat, 15 Feb 2025 18:10:06 -0500
+Subject: [PATCH 3/3] configure.ac: require snmpgetnext for check_snmp
+
+PATH_TO_SNMPGETNEXT is used unconditionally in plugins/check_snmp.c,
+and the build will fail if it is left undefined (that is, if we are
+building check_snmp but snmpgetnext was neither found on the user's
+PATH or supplied manually).
+
+To avoid this build failure, we now test for snmpgetnext inside the
+case for snmpget, and skip check_snmp unless BOTH are found.
+
+Closes GH-788
+---
+ configure.ac | 25 +++++++++++++++++--------
+ 1 file changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 5aaf4eee..ae2ea796 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1486,20 +1486,29 @@ AC_ARG_WITH(snmpget_command,
+             ACX_HELP_STRING([--with-snmpget-command=PATH],
+                             [Path to snmpget command]),
+             PATH_TO_SNMPGET=$withval)
+-AS_IF([test -n "$PATH_TO_SNMPGET"], [
+-      AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget 
binary])
+-      EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)"
+-], [
+-      AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to make 
check_hpjd and check_snmp plugins])
+-])
+ 
+ AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext)
+ AC_ARG_WITH(snmpgetnext_command,
+             ACX_HELP_STRING([--with-snmpgetnext-command=PATH],
+                             [Path to snmpgetnext command]),
+             PATH_TO_SNMPGETNEXT=$withval)
+-AS_IF([test -n "$PATH_TO_SNMPGETNEXT"], [
+-      AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to 
snmpgetnext binary])
++
++AS_IF([test -n "$PATH_TO_SNMPGET"], [
++      AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget 
binary])
++      EXTRAS="$EXTRAS check_hpjd"
++
++      dnl PATH_TO_SNMPGETNEXT is used unconditionally in check_snmp:
++      dnl
++      dnl   https://github.com/nagios-plugins/nagios-plugins/issues/788
++      dnl
++      AS_IF([test -n "$PATH_TO_SNMPGETNEXT"], [
++              
AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to 
snmpgetnext binary])
++              EXTRAS="$EXTRAS check_snmp\$(EXEEXT)"
++      ], [
++              AC_MSG_WARN([Get snmpgetnext from 
https://net-snmp.sourceforge.io/ to build the check_snmp plugin])
++      ])
++], [
++      AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to build 
the check_hpjd and check_snmp plugins])
+ ])
+ 
+ if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null  )

diff --git a/net-analyzer/nagios-plugins/nagios-plugins-2.4.12-r1.ebuild 
b/net-analyzer/nagios-plugins/nagios-plugins-2.4.12-r1.ebuild
new file mode 100644
index 000000000000..add6fce1fcec
--- /dev/null
+++ b/net-analyzer/nagios-plugins/nagios-plugins-2.4.12-r1.ebuild
@@ -0,0 +1,130 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools
+
+DESCRIPTION="Official plugins for Nagios"
+HOMEPAGE="https://nagios-plugins.org/";
+SRC_URI="https://github.com/${PN}/${PN}/releases/download/release-${PV}/${P}.tar.gz";
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~sparc ~x86"
+IUSE="ipv6 ldap mysql nagios-dns nagios-ping nagios-game postgres radius samba 
selinux snmp ssh +ssl"
+
+# Most of the plugins use automagic dependencies, i.e. the plugin will
+# get built if the binary it uses is installed. For example, check_snmp
+# will be built only if snmpget from net-analyzer/net-snmp[-minimal] is
+# installed. End result: most of our runtime dependencies are required
+# at build time as well.
+AUTOMAGIC_DEPEND="
+       nagios-dns? ( net-dns/bind )
+       nagios-game? ( games-util/qstat )
+       nagios-ping? ( net-analyzer/fping )
+       samba? ( net-fs/samba )
+       ssh? ( virtual/openssh )
+       snmp? ( dev-perl/Net-SNMP
+                       net-analyzer/net-snmp[-minimal] )"
+
+# Perl really needs to run during the build...
+BDEPEND="${AUTOMAGIC_DEPEND}
+       dev-lang/perl"
+
+DEPEND="
+       ldap? ( net-nds/openldap:= )
+       mysql? ( dev-db/mysql-connector-c:= )
+       postgres? ( dev-db/postgresql:* )
+       ssl? (
+               dev-libs/openssl:0=
+       )
+       radius? ( net-dialup/freeradius-client )"
+
+# Basically everything in net-analyzer/monitoring-plugins collides with
+# nagios-plugins. Perl (from BDEPEND) is needed at runtime, too.
+RDEPEND="${BDEPEND}
+       ${DEPEND}
+       !net-analyzer/monitoring-plugins
+       selinux? ( sec-policy/selinux-nagios )"
+
+# At least one test is interactive.
+RESTRICT="test"
+
+PATCHES=(
+       "${FILESDIR}/${P}-postgresql-detection.patch"
+       "${FILESDIR}/${P}-snmpgetnext.patch"
+)
+
+DOCS=(
+       ACKNOWLEDGEMENTS
+       AUTHORS
+       CODING
+       ChangeLog
+       FAQ
+       NEWS
+       README
+       REQUIREMENTS
+       SUPPORT
+       THANKS
+)
+
+# These all come from gnulib and the ./configure checks are working as
+# intended when the functions aren't present. Bugs 907755 and 924341.
+QA_CONFIG_IMPL_DECL_SKIP=(
+       statvfs64
+       re_set_syntax
+       re_compile_pattern
+       re_search
+       re_match
+)
+
+src_prepare() {
+       default
+
+       # Fix the path to our perl interpreter
+       sed -i -e "1s:/usr/local/bin/perl:/usr/bin/perl:" \
+               "${S}"/plugins-scripts/*.pl \
+               || die 'failed to fix perl interpreter path'
+
+       eautoreconf
+}
+
+src_configure() {
+       # Use an array to prevent econf from mangling the ping args.
+       local myconf=()
+
+       if use ssl; then
+               myconf+=( $(use_with ssl openssl /usr) )
+       else
+               myconf+=( --without-openssl )
+               myconf+=( --without-gnutls )
+       fi
+
+       # The autodetection for these two commands can hang if localhost is
+       # down or ICMP traffic is filtered (bug #468296). But also the path
+       # likes to move around on us (bug #883765).
+       myconf+=( --with-ping-command="$(command -v ping) -n -U -w %d -c %d %s" 
)
+
+       if use ipv6; then
+               myconf+=( --with-ping6-command="$(command -v ping6) -n -U -w %d 
-c %d %s" )
+       fi
+
+       econf \
+               $(use_with mysql) \
+               $(use_with ipv6) \
+               $(use_with ldap) \
+               $(use_with postgres pgsql /usr) \
+               $(use_with radius) \
+               "${myconf[@]}" \
+               --libexecdir="/usr/$(get_libdir)/nagios/plugins" \
+               --sysconfdir="/etc/nagios"
+}
+
+pkg_postinst() {
+       elog "This ebuild has a number of USE flags that determine what you"
+       elog "are able to monitor. Depending on what you want to monitor, some"
+       elog "or all of these USE flags need to be set."
+       elog
+       elog "The plugins are installed in 
${ROOT}/usr/$(get_libdir)/nagios/plugins"
+}

Reply via email to