git: e25d62fc9bf6 - main - net-mgmt/mrtg: fix regression with gcc14 / clang16

From: Dirk Meyer <dinoex_at_FreeBSD.org>
Date: Fri, 18 Oct 2024 14:25:43 UTC
The branch main has been updated by dinoex:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e25d62fc9bf6b007940a06a889a3501fa3e51607

commit e25d62fc9bf6b007940a06a889a3501fa3e51607
Author:     Dirk Meyer <dinoex@FreeBSD.org>
AuthorDate: 2024-10-18 14:24:47 +0000
Commit:     Dirk Meyer <dinoex@FreeBSD.org>
CommitDate: 2024-10-18 14:24:47 +0000

    net-mgmt/mrtg: fix regression with gcc14 / clang16
    
    - fix shebangfix
    
    - use textproc/p5-Pod-Parser
    Obtained from: NetBSD
    
    - add ubiquiti to cfgmaker
    - fix HC detection in cfgmaker
---
 net-mgmt/mrtg/Makefile                |  9 ++++++---
 net-mgmt/mrtg/files/patch-Makefile.in | 32 +++++++++++++++++++++++++++++
 net-mgmt/mrtg/files/patch-Mrtg_nsi    | 11 ++++++++++
 net-mgmt/mrtg/files/patch-cfgmaker    | 38 +++++++++++++++++++++++++++++++++++
 net-mgmt/mrtg/files/patch-configure   | 13 +++++++++---
 net-mgmt/mrtg/files/patch-rateup.c    | 14 +++++++++++++
 6 files changed, 111 insertions(+), 6 deletions(-)

diff --git a/net-mgmt/mrtg/Makefile b/net-mgmt/mrtg/Makefile
index 61249a09cf5b..bec636fbea34 100644
--- a/net-mgmt/mrtg/Makefile
+++ b/net-mgmt/mrtg/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	mrtg
 DISTVERSION=	2.17.10
-PORTREVISION=	2
+PORTREVISION=	3
 PORTEPOCH=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	https://github.com/oetiker/${PORTNAME}/releases/download/v${DISTVERSION}/ \
@@ -14,7 +14,9 @@ LICENSE=	GPLv2
 
 LIB_DEPENDS=	libgd.so:${GD_PORT} \
 		libpng16.so:graphics/png
-RUN_DEPENDS=	p5-SNMP_Session>=0:net-mgmt/p5-SNMP_Session
+RUN_DEPENDS=	p5-SNMP_Session>=0:net-mgmt/p5-SNMP_Session \
+		p5-Pod-Parser>=0:textproc/p5-Pod-Parser \
+		p5-Module-CoreList>=0:devel/p5-Module-CoreList
 
 USES=		perl5 shebangfix
 
@@ -29,7 +31,8 @@ GROUPS=		mrtg
 
 MAKE_ENV+=	PERL=${PERL}
 MRTG_RUNDIR?=	/var/run/mrtg
-SHEBANG_FILES=	bin/mrtg-traffic-sum
+SHEBANG_FILES=	bin/cfgmaker bin/indexmaker bin/mrtg bin/mrtg-traffic-sum
+perl_OLD_CMD=	/home/oetiker/.plenv/shims/perl
 
 USE_RC_SUBR=	mrtg_daemon
 SUB_FILES=	pkg-deinstall pkg-install pkg-message
diff --git a/net-mgmt/mrtg/files/patch-Makefile.in b/net-mgmt/mrtg/files/patch-Makefile.in
new file mode 100644
index 000000000000..61447f9ba420
--- /dev/null
+++ b/net-mgmt/mrtg/files/patch-Makefile.in
@@ -0,0 +1,32 @@
+Ignore the enclosed Pod-Parser in favour of textproc/p5-Pod-Parser,
+avoiding pointless conflicts with p5 packages
+
+Install Perl modules to the proper versioned vendorlib directory
+
+--- Makefile.in.orig	2022-01-19 10:24:31 UTC
++++ Makefile.in
+@@ -38,7 +38,7 @@ subst:
+ 	$(CC) $(CPPFLAGS) $(CFLAGS) -c $(top_srcdir)/src/rateup.c -o bin/rateup.o
+ 
+ subst:
+-	$(PERL) -0777 -p -i~ -e "s'^#!\s*/\S*perl'#! $(PERL)'" $(top_srcdir)/bin/cfgmaker $(top_srcdir)/bin/indexmaker $(top_srcdir)/bin/mrtg
++	$(PERL) -0777 -p -i~ -e "s@__PREFIX__@${prefix}@g" $(top_srcdir)/bin/cfgmaker $(top_srcdir)/bin/indexmaker $(top_srcdir)/bin/mrtg
+ 	$(PERL) -0777 -p -i~ -e 's@GRAPHFMT="...";@GRAPHFMT="$(GDFORM_EXT)";@' $(top_srcdir)/bin/mrtg $(top_srcdir)/bin/indexmaker
+ 
+ configure: configure.ac
+@@ -58,12 +58,10 @@ install: all
+ 	for x in $(top_srcdir)/bin/mrtg $(top_srcdir)/bin/cfgmaker $(top_srcdir)/bin/indexmaker $(top_srcdir)/bin/mrtg-traffic-sum; do \
+ 	  $(INSTALL) -m 755 $$x $(DESTDIR)$(bindir); done
+ 	for x in bin/rateup; do \
+-	  $(INSTALL) -m 755 $$x $(DESTDIR)$(bindir); done
+-	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)/mrtg2/Pod
++	  $(INSTALL) -m 755 -s $$x $(DESTDIR)$(bindir); done
++	$(MKINSTALLDIRS) $(DESTDIR)${PERL5_INSTALLVENDORLIB}
+ 	for x in $(top_srcdir)/lib/mrtg2/*.pm; do \
+-	  $(INSTALL) -m 644 $$x $(DESTDIR)$(libdir)/mrtg2; done
+-	for x in $(top_srcdir)/lib/mrtg2/Pod/*.pm; do \
+-	  $(INSTALL) -m 644 $$x $(DESTDIR)$(libdir)/mrtg2/Pod; done
++	  $(INSTALL) -m 644 $$x $(DESTDIR)${PERL5_INSTALLVENDORLIB}; done
+ 	$(MKINSTALLDIRS) $(DESTDIR)$(datadir)/mrtg2/icons
+ 	for x in $(top_srcdir)/images/*.gif $(top_srcdir)/images/*.png; do \
+ 	  $(INSTALL) -m 644 $$x $(DESTDIR)$(datadir)/mrtg2/icons; done
diff --git a/net-mgmt/mrtg/files/patch-Mrtg_nsi b/net-mgmt/mrtg/files/patch-Mrtg_nsi
new file mode 100644
index 000000000000..55cce864648a
--- /dev/null
+++ b/net-mgmt/mrtg/files/patch-Mrtg_nsi
@@ -0,0 +1,11 @@
+--- contrib/NSI/Mrtg_nsi.orig	2017-03-05 14:09:53 UTC
++++ contrib/NSI/Mrtg_nsi
+@@ -59,7 +59,7 @@ $main::OS = 'NT';
+ 	}
+ 	die "ERROR: Can\'t find location of mrtg executable\n" 
+ 	  unless $main::binpath; 
+-	unshift (@INC,$main::binpath);
++	$main::binpath .= "/../libexec"
+ }
+ 
+ # There older perls tend to behave peculiar with
diff --git a/net-mgmt/mrtg/files/patch-cfgmaker b/net-mgmt/mrtg/files/patch-cfgmaker
new file mode 100644
index 000000000000..9053ec35fb7d
--- /dev/null
+++ b/net-mgmt/mrtg/files/patch-cfgmaker
@@ -0,0 +1,38 @@
+--- bin/cfgmaker.orig	2022-01-19 10:25:15 UTC
++++ bin/cfgmaker
+@@ -175,7 +175,7 @@ sub InterfaceInfo($$$$$) {
+         push @Variables,  ($1 > 11.0 or $1 < 10.0 ) ? "ifAlias" : "CiscolocIfDescr";
+         if ($1 > 11.2) {push @Variables, "vmVlan";};
+        if ($1 > 11.3) {push @Variables, "vlanTrunkPortDynamicStatus";};
+-    } elsif ( $routers->{$router}{deviceinfo}{Vendor} =~ /(?:hp|juniper|dlink|wwp|foundry|dellLan|force10|3com|extremenetworks|openBSD|arista|enterasys|zyxel|vyatta|dcn|brocade|datacom|alcatel|mikrotik|huawei|eltex)/i) {
++    } elsif ( $routers->{$router}{deviceinfo}{Vendor} =~ /(?:hp|juniper|dlink|wwp|foundry|dellLan|force10|3com|extremenetworks|openBSD|arista|enterasys|zyxel|vyatta|dcn|brocade|datacom|alcatel|mikrotik|huawei|eltex|ubiquiti)/i) {
+         push @Variables, "ifAlias";
+     }
+ 
+@@ -911,11 +911,11 @@ sub IsCounterBroken ($$$) {
+     my $snmphost = v4onlyifnecessary($router, $ipv4only);
+ 
+     if ($router =~ /:[\d.]*:[\d.]*:[\d.]*:[23]/) {
+-        my $speed = (snmpget($snmphost, $v3opt, 'ifHighSpeed.'.$if))[0] || 'unknown';
++        my $speed = (snmpget($snmphost, $v3opt, 'ifHighSpeed.'.$if))[0] // 'unknown';
+         debug('base',"snmpget $snmphost for ifHighSpeed.$if -> $speed Mb/s");
+         $SNMP_Session::errmsg = undef;
+ 	$Net_SNMP_util::ErrorMessage = undef;
+-        my $counter = (snmpget($snmphost,$v3opt, 'ifHCInOctets.'.$if))[0] || 'unknown';
++        my $counter = (snmpget($snmphost,$v3opt, 'ifHCInOctets.'.$if))[0] // 'unknown';
+         debug('base',"snmpget $snmphost for ifHCInOctets.$if -> $counter");
+         if( $speed eq 'unknown' or $counter !~ /^\d+$/ or $SNMP_Session::errmsg or $Net_SNMP_util::ErrorMessage){
+             $SNMP_Session::errmsg = undef;
+@@ -1018,7 +1018,11 @@ sub DeviceInfo ($$$) {
+             '1.3.6.1.4.1.14988.' =>     'mikrotik',
+             '1.3.6.1.4.1.6486.' =>      'alcatel',
+             '1.3.6.1.4.1.2011.' =>      'huawei',
+-            '1.3.6.1.4.1.35265.' =>     'eltex'
++            '1.3.6.1.4.1.35265.' =>     'eltex',
++            '1.3.6.1.4.1.4413' =>       'ubiquiti',
++            '1.3.6.1.4.1.41112' =>      'ubiquiti'
++
++
+         );
+         $DevInfo{Vendor} = 'Unknown Vendor - '.$DevInfo{sysObjectID};
+         foreach (keys %vendorIDs) {
diff --git a/net-mgmt/mrtg/files/patch-configure b/net-mgmt/mrtg/files/patch-configure
index 4c0104f398a3..619060a62149 100644
--- a/net-mgmt/mrtg/files/patch-configure
+++ b/net-mgmt/mrtg/files/patch-configure
@@ -1,7 +1,14 @@
-If I can shave off 7 seconds off every exp-run this patch seems totally worth it
---- configure.orig	2014-12-11 13:46:28 UTC
+--- configure.orig	2022-01-19 10:24:35 UTC
 +++ configure
-@@ -5343,18 +5343,12 @@ fi
+@@ -3664,6 +3664,7 @@ else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ #include <stdio.h>
++#include <stdlib.h>
+             int main()
+             {
+                 long long b, a = -0x3AFAFAFAFAFAFAFALL;
+@@ -5384,18 +5385,12 @@ echo $ECHO_N "ordering CD from http://tobi.oetiker.ch/
  
  
  echo $ECHO_N "ordering CD from http://tobi.oetiker.ch/wish $ECHO_C" 1>&6
diff --git a/net-mgmt/mrtg/files/patch-rateup.c b/net-mgmt/mrtg/files/patch-rateup.c
new file mode 100644
index 000000000000..4e119ef4add0
--- /dev/null
+++ b/net-mgmt/mrtg/files/patch-rateup.c
@@ -0,0 +1,14 @@
+--- src/rateup.c.orig	2022-01-19 10:25:16 UTC
++++ src/rateup.c
+@@ -49,11 +49,6 @@
+ #define GFORM_GD gdImagePng
+ #endif
+ 
+-/* BSD* does not have/need malloc.h */
+-#if !defined(bsdi) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__APPLE__)
+-#include <malloc.h>
+-#endif
+-
+ /* MSVCRT.DLL does not know %ll in printf */
+ #ifdef __MINGW32_VERSION
+ #define LLD "%I64d"