pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/lang Add support for NetBSD's socketcan implementation.
details: https://anonhg.NetBSD.org/pkgsrc/rev/d896112d597a
branches: trunk
changeset: 363003:d896112d597a
user: bouyer <bouyer%pkgsrc.org@localhost>
date: Tue May 30 14:04:53 2017 +0000
description:
Add support for NetBSD's socketcan implementation.
Tested with the example from
http://www.bencz.com/hacks/2016/07/10/python-and-socketcan/
Needs <netcan/can.h> rev 1.3 or newer.
diffstat:
lang/python34/distinfo | 7 +-
lang/python34/patches/patch-Modules_socketmodule.c | 71 ++++++++++++++++++++++
lang/python34/patches/patch-Modules_socketmodule.h | 15 ++++
lang/python34/patches/patch-al | 33 ++++++---
lang/python34/patches/patch-pyconfig.h.in | 16 ++++
lang/python35/distinfo | 7 +-
lang/python35/patches/patch-Modules_socketmodule.c | 71 ++++++++++++++++++++++
lang/python35/patches/patch-Modules_socketmodule.h | 15 ++++
lang/python35/patches/patch-configure | 33 ++++++---
lang/python35/patches/patch-pyconfig.h.in | 16 ++++
10 files changed, 258 insertions(+), 26 deletions(-)
diffs (truncated from 465 to 300 lines):
diff -r e3aa912d58e3 -r d896112d597a lang/python34/distinfo
--- a/lang/python34/distinfo Tue May 30 13:57:16 2017 +0000
+++ b/lang/python34/distinfo Tue May 30 14:04:53 2017 +0000
@@ -1,16 +1,19 @@
-$NetBSD: distinfo,v 1.25 2017/01/26 09:45:23 jperkin Exp $
+$NetBSD: distinfo,v 1.26 2017/05/30 14:04:53 bouyer Exp $
SHA1 (Python-3.4.6.tar.xz) = ef7dbec63d45760701534990511d686e3acbbe4f
RMD160 (Python-3.4.6.tar.xz) = a669de69e6728141a6c960877c486c1f094b560d
SHA512 (Python-3.4.6.tar.xz) = f6785cf6a99a8a27823baefe59cc20e34cbec01bb444c8600e7f49b5437159d5137f9d80fce26e219846d71bfe98f68bc6f0c87719a34db0050a4eaca95959ac
Size (Python-3.4.6.tar.xz) = 14473592 bytes
SHA1 (patch-Lib_distutils_unixccompiler.py) = 7d6df07921ad3357757d4681a964256b560b3f57
+SHA1 (patch-Modules_socketmodule.c) = 3b091755d7c104b5d1fc696a0d4a679ed3565ef4
+SHA1 (patch-Modules_socketmodule.h) = ed334a97c2a6662c5b44b4e50c1b8efcc220fa1f
SHA1 (patch-aa) = 14359f8d0527eff08073c0aea60dfe8961d9255d
SHA1 (patch-ah) = 0acdfcbf3ebcb96b18a1cf28f18b286aa507a62f
-SHA1 (patch-al) = 7239d10b67c739c3ee33dd2fc95bb770360d152f
+SHA1 (patch-al) = 5cf4d44d24020a9b6fe41deeb916edbe87a937cb
SHA1 (patch-am) = 5822927f1c315b4fce5078626efe5418c764665e
SHA1 (patch-an) = c9b571eb54fdf0b1e93524a6de6780e8c4119221
SHA1 (patch-au) = b593d64b34531fdd5a936d109854d80e969f1847
SHA1 (patch-av) = 9b44f339f65f029b7f17dbc654739a7ae3c12780
SHA1 (patch-aw) = bd290417c265846e238660180e60e76c0f5f696a
+SHA1 (patch-pyconfig.h.in) = 1fbd8b94a6317e31a3b9db683db0c2c9c4334713
SHA1 (patch-xa) = fb81eaa604b4ed7c1b64c3f4731d58a8aee257be
diff -r e3aa912d58e3 -r d896112d597a lang/python34/patches/patch-Modules_socketmodule.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/python34/patches/patch-Modules_socketmodule.c Tue May 30 14:04:53 2017 +0000
@@ -0,0 +1,71 @@
+$NetBSD: patch-Modules_socketmodule.c,v 1.1 2017/05/30 14:04:53 bouyer Exp $
+
+Support NetBSD's socketcan implementation
+
+--- Modules/socketmodule.c.orig 2017-01-17 08:57:45.000000000 +0100
++++ Modules/socketmodule.c 2017-05-30 15:52:31.835064114 +0200
+@@ -1174,8 +1174,13 @@
+ /* need to look up interface name given index */
+ if (a->can_ifindex) {
+ ifr.ifr_ifindex = a->can_ifindex;
++#ifdef __NetBSD__
++ if (if_indextoname(a->can_ifindex, ifr.ifr_name) != NULL)
++ ifname = ifr.ifr_name;
++#else
+ if (ioctl(sockfd, SIOCGIFNAME, &ifr) == 0)
+ ifname = ifr.ifr_name;
++#endif /* __NetBSD__ */
+ }
+
+ return Py_BuildValue("O&h", PyUnicode_DecodeFSDefault,
+@@ -1589,12 +1594,14 @@
+ }
+ #endif
+
+-#if defined(AF_CAN) && defined(CAN_RAW) && defined(CAN_BCM)
++#if defined(AF_CAN) && defined(CAN_RAW)
+ case AF_CAN:
+ switch (s->sock_proto) {
+ case CAN_RAW:
++#ifdef CAN_BCM
+ /* fall-through */
+ case CAN_BCM:
++#endif
+ {
+ struct sockaddr_can *addr;
+ PyObject *interfaceName;
+@@ -1614,7 +1621,12 @@
+ } else if (len < sizeof(ifr.ifr_name)) {
+ strncpy(ifr.ifr_name, PyBytes_AS_STRING(interfaceName), sizeof(ifr.ifr_name));
+ ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0';
+- if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) {
++#ifdef __NetBSD__
++ if ((ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name)) == 0)
++#else
++ if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0)
++#endif
++ {
+ s->errorhandler();
+ Py_DECREF(interfaceName);
+ return 0;
+@@ -6335,6 +6347,20 @@
+ PyModule_AddIntConstant(m, "CAN_BCM_RX_TIMEOUT", RX_TIMEOUT);
+ PyModule_AddIntConstant(m, "CAN_BCM_RX_CHANGED", RX_CHANGED);
+ #endif
++#ifdef HAVE_NETCAN_CAN_H
++ PyModule_AddIntMacro(m, CAN_EFF_FLAG);
++ PyModule_AddIntMacro(m, CAN_RTR_FLAG);
++ PyModule_AddIntMacro(m, CAN_ERR_FLAG);
++
++ PyModule_AddIntMacro(m, CAN_SFF_MASK);
++ PyModule_AddIntMacro(m, CAN_EFF_MASK);
++ PyModule_AddIntMacro(m, CAN_ERR_MASK);
++
++ PyModule_AddIntMacro(m, CAN_RAW_FILTER);
++ /* PyModule_AddIntMacro(m, CAN_RAW_ERR_FILTER); */
++ PyModule_AddIntMacro(m, CAN_RAW_LOOPBACK);
++ PyModule_AddIntMacro(m, CAN_RAW_RECV_OWN_MSGS);
++#endif
+ #ifdef SOL_RDS
+ PyModule_AddIntMacro(m, SOL_RDS);
+ #endif
diff -r e3aa912d58e3 -r d896112d597a lang/python34/patches/patch-Modules_socketmodule.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/python34/patches/patch-Modules_socketmodule.h Tue May 30 14:04:53 2017 +0000
@@ -0,0 +1,15 @@
+$NetBSD: patch-Modules_socketmodule.h,v 1.1 2017/05/30 14:04:53 bouyer Exp $
+
+--- Modules/socketmodule.h.orig 2017-01-17 08:57:45.000000000 +0100
++++ Modules/socketmodule.h 2017-05-30 15:51:47.251527645 +0200
+@@ -84,6 +84,10 @@
+ #include <linux/can/bcm.h>
+ #endif
+
++#ifdef HAVE_NETCAN_CAN_H
++#include <netcan/can.h>
++#endif
++
+ #ifdef HAVE_SYS_SYS_DOMAIN_H
+ #include <sys/sys_domain.h>
+ #endif
diff -r e3aa912d58e3 -r d896112d597a lang/python34/patches/patch-al
--- a/lang/python34/patches/patch-al Tue May 30 13:57:16 2017 +0000
+++ b/lang/python34/patches/patch-al Tue May 30 14:04:53 2017 +0000
@@ -1,4 +1,4 @@
-$NetBSD: patch-al,v 1.5 2014/10/09 09:15:38 adam Exp $
+$NetBSD: patch-al,v 1.6 2017/05/30 14:04:53 bouyer Exp $
MirBSD support
http://bugs.python.org/issue21458
@@ -7,9 +7,11 @@
XXX: Not sure what the BLDSHARED changes are about.
---- configure.orig 2014-10-08 08:18:16.000000000 +0000
-+++ configure
-@@ -3358,7 +3358,7 @@ case $ac_sys_system/$ac_sys_release in
+detect netcan/can.h on NetBSD
+
+--- configure.orig 2017-01-17 08:57:47.000000000 +0100
++++ configure 2017-05-30 15:49:43.508649775 +0200
+@@ -3369,7 +3369,7 @@
# Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
# In addition, Stefan Krah confirms that issue #1244610 exists through
# OpenBSD 4.6, but is fixed in 4.7.
@@ -18,7 +20,7 @@
define_xopen_source=no
# OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
# also defined. This can be overridden by defining _BSD_SOURCE
-@@ -5636,15 +5636,10 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>
+@@ -5650,15 +5650,10 @@
PY3LIBRARY=libpython3.so
fi
;;
@@ -35,7 +37,16 @@
INSTSONAME="$LDLIBRARY".$SOVERSION
if test "$with_pydebug" != yes
then
-@@ -8543,8 +8538,8 @@ then
+@@ -7283,7 +7278,7 @@
+
+
+ # On Linux, can.h and can/raw.h require sys/socket.h
+-for ac_header in linux/can.h linux/can/raw.h linux/can/bcm.h
++for ac_header in linux/can.h linux/can/raw.h linux/can/bcm.h netcan/can.h
+ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "
+@@ -8561,8 +8556,8 @@
LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
else
# No framework, use the Python app as bundle-loader
@@ -46,7 +57,7 @@
LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
fi ;;
Darwin/*)
-@@ -8568,9 +8563,9 @@ then
+@@ -8586,9 +8581,9 @@
LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
else
# No framework, use the Python app as bundle-loader
@@ -59,7 +70,7 @@
fi
else
# building for OS X 10.3 and later
-@@ -8609,6 +8604,9 @@ then
+@@ -8627,6 +8622,9 @@
;;
esac
fi;;
@@ -69,7 +80,7 @@
NetBSD*|DragonFly*)
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
-@@ -8652,7 +8650,7 @@ then
+@@ -8670,7 +8668,7 @@
fi;;
Linux*|GNU*) CCSHARED="-fPIC";;
BSD/OS*/4*) CCSHARED="-fpic";;
@@ -78,7 +89,7 @@
OpenUNIX*|UnixWare*)
if test "$GCC" = "yes"
then CCSHARED="-fPIC"
-@@ -8701,7 +8699,7 @@ then
+@@ -8719,7 +8717,7 @@
OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
@@ -87,7 +98,7 @@
if [ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]
then
LINKFORSHARED="-Wl,--export-dynamic"
-@@ -13935,8 +13933,6 @@ $as_echo "$SOABI" >&6; }
+@@ -14017,8 +14015,6 @@
case $ac_sys_system in
diff -r e3aa912d58e3 -r d896112d597a lang/python34/patches/patch-pyconfig.h.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/python34/patches/patch-pyconfig.h.in Tue May 30 14:04:53 2017 +0000
@@ -0,0 +1,16 @@
+$NetBSD: patch-pyconfig.h.in,v 1.3 2017/05/30 14:04:53 bouyer Exp $
+
+detect netcan/can.h on NetBSD
+
+--- pyconfig.h.in.orig 2017-01-17 08:57:47.000000000 +0100
++++ pyconfig.h.in 2017-05-30 15:51:02.132654510 +0200
+@@ -522,6 +522,9 @@
+ /* Define to 1 if you have the <linux/can/raw.h> header file. */
+ #undef HAVE_LINUX_CAN_RAW_H
+
++/* Define to 1 if you have the <netcan/can.h> header file. */
++#undef HAVE_NETCAN_CAN_H
++
+ /* Define to 1 if you have the <linux/netlink.h> header file. */
+ #undef HAVE_LINUX_NETLINK_H
+
diff -r e3aa912d58e3 -r d896112d597a lang/python35/distinfo
--- a/lang/python35/distinfo Tue May 30 13:57:16 2017 +0000
+++ b/lang/python35/distinfo Tue May 30 14:04:53 2017 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.10 2017/01/26 09:45:23 jperkin Exp $
+$NetBSD: distinfo,v 1.11 2017/05/30 14:04:53 bouyer Exp $
SHA1 (Python-3.5.3.tar.xz) = 127121fdca11e735b3686e300d66f73aba663e93
RMD160 (Python-3.5.3.tar.xz) = 663ad06b0c4b36e7760f5202e73bc53697f225d2
@@ -11,6 +11,9 @@
SHA1 (patch-Modules___cursesmodule.c) = 2ab2779e0418a4529987641c254686ba05d28593
SHA1 (patch-Modules_makesetup) = c9b571eb54fdf0b1e93524a6de6780e8c4119221
SHA1 (patch-Modules_nismodule.c) = bd290417c265846e238660180e60e76c0f5f696a
+SHA1 (patch-Modules_socketmodule.c) = 63d583340b071b07ff3e31cf332fcc2ca9ab50e3
+SHA1 (patch-Modules_socketmodule.h) = 13a3290eb72078067060d3e71b7baa08f3eb591c
SHA1 (patch-Python_thread__pthread.h) = fb81eaa604b4ed7c1b64c3f4731d58a8aee257be
-SHA1 (patch-configure) = 069f7bb10d98e3616f52859a2cf90c7f5732425e
+SHA1 (patch-configure) = fcdc55c8cc84017364f840f35e7ec4a131074520
+SHA1 (patch-pyconfig.h.in) = 5d11bd737a949f89b3fbd14db4920873bcc3282e
SHA1 (patch-setup.py) = 7d8afe5e799c8373fe41fbb65e283e0c6f3967d2
diff -r e3aa912d58e3 -r d896112d597a lang/python35/patches/patch-Modules_socketmodule.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/python35/patches/patch-Modules_socketmodule.c Tue May 30 14:04:53 2017 +0000
@@ -0,0 +1,71 @@
+$NetBSD: patch-Modules_socketmodule.c,v 1.1 2017/05/30 14:04:54 bouyer Exp $
+
+Support NetBSD's socketcan implementation
+
+--- Modules/socketmodule.c.orig 2017-01-17 08:57:53.000000000 +0100
++++ Modules/socketmodule.c 2017-05-30 15:43:04.200284076 +0200
+@@ -1346,8 +1346,13 @@
+ /* need to look up interface name given index */
+ if (a->can_ifindex) {
+ ifr.ifr_ifindex = a->can_ifindex;
++#ifdef __NetBSD__
++ if (if_indextoname(a->can_ifindex, ifr.ifr_name) != NULL)
++ ifname = ifr.ifr_name;
++#else
+ if (ioctl(sockfd, SIOCGIFNAME, &ifr) == 0)
+ ifname = ifr.ifr_name;
++#endif /* __NetBSD__ */
+ }
+
+ return Py_BuildValue("O&h", PyUnicode_DecodeFSDefault,
+@@ -1834,12 +1839,14 @@
+ }
+ #endif
+
+-#if defined(AF_CAN) && defined(CAN_RAW) && defined(CAN_BCM)
++#if defined(AF_CAN) && defined(CAN_RAW)
+ case AF_CAN:
+ switch (s->sock_proto) {
+ case CAN_RAW:
++#ifdef CAN_BCM
+ /* fall-through */
+ case CAN_BCM:
++#endif
+ {
+ struct sockaddr_can *addr;
+ PyObject *interfaceName;
+@@ -1859,7 +1866,12 @@
+ } else if ((size_t)len < sizeof(ifr.ifr_name)) {
+ strncpy(ifr.ifr_name, PyBytes_AS_STRING(interfaceName), sizeof(ifr.ifr_name));
+ ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0';
+- if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) {
Home |
Main Index |
Thread Index |
Old Index