pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
py-netsnmp-cffi: fix the time_t issue using cffi mechanism "int...".
Module Name: pkgsrc-wip
Committed By: Havard Eidnes <he%NetBSD.org@localhost>
Pushed By: he
Date: Wed May 14 12:56:01 2025 +0200
Changeset: 900772a9b4976995eaffc2d5960d816bc0272222
Modified Files:
py-netsnmp-cffi/Makefile
py-netsnmp-cffi/distinfo
py-netsnmp-cffi/patches/patch-src_netsnmpy_netsnmp__ffi.py
Removed Files:
py-netsnmp-cffi/patches/patch-src_netsnmp_trapsession.py
Log Message:
py-netsnmp-cffi: fix the time_t issue using cffi mechanism "int...".
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=900772a9b4976995eaffc2d5960d816bc0272222
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
py-netsnmp-cffi/Makefile | 24 +--------
py-netsnmp-cffi/distinfo | 3 +-
.../patches/patch-src_netsnmp_trapsession.py | 62 ----------------------
.../patches/patch-src_netsnmpy_netsnmp__ffi.py | 32 +++--------
4 files changed, 8 insertions(+), 113 deletions(-)
diffs:
diff --git a/py-netsnmp-cffi/Makefile b/py-netsnmp-cffi/Makefile
index dd86d3c8f5..376867ab0a 100644
--- a/py-netsnmp-cffi/Makefile
+++ b/py-netsnmp-cffi/Makefile
@@ -2,7 +2,7 @@
DISTNAME= netsnmp-cffi-0.1.1
PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_GITHUB:=Uninett/}
GITHUB_PROJECT= netsnmp-cffi
@@ -22,28 +22,6 @@ TOOL_DEPENDS+= ${PYPKGPREFIX}-setuptools>=70.1:../../devel/py-setuptools
DEPENDS+= ${PYPKGPREFIX}-cffi-[0-9]*:../../devel/py-cffi
.include "../../mk/bsd.prefs.mk"
-
-.if ${MACHINE_PLATFORM:MNetBSD-*}
-TIME_T_CMD= ${CC} -E -dD - </dev/null | \
- sed -n -e '/__INT64_TYPE__/s/\#define __INT64_TYPE__ //p'
-TIME_T= ${TIME_T_CMD:sh}
-SUSECONDS_T= int
-.else
-# what was there before, applies at least on Linux:
-TIME_T= long
-SUSECONDS_T= long
-.endif
-FIX_TIME_T= src/netsnmpy/netsnmp_ffi.py
-
-pre-configure:
- cd ${WRKSRC}; \
- for f in ${FIX_TIME_T}; do \
- sed -e "s/@TIME_T@/${TIME_T}/g" <$$f >$$f.new; \
- mv $$f.new $$f; \
- sed -e "s/@SUSECONDS_T@/${SUSECONDS_T}/g" <$$f >$$f.new; \
- mv $$f.new $$f; \
- done
-
.include "../../net/net-snmp/buildlink3.mk"
.include "../../lang/python/wheel.mk"
.include "../../mk/bsd.pkg.mk"
diff --git a/py-netsnmp-cffi/distinfo b/py-netsnmp-cffi/distinfo
index d05a2099a0..5aaec501af 100644
--- a/py-netsnmp-cffi/distinfo
+++ b/py-netsnmp-cffi/distinfo
@@ -3,5 +3,4 @@ $NetBSD$
BLAKE2s (netsnmp-cffi-0.1.1.tar.gz) = 10d75260cfca2be08f73f7ff0e8726a3eec2b351a6a6c8f136d0a4ddea087d37
SHA512 (netsnmp-cffi-0.1.1.tar.gz) = 1f0be1e2af13364f3b93c7dc26e2f78d57e9f9120185fe4b85251e4b0a7417117a83dd3626abd2874a6b1ce99cbd1d7e42198b1159bd7b715b51084a9e121311
Size (netsnmp-cffi-0.1.1.tar.gz) = 38212 bytes
-SHA1 (patch-src_netsnmp_trapsession.py) = 7293de0f01b9c59b82d92c8d5ec11b060ecd6900
-SHA1 (patch-src_netsnmpy_netsnmp__ffi.py) = 7e8129335e25b07c5d8daccd311964aedc02a547
+SHA1 (patch-src_netsnmpy_netsnmp__ffi.py) = d8415f5f871691aa53c1fe6f87e9850059457f28
diff --git a/py-netsnmp-cffi/patches/patch-src_netsnmp_trapsession.py b/py-netsnmp-cffi/patches/patch-src_netsnmp_trapsession.py
deleted file mode 100644
index d179d7d8d7..0000000000
--- a/py-netsnmp-cffi/patches/patch-src_netsnmp_trapsession.py
+++ /dev/null
@@ -1,62 +0,0 @@
-$NetBSD$
-
-Add patch to handle sockaddr layout on BSD*s.
-
---- src/netsnmpy/trapsession.py.orig 2025-04-25 09:15:29.422003201 +0000
-+++ src/netsnmpy/trapsession.py
-@@ -1,6 +1,7 @@
- """SNMP Trap session handling"""
-
- import logging
-+import platform
- from ipaddress import ip_address
- from socket import AF_INET, AF_INET6, inet_ntop
- from typing import Optional, Protocol
-@@ -36,10 +37,18 @@ _lib = _netsnmp.lib
- _log = logging.getLogger(__name__)
-
- # Local constants
-+SOCKADDR_OFFSET = 1 if "BSD" in platform.system() else 0
- IPADDR_SIZE = 4
- IP6ADDR_SIZE = 16
--IPADDR_OFFSET = 4
--IP6ADDR_OFFSET = 8
-+IPADDR_OFFSET = 0
-+IP6ADDR_OFFSET = _ffi.sizeof("uint32_t") # sin6_flowinfo
-+if "BSD" in platform.platform():
-+ SOCKADDR_TYPE = "bsd_sockaddr_in"
-+ SA_FAILY_TYPE = "uint8_t"
-+else:
-+ SOCKADDR_TYPE = "linux_sockaddr_in"
-+ SA_FAMILY_TYPE = "unsigned short"
-+SOCKADDR_DATA_OFFSET = _ffi.offsetof(SOCKADDR_TYPE, "sa_data")
-
- OBJID_SNMP_TRAPS = OID(".1.3.6.1.6.3.1.1.5")
- OBJID_SNMP_TRAP_OID = OID(".1.3.6.1.6.3.1.1.4.1.0")
-@@ -248,18 +257,19 @@ class SNMPTrap:
- if pdu.transport_data_length <= 1:
- return
-
-- # peek the first two bytes of the pdu's opaque transport data to determine
-- # socket address family (we are assuming the transport_data is a sockaddr_in
-- # or sockaddr_in6 structure and accessing it naughtily here)
-- family_p = _ffi.cast("unsigned short*", pdu.transport_data)
-- family = family_p[0]
-+ # peek the first part of the pdu's opaque transport data to determine socket
-+ # address family (we are assuming the transport_data is a sockaddr_in or
-+ # sockaddr_in6 structure and accessing it naughtily here. sockaddr
-+ # definitions vary between platforms, further complicating this).
-+ sockaddr = _ffi.cast(f"{SOCKADDR_TYPE}*", pdu.transport_data)
-+ family = sockaddr[0].sa_family
- if family not in (AF_INET, AF_INET6):
- return
-
- addr_size, offset = (
-- (IPADDR_SIZE, IPADDR_OFFSET)
-+ (IPADDR_SIZE, SOCKADDR_DATA_OFFSET + IPADDR_OFFSET)
- if family == AF_INET
-- else (IP6ADDR_SIZE, IP6ADDR_OFFSET)
-+ else (IP6ADDR_SIZE, SOCKADDR_DATA_OFFSET + IP6ADDR_OFFSET)
- )
-
- buffer = _ffi.cast("char*", pdu.transport_data)
diff --git a/py-netsnmp-cffi/patches/patch-src_netsnmpy_netsnmp__ffi.py b/py-netsnmp-cffi/patches/patch-src_netsnmpy_netsnmp__ffi.py
index 2d8d9c2733..b6de175a49 100644
--- a/py-netsnmp-cffi/patches/patch-src_netsnmpy_netsnmp__ffi.py
+++ b/py-netsnmp-cffi/patches/patch-src_netsnmpy_netsnmp__ffi.py
@@ -1,36 +1,16 @@
$NetBSD$
-Provide a hook to replace correct type for time_t and suseconds_t.
-See pre-configure target.
+Use the new way of dealing with different-sized
+time_t types in FFI.
-Also handle the difference in sockaddr layout on Linux & BSDs.
-
---- src/netsnmpy/netsnmp_ffi.py.orig 2025-02-19 13:40:58.000000000 +0000
+--- src/netsnmpy/netsnmp_ffi.py.orig 2025-05-14 09:52:14.408968553 +0000
+++ src/netsnmpy/netsnmp_ffi.py
-@@ -12,6 +12,17 @@ typedef struct _callback_data {
- void *reserved;
- unsigned long session_id;
- } _callback_data;
-+typedef struct linux_sockaddr_in {
-+ unsigned short sa_family;
-+ unsigned short sa_port;
-+ char sa_data[14];
-+} linux_sockaddr_in;
-+typedef struct bsd_sockaddr_in {
-+ uint8_t sa_len;
-+ uint8_t sa_family;
-+ unsigned short sa_port;
-+ char sa_data[14];
-+} bsd_sockaddr_in;
- """
- _CDEF = f"""
- /* Typedefs and structs we will be needing access to */
-@@ -20,9 +31,11 @@ typedef unsigned short u_short;
+@@ -20,9 +20,11 @@ typedef unsigned short u_short;
typedef unsigned char u_char;
typedef unsigned int u_int;
typedef unsigned long oid;
-+typedef @TIME_T@ time_t; /* @TIME_T@ substituted by pre-configure target */
-+typedef @SUSECONDS_T@ suseconds_t; /* also done by pre-configure target */
++typedef int... time_t;
++typedef int... suseconds_t;
typedef struct timeval {{
- long tv_sec;
- long tv_usec;
Home |
Main Index |
Thread Index |
Old Index