Skip to content

Instantly share code, notes, and snippets.

@plntyk
Created August 30, 2015 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plntyk/2ab03ef4bb4ce132a6d5 to your computer and use it in GitHub Desktop.
Save plntyk/2ab03ef4bb4ce132a6d5 to your computer and use it in GitHub Desktop.
From 3ec880ab841472ae1675015176dbff7294e238f6 Mon Sep 17 00:00:00 2001
From: Dirk Neukirchen <dirkneukirchen@web.de>
Date: Sat, 15 Aug 2015 15:44:43 +0200
Subject: [PATCH 47/49] [package] add package python-pcapy
some person on IRC submitted + requested help with that
fixed & helped until it worked (kireevco)
Signed-off-by: Dirk Neukirchen <dirkneukirchen@web.de>
---
package/lang/python-pcapy/Makefile | 51 ++++++++++++++++++++++
.../python-pcapy/patches/001-cross_compile.patch | 20 +++++++++
2 files changed, 71 insertions(+)
create mode 100644 package/lang/python-pcapy/Makefile
create mode 100644 package/lang/python-pcapy/patches/001-cross_compile.patch
diff --git a/package/lang/python-pcapy/Makefile b/package/lang/python-pcapy/Makefile
new file mode 100644
index 0000000..5fac9c0
--- /dev/null
+++ b/package/lang/python-pcapy/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2007-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=pcapy
+PKG_VERSION:=0.10.9
+PKG_RELEASE:=1
+PKG_LICENSE:=Apache Modified
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://pypi.python.org/packages/source/p/pcapy
+PKG_MD5SUM:=b91b423b0efbcffbe516d369f5d77ada
+
+PKG_BUILD_DEPENDS:=python python-setuptools libpcap
+
+include $(INCLUDE_DIR)/package.mk
+$(call include_mk, python-package.mk)
+
+define Package/python-pcapy
+ SUBMENU:=Python
+ SECTION:=lang
+ CATEGORY:=Languages
+ TITLE:=Python interface to the libpcap packet capture library
+ URL:=https://pypi.python.org/pypi/pcapy
+ MAINTAINER:=Dmitry Kireev<dmitry@kireev.co>
+ DEPENDS:=+python +libpcap +libstdcpp
+endef
+
+define Package/python-pcapy/description
+ Pcapy is a Python extension module that interfaces with the libpcap packet capture library.
+endef
+
+define Build/Compile
+ $(call Build/Compile/PyMod,., \
+ install --prefix="/usr" --root="$(PKG_INSTALL_DIR)", \
+ )
+endef
+
+define Package/python-pcapy/install
+ $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)
+ $(CP) \
+ $(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/* \
+ $(1)$(PYTHON_PKG_DIR)
+endef
+
+$(eval $(call BuildPackage,python-pcapy))
diff --git a/package/lang/python-pcapy/patches/001-cross_compile.patch b/package/lang/python-pcapy/patches/001-cross_compile.patch
new file mode 100644
index 0000000..c689468
--- /dev/null
+++ b/package/lang/python-pcapy/patches/001-cross_compile.patch
@@ -0,0 +1,20 @@
+--- a/setup.py
++++ b/setup.py
+@@ -33,17 +33,6 @@ if sys.platform == 'win32':
+ sources.append(os.path.join('win32', 'dllmain.cc'))
+ macros.append(('WIN32', '1'))
+
+-# HACK replace linker gcc with g++
+-from distutils import sysconfig
+-save_init_posix = sysconfig._init_posix
+-def my_init_posix():
+- save_init_posix()
+- g = sysconfig._config_vars
+- if g['LDSHARED'][:3]=='gcc':
+- print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
+- g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
+- print 'to',`g['LDSHARED']`
+-sysconfig._init_posix = my_init_posix
+
+ setup(name = PACKAGE_NAME,
+ version = "0.10.9",
--
2.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment