From a94861fb58ad775543f321831885ad566e078b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mina=20Gali=C4=87?= Date: Sun, 13 Aug 2023 21:34:16 +0000 Subject: [PATCH] lang/python3.11: backport netlink patch this patch backports GH-107812: extend socket's netlink support to FreeBSD see https://github.com/python/cpython/pull/107813 for the patch. see https://github.com/python/cpython/issues/107812 for the discussion on the backport itself. Sponsored by: The FreeBSD Foundation --- lang/python311/Makefile | 1 + .../files/patch-Modules__socketmodule.h | 11 ++++++ lang/python311/files/patch-configure | 36 +++++++++++++++++-- lang/python311/files/patch-pyconfig.h.in | 12 +++++++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 lang/python311/files/patch-Modules__socketmodule.h create mode 100644 lang/python311/files/patch-pyconfig.h.in diff --git a/lang/python311/Makefile b/lang/python311/Makefile index 2ce279dbe..538533d4f 100644 --- a/lang/python311/Makefile +++ b/lang/python311/Makefile @@ -1,5 +1,6 @@ PORTNAME= python DISTVERSION= ${PYTHON_DISTVERSION} +PORTREVISION= 1 CATEGORIES= lang python MASTER_SITES= PYTHON/ftp/python/${DISTVERSION:C/[a-z].*//} PKGNAMESUFFIX= ${PYTHON_SUFFIX} diff --git a/lang/python311/files/patch-Modules__socketmodule.h b/lang/python311/files/patch-Modules__socketmodule.h new file mode 100644 index 000000000..8ea41288f --- /dev/null +++ b/lang/python311/files/patch-Modules__socketmodule.h @@ -0,0 +1,11 @@ +--- Modules/socketmodule.h.orig ++++ Modules/socketmodule.h +@@ -89,6 +89,8 @@ typedef int socklen_t; + # include + # endif + # include ++#elif defined(HAVE_NETLINK_NETLINK_H) ++# include + #else + # undef AF_NETLINK + #endif diff --git a/lang/python311/files/patch-configure b/lang/python311/files/patch-configure index 4aa2a57ef..a9d654a22 100644 --- a/lang/python311/files/patch-configure +++ b/lang/python311/files/patch-configure @@ -1,11 +1,41 @@ --- configure.orig 2022-12-07 13:31:07 UTC +++ configure -@@ -7630,7 +7630,7 @@ if test "$Py_LTO" = 'true' ; then + +@@ -8336,7 +8336,7 @@ fi if test "$Py_LTO" = 'true' ; then case $CC in - *clang*) + *clang*|cc) LDFLAGS_NOLTO="-fno-lto" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -flto=thin" >&5 - $as_echo_n "checking whether C compiler accepts -flto=thin... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -flto=thin" >&5 + printf %s "checking whether C compiler accepts -flto=thin... " >&6; } +@@ -10629,6 +10629,7 @@ fi + + + # On Linux, netlink.h requires asm/types.h ++# On FreeBSD, netlink.h is located in netlink/netlink.h + ac_fn_c_check_header_compile "$LINENO" "linux/netlink.h" "ac_cv_header_linux_netlink_h" " + #ifdef HAVE_ASM_TYPES_H + #include +@@ -10643,6 +10644,20 @@ then : + printf "%s\n" "#define HAVE_LINUX_NETLINK_H 1" >>confdefs.h + + fi ++ac_fn_c_check_header_compile "$LINENO" "netlink/netlink.h" "ac_cv_header_netlink_netlink_h" " ++#ifdef HAVE_ASM_TYPES_H ++#include ++#endif ++#ifdef HAVE_SYS_SOCKET_H ++#include ++#endif ++ ++" ++if test "x$ac_cv_header_netlink_netlink_h" = xyes ++then : ++ printf "%s\n" "#define HAVE_NETLINK_NETLINK_H 1" >>confdefs.h ++ ++fi + + + # On Linux, qrtr.h requires asm/types.h \ No newline at end of file diff --git a/lang/python311/files/patch-pyconfig.h.in b/lang/python311/files/patch-pyconfig.h.in new file mode 100644 index 000000000..d20d8df3c --- /dev/null +++ b/lang/python311/files/patch-pyconfig.h.in @@ -0,0 +1,12 @@ +--- pyconfig.h.in.orig ++++ pyconfig.h.in +@@ -835,6 +835,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_NETINET_IN_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_NETLINK_NETLINK_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_NETPACKET_PACKET_H + -- 2.41.0