From 5354cf51592966364b8c7514e9f8b5316b8740cd Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Thu, 29 Oct 2015 12:43:28 +0800 Subject: [PATCH 1/3] python-crypto: import pycrypto from old packages feed - update to latest stable version (2.6.1) - add PyPackage call - add license info - add myself as maintainer Signed-off-by: Jeffery To --- lang/python-crypto/Makefile | 51 +++++++++++++++++++ .../patches/001-no-host-paths.patch | 11 ++++ 2 files changed, 62 insertions(+) create mode 100644 lang/python-crypto/Makefile create mode 100644 lang/python-crypto/patches/001-no-host-paths.patch diff --git a/lang/python-crypto/Makefile b/lang/python-crypto/Makefile new file mode 100644 index 000000000..0e3eeb68d --- /dev/null +++ b/lang/python-crypto/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (C) 2009-2015 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:=pycrypto +PKG_VERSION:=2.6.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/ +PKG_MD5SUM:=55a61a054aa66812daf5161a0d5d7eda + +PKG_LICENSE:=Public Domain +PKG_LICENSE_FILES:=COPYRIGHT +PKG_MAINTAINER:=Jeffery To + +include $(INCLUDE_DIR)/package.mk +$(call include_mk, python-package.mk) + +define Package/python-crypto + SECTION:=lang-python + CATEGORY:=Languages + SUBMENU:=Python + TITLE:=python-crypto + URL:=http://www.pycrypto.org/ + DEPENDS:=+python +libgmp +endef + +define Package/python-crypto/description +A collection of both secure hash functions (such as MD5 and SHA), +and various encryption algorithms (AES, DES, IDEA, RSA, ElGamal, etc.). +endef + +define Build/Compile + $(call Build/Compile/PyMod,,install --prefix=/usr --root=$(PKG_INSTALL_DIR)) +endef + +define Package/python-crypto/install + $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)/ + $(CP) \ + $(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/* \ + $(1)$(PYTHON_PKG_DIR)/ +endef + +$(eval $(call PyPackage,python-crypto)) +$(eval $(call BuildPackage,python-crypto)) diff --git a/lang/python-crypto/patches/001-no-host-paths.patch b/lang/python-crypto/patches/001-no-host-paths.patch new file mode 100644 index 000000000..d481627a2 --- /dev/null +++ b/lang/python-crypto/patches/001-no-host-paths.patch @@ -0,0 +1,11 @@ +--- a/setup.py ++++ b/setup.py +@@ -370,7 +370,7 @@ kw = {'name':"pycrypto", + 'ext_modules': plat_ext + [ + # _fastmath (uses GNU mp library) + Extension("Crypto.PublicKey._fastmath", +- include_dirs=['src/','/usr/include/'], ++ include_dirs=['src/'], + libraries=['gmp'], + sources=["src/_fastmath.c"]), + From 35ae47a44c9a4044647689ea1360fe5b6f2a90c9 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 30 Oct 2015 23:48:52 +0800 Subject: [PATCH 2/3] python-crypto: fixed endianness detection This fixes setup.py so that it uses the endianness of the target system instead of detecting endianness from the host. This affects the computation of RIPEMD-160 hashes. Signed-off-by: Jeffery To --- lang/python-crypto/Makefile | 5 ++++- .../patches/002-fix-endianness-detect.patch | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lang/python-crypto/patches/002-fix-endianness-detect.patch diff --git a/lang/python-crypto/Makefile b/lang/python-crypto/Makefile index 0e3eeb68d..e0a3b7bf3 100644 --- a/lang/python-crypto/Makefile +++ b/lang/python-crypto/Makefile @@ -37,7 +37,10 @@ and various encryption algorithms (AES, DES, IDEA, RSA, ElGamal, etc.). endef define Build/Compile - $(call Build/Compile/PyMod,,install --prefix=/usr --root=$(PKG_INSTALL_DIR)) + $(call Build/Compile/PyMod,,\ + install --prefix=/usr --root=$(PKG_INSTALL_DIR),\ + CONFIG_BIG_ENDIAN="$(CONFIG_BIG_ENDIAN)" \ + ) endef define Package/python-crypto/install diff --git a/lang/python-crypto/patches/002-fix-endianness-detect.patch b/lang/python-crypto/patches/002-fix-endianness-detect.patch new file mode 100644 index 000000000..fd3a656fd --- /dev/null +++ b/lang/python-crypto/patches/002-fix-endianness-detect.patch @@ -0,0 +1,15 @@ +--- a/setup.py 2015-10-30 23:30:22.334127083 +0800 ++++ b/setup.py 2015-10-30 23:33:03.856098660 +0800 +@@ -100,6 +100,12 @@ + w(kwd.get("end", "\n")) + + def endianness_macro(): ++ if "CONFIG_BIG_ENDIAN" in os.environ: ++ if os.environ["CONFIG_BIG_ENDIAN"] == "y": ++ return ('PCT_BIG_ENDIAN', 1) ++ else: ++ return ('PCT_LITTLE_ENDIAN', 1) ++ raise AssertionError("CONFIG_BIG_ENDIAN environment variable missing") + s = struct.pack("@I", 0x33221100) + if s == "\x00\x11\x22\x33".encode(): # little endian + return ('PCT_LITTLE_ENDIAN', 1) From a69543b51e4542a8d5e4c42614d7e294476eeaad Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sun, 1 Nov 2015 14:38:52 +0800 Subject: [PATCH 3/3] python-crypto: let the KeyError bubble up instead of manually throwing an AssertionError Signed-off-by: Jeffery To --- .../patches/002-fix-endianness-detect.patch | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lang/python-crypto/patches/002-fix-endianness-detect.patch b/lang/python-crypto/patches/002-fix-endianness-detect.patch index fd3a656fd..baed012bf 100644 --- a/lang/python-crypto/patches/002-fix-endianness-detect.patch +++ b/lang/python-crypto/patches/002-fix-endianness-detect.patch @@ -1,15 +1,13 @@ ---- a/setup.py 2015-10-30 23:30:22.334127083 +0800 -+++ b/setup.py 2015-10-30 23:33:03.856098660 +0800 -@@ -100,6 +100,12 @@ +--- a/setup.py ++++ b/setup.py +@@ -100,6 +100,10 @@ w(kwd.get("end", "\n")) def endianness_macro(): -+ if "CONFIG_BIG_ENDIAN" in os.environ: -+ if os.environ["CONFIG_BIG_ENDIAN"] == "y": -+ return ('PCT_BIG_ENDIAN', 1) -+ else: -+ return ('PCT_LITTLE_ENDIAN', 1) -+ raise AssertionError("CONFIG_BIG_ENDIAN environment variable missing") ++ if os.environ["CONFIG_BIG_ENDIAN"] == "y": ++ return ('PCT_BIG_ENDIAN', 1) ++ else: ++ return ('PCT_LITTLE_ENDIAN', 1) s = struct.pack("@I", 0x33221100) if s == "\x00\x11\x22\x33".encode(): # little endian return ('PCT_LITTLE_ENDIAN', 1)