ports/172299: [PATCH] security/py-pycrypto: Make GMP OPTION'al, Add test targets

Kubilay Kocak koobs.freebsd at gmail.com
Wed Oct 3 09:30:13 UTC 2012


>Number:         172299
>Category:       ports
>Synopsis:       [PATCH] security/py-pycrypto: Make GMP OPTION'al, Add test targets
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 03 09:30:12 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Kubilay Kocak
>Release:        FreeBSD 9.0-RELEASE-p3 amd64
>Organization:
>Environment:
System: FreeBSD freebsd-9-amd64 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Sat Jul  7 21:26:56 EST
>Description:
- Make GMP OPTION'al
- Add upstream patch for test failure when built without GMP 
    https://bugs.launchpad.net/pycrypto/+bug/1004781
    https://github.com/dlitz/pycrypto/pull/22
- Update pkg-plist (%%GMP and new files)
- Add test and regression-test targets
- Whitespace alignment

====[QA]====

  - portlint: looks fine.
  - porttest: OK
  - redports: https://redports.org/buildarchive/20121003060945-29451/ (WITHOUT_GMP)
  - redports: https://redports.org/buildarchive/20121003061601-26664/ (WITH_GMP)
  - unittest: Ran 1030 tests in 21.603s - OK (WITHOUT_GMP)
  - unittest: Ran 1064 tests in 8.096s - OK (WITH_GMP)
  
============

Added file(s):
- files/patch-lib__Crypto__SelfTest__Util__test_number.py

Port maintainer (jgh at FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: ports)
>How-To-Repeat:
>Fix:

--- py27-pycrypto-2.6.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/security/py-pycrypto/Makefile ./Makefile
--- /usr/ports/security/py-pycrypto/Makefile	2012-07-03 02:32:38.000000000 +1000
+++ ./Makefile	2012-10-03 16:13:39.000000000 +1000
@@ -15,17 +15,37 @@
 MAINTAINER=	jgh at FreeBSD.org
 COMMENT=	The Python Cryptography Toolkit
 
-USE_PYTHON=	yes
-USE_PYDISTUTILS=yes
+USE_PYTHON=		yes
+USE_PYDISTUTILS=	yes
 
 HAS_CONFIGURE=	yes
 USE_AUTOTOOLS=	autoconf
-CPPFLAGS+=	-I${LOCALBASE}/include
-LDFLAGS+=	-L${LOCALBASE}/lib
 
-LIB_DEPENDS+=	gmp.10:${PORTSDIR}/math/gmp
+OPTIONS_DEFINE=		GMP
+OPTIONS_DEFAULT=	GMP
+GMP_DESC=		Use GMP for faster DSA/RSA operations
+
+OPTIONSFILE?=		${PORT_DBDIR}/py-${PORTNAME}/options
+
+.include <bsd.port.options.mk>
+
+.if ${PORT_OPTIONS:MGMP}
+LIB_DEPENDS+=		gmp:${PORTSDIR}/math/gmp
+CONFIGURE_ARGS+=	--with-gmp
+CPPFLAGS+=		-I${LOCALBASE}/include
+LDFLAGS+=		-L${LOCALBASE}/lib
+PLIST_SUB+=		GMP=""
+.else
+CONFIGURE_ARGS+=	--without-gmp
+PLIST_SUB+=		GMP="@comment "
+.endif
 
 pre-patch:
 	@${REINPLACE_CMD} -e "s|%%LOCALBASE%%|${LOCALBASE}|" ${WRKSRC}/setup.py
 
+test: build
+	cd ${WRKSRC} && ${PYTHON_CMD} ${PYSETUP} test
+
+regression-test: test
+
 .include <bsd.port.mk>
diff -ruN --exclude=CVS /usr/ports/security/py-pycrypto/files/patch-lib__Crypto__SelfTest__Util__test_number.py ./files/patch-lib__Crypto__SelfTest__Util__test_number.py
--- /usr/ports/security/py-pycrypto/files/patch-lib__Crypto__SelfTest__Util__test_number.py	1970-01-01 10:00:00.000000000 +1000
+++ ./files/patch-lib__Crypto__SelfTest__Util__test_number.py	2012-10-03 16:04:31.000000000 +1000
@@ -0,0 +1,37 @@
+--- ./lib/Crypto/SelfTest/Util/test_number.py.orig	2012-10-03 16:03:52.000000000 +1000
++++ ./lib/Crypto/SelfTest/Util/test_number.py	2012-10-03 16:04:01.000000000 +1000
+@@ -276,6 +276,11 @@
+         self.assertEqual(number.size(0xa2ba40),8*3)
+         self.assertEqual(number.size(0xa2ba40ee07e3b2bd2f02ce227f36a195024486e49c19cb41bbbdfbba98b22b0e577c2eeaffa20d883a76e65e394c69d4b3c05a1e8fadda27edb2a42bc000fe888b9b32c22d15add0cd76b3e7936e19955b220dd17d4ea904b1ec102b2e4de7751222aa99151024c7cb41cc5ea21d00eeb41f7c800834d2c6e06bce3bce7ea9a5L), 1024)
+ 
++class FastmathTests(unittest.TestCase):
++    def setUp(self):
++        global number
++        from Crypto.Util import number
++
+     def test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ(self):
+         """Test that mpzToLongObj and longObjToMPZ (internal functions) roundtrip negative numbers correctly."""
+         n = -100000000000000000000000000000000000L
+@@ -286,7 +291,21 @@
+ 
+ def get_tests(config={}):
+     from Crypto.SelfTest.st_common import list_test_cases
+-    return list_test_cases(MiscTests)
++    tests = list_test_cases(MiscTests)
++    try:
++        from Crypto.PublicKey import _fastmath
++        tests += list_test_cases(FastmathTests)
++    except ImportError:
++        from distutils.sysconfig import get_config_var
++        import inspect, os.path
++        _fm_path = os.path.normpath(os.path.dirname(os.path.abspath(
++            inspect.getfile(inspect.currentframe())))
++            +"/../../PublicKey/_fastmath"+get_config_var("SO"))
++        if os.path.exists(_fm_path):
++            raise ImportError("While the _fastmath module exists, importing "+
++                "it failed. This may point to the gmp or mpir shared library "+
++                "not being in the path. _fastmath was found at "+_fm_path)
++    return tests
+ 
+ if __name__ == '__main__':
+     suite = lambda: unittest.TestSuite(get_tests())
diff -ruN --exclude=CVS /usr/ports/security/py-pycrypto/files/patch-setup.py ./files/patch-setup.py
--- /usr/ports/security/py-pycrypto/files/patch-setup.py	2011-12-08 22:18:08.000000000 +1100
+++ ./files/patch-setup.py	2012-10-03 16:04:31.000000000 +1000
@@ -1,6 +1,6 @@
---- setup.py.orig	2011-11-01 17:47:23.000000000 +0400
-+++ setup.py	2011-11-01 17:54:51.000000000 +0400
-@@ -177,6 +177,7 @@
+--- ./setup.py.orig	2012-10-03 15:57:50.000000000 +1000
++++ ./setup.py	2012-10-03 15:57:50.000000000 +1000
+@@ -136,6 +136,7 @@
                  # especially helps the DES modules.
                  self.__add_compiler_option("-O3")
                  self.__add_compiler_option("-fomit-frame-pointer")
diff -ruN --exclude=CVS /usr/ports/security/py-pycrypto/pkg-plist ./pkg-plist
--- /usr/ports/security/py-pycrypto/pkg-plist	2012-06-26 02:06:47.000000000 +1000
+++ ./pkg-plist	2012-10-03 15:35:15.000000000 +1000
@@ -115,7 +115,7 @@
 %%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.py
 %%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.pyc
 %%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.pyo
-%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_fastmath.so
+%%GMP%%%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_fastmath.so
 %%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.py
 %%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.pyc
 %%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.pyo
--- py27-pycrypto-2.6.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list