git: 622023b5f614 - main - devel/glib20: Enable GNetworkMonitor with Netlink backend

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Wed, 30 Oct 2024 18:29:59 UTC
The branch main has been updated by arrowd:

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

commit 622023b5f6146fa8f9b544dcb49329395b1f0ff8
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2024-10-30 18:28:40 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2024-10-30 18:29:43 +0000

    devel/glib20: Enable GNetworkMonitor with Netlink backend
    
    Sponsored by:   Future Crew, LLC
---
 devel/glib20/Makefile                           |  1 +
 devel/glib20/files/patch-networkmonitor-netlink | 76 +++++++++++++++++++++++++
 2 files changed, 77 insertions(+)

diff --git a/devel/glib20/Makefile b/devel/glib20/Makefile
index a300d7e0aadf..fbeed640d9ae 100644
--- a/devel/glib20/Makefile
+++ b/devel/glib20/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	glib
 DISTVERSION=	2.80.5
+PORTREVISION=	1
 PORTEPOCH=	2
 CATEGORIES=	devel
 MASTER_SITES=	GNOME
diff --git a/devel/glib20/files/patch-networkmonitor-netlink b/devel/glib20/files/patch-networkmonitor-netlink
new file mode 100644
index 000000000000..6e5996f5ee11
--- /dev/null
+++ b/devel/glib20/files/patch-networkmonitor-netlink
@@ -0,0 +1,76 @@
+From 02172bda73663f63b603956a180c6c6fc6a3d187 Mon Sep 17 00:00:00 2001
+From: Gleb Popov <6yearold@gmail.com>
+Date: Tue, 29 Oct 2024 21:18:36 +0300
+Subject: [PATCH] Enable GNetworkMonitorNetlink on FreeBSD
+
+https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4376
+
+---
+ gio/gnetworkmonitornetlink.c | 8 ++++++++
+ meson.build                  | 4 +++-
+ 2 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/gio/gnetworkmonitornetlink.c b/gio/gnetworkmonitornetlink.c
+index bf51d31f99..adaa77d38b 100644
+--- a/gio/gnetworkmonitornetlink.c
++++ ./gio/gnetworkmonitornetlink.c
+@@ -38,8 +38,14 @@
+ 
+ /* must come at the end to pick system includes from
+  * gnetworkingprivate.h */
++#ifdef HAVE_LINUX_NETLINK_H
+ #include <linux/netlink.h>
+ #include <linux/rtnetlink.h>
++#endif
++#ifdef HAVE_NETLINK_NETLINK_H
++#include <netlink/netlink.h>
++#include <netlink/netlink_route.h>
++#endif
+ 
+ static GInitableIface *initable_parent_iface;
+ static void g_network_monitor_netlink_iface_init (GNetworkMonitorInterface *iface);
+@@ -124,6 +130,7 @@ g_network_monitor_netlink_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+ 
++#ifdef SO_PASSCRED
+   if (!g_socket_set_option (nl->priv->sock, SOL_SOCKET, SO_PASSCRED,
+ 			    TRUE, NULL))
+     {
+@@ -133,6 +140,7 @@ g_network_monitor_netlink_initable_init (GInitable     *initable,
+                    g_strerror (errsv));
+       return FALSE;
+     }
++#endif
+ 
+   /* Request the current state */
+   if (!request_dump (nl, error))
+diff --git a/meson.build b/meson.build
+index 69e4b036ea..7da293881e 100644
+--- a/meson.build
++++ ./meson.build
+@@ -400,10 +400,12 @@ headers = [
+   'inttypes.h',
+   'libproc.h',
+   'limits.h',
++  'linux/netlink.h',
+   'locale.h',
+   'mach/mach_time.h',
+   'memory.h',
+   'mntent.h',
++  'netlink/netlink.h',
+   'poll.h',
+   'pwd.h',
+   'sched.h',
+@@ -461,7 +463,7 @@ if cc.check_header('malloc.h')
+   glib_conf_prefix = glib_conf_prefix + '#define HAVE_MALLOC_H 1\n'
+ endif
+ 
+-if cc.check_header('linux/netlink.h')
++if glib_conf.has('HAVE_LINUX_NETLINK_H') or glib_conf.has('HAVE_NETLINK_NETLINK_H')
+   glib_conf.set('HAVE_NETLINK', 1)
+ endif
+ 
+-- 
+GitLab
+