[python26-m2crypto/el5/master: 67/78] - Make test suite pass with OpenSSL 1.0.0 - Don't ship patch backup files in %%doc
gholms
gholms at fedoraproject.org
Wed Feb 23 00:31:06 UTC 2011
commit c75ce4c9e43b4e4231df7b231b1eae1e3b3e656c
Author: Miloslav Trmac <mitr at fedoraproject.org>
Date: Mon Feb 15 21:28:27 2010 +0000
- Make test suite pass with OpenSSL 1.0.0
- Don't ship patch backup files in %%doc
m2crypto-0.20.2-testsuite.patch | 56 +++++++++
m2crypto-0.20.2-threads.patch | 255 +++++++++++++++++++++++++++++++++++++++
m2crypto.spec | 19 +++-
3 files changed, 327 insertions(+), 3 deletions(-)
---
diff --git a/m2crypto-0.20.2-testsuite.patch b/m2crypto-0.20.2-testsuite.patch
new file mode 100644
index 0000000..c664724
--- /dev/null
+++ b/m2crypto-0.20.2-testsuite.patch
@@ -0,0 +1,56 @@
+--- tests/test_smime.py 2010-02-09 17:21:02.428817088 +0100
++++ /home/mitr/m2crypto-tests/current-tests/tests/test_smime.py 2010-02-10 18:07:33.785788459 +0100
+@@ -37,7 +37,7 @@
+ buf = BIO.MemoryBuffer(self.cleartext)
+ s = SMIME.SMIME()
+ s.load_key('tests/signer_key.pem', 'tests/signer.pem')
+- p7 = s.sign(buf)
++ p7 = s.sign(buf, SMIME.PKCS7_DETACHED)
+ assert len(buf) == 0
+ assert p7.type() == SMIME.PKCS7_SIGNED, p7.type()
+ assert isinstance(p7, SMIME.PKCS7), p7
+@@ -73,9 +73,8 @@
+
+ p7, data = SMIME.smime_load_pkcs7_bio(self.signed)
+
+- assert data.read() == self.cleartext
+ assert isinstance(p7, SMIME.PKCS7), p7
+- v = s.verify(p7)
++ v = s.verify(p7, data)
+ assert v == self.cleartext
+
+ t = p7.get0_signers(sk)
+@@ -95,7 +94,6 @@
+ s.set_x509_store(st)
+
+ p7, data = SMIME.smime_load_pkcs7_bio(self.signed)
+- assert data.read() == self.cleartext
+ assert isinstance(p7, SMIME.PKCS7), p7
+ self.assertRaises(SMIME.PKCS7_Error, s.verify, p7) # Bad signer
+
+@@ -169,7 +167,7 @@
+ s.set_cipher(SMIME.Cipher('des_ede3_cbc'))
+
+ tmp = BIO.MemoryBuffer()
+- s.write(tmp, p7, buf)
++ s.write(tmp, p7)
+
+ p7 = s.encrypt(tmp)
+
+@@ -211,6 +209,7 @@
+ assert p7.write(f) == 1
+ f.close()
+
++ p7 = s.sign(BIO.MemoryBuffer('some text'), SMIME.PKCS7_DETACHED)
+ self.filenameSmime = 'tests/sig.p7s'
+ f = BIO.openfile(self.filenameSmime, 'wb')
+ assert s.write(f, p7, BIO.MemoryBuffer('some text')) == 1, Err.get_error()
+@@ -220,7 +219,7 @@
+ buf = BIO.MemoryBuffer()
+ assert SMIME.load_pkcs7(self.filename).write_der(buf) == 1
+ s = buf.read()
+- assert len(s) == 1204, len(s)
++ assert len(s) in (1204, 1243), len(s)
+
+ def test_load_pkcs7(self):
+ assert SMIME.load_pkcs7(self.filename).type() == SMIME.PKCS7_SIGNED
diff --git a/m2crypto-0.20.2-threads.patch b/m2crypto-0.20.2-threads.patch
new file mode 100644
index 0000000..9cf505b
--- /dev/null
+++ b/m2crypto-0.20.2-threads.patch
@@ -0,0 +1,255 @@
+diff -ur M2Crypto/SWIG/_dsa.i M2Crypto-0.20.2/SWIG/_dsa.i
+--- M2Crypto/SWIG/_dsa.i 2009-10-07 06:25:44.000000000 +0200
++++ M2Crypto-0.20.2/SWIG/_dsa.i 2010-02-10 16:46:18.386538508 +0100
+@@ -155,13 +155,14 @@
+ }
+ %}
+
+-%threadallow dsa_read_params;
+ %inline %{
+ DSA *dsa_read_params(BIO *f, PyObject *pyfunc) {
+ DSA *ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_read_bio_DSAparams(f, NULL, passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+@@ -174,27 +175,29 @@
+ }
+ %}
+
+-%threadallow dsa_write_key_bio;
+ %inline %{
+ int dsa_write_key_bio(DSA* dsa, BIO* f, EVP_CIPHER *cipher, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_DSAPrivateKey(f, dsa, cipher, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+ %}
+
+-%threadallow dsa_write_key_bio_no_cipher;
+ %inline %{
+ int dsa_write_key_bio_no_cipher(DSA* dsa, BIO* f, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_DSAPrivateKey(f, dsa, NULL, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+@@ -207,25 +210,27 @@
+ }
+ %}
+
+-%threadallow dsa_read_key;
+ %inline %{
+ DSA *dsa_read_key(BIO *f, PyObject *pyfunc) {
+ DSA *ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_read_bio_DSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+ %}
+
+-%threadallow dsa_read_pub_key;
+ %inline %{
+ DSA *dsa_read_pub_key(BIO *f, PyObject *pyfunc) {
+ DSA *ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_read_bio_DSA_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+diff -ur M2Crypto/SWIG/_ec.i M2Crypto-0.20.2/SWIG/_ec.i
+--- M2Crypto/SWIG/_ec.i 2010-02-09 17:21:02.434816299 +0100
++++ M2Crypto-0.20.2/SWIG/_ec.i 2010-02-10 16:47:59.284538639 +0100
+@@ -205,39 +205,42 @@
+ }
+ %}
+
+-%threadallow ec_key_read_bio;
+ %inline %{
+ EC_KEY *ec_key_read_bio(BIO *f, PyObject *pyfunc) {
+ EC_KEY *ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_read_bio_ECPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+ %}
+
+-%threadallow ec_key_write_bio;
+ %inline %{
+ int ec_key_write_bio(EC_KEY *key, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_ECPrivateKey(f, key, cipher, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+ %}
+
+-%threadallow ec_key_write_bio_no_cipher;
+ %inline %{
+ int ec_key_write_bio_no_cipher(EC_KEY *key, BIO *f, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_ECPrivateKey(f, key, NULL, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+diff -ur M2Crypto/SWIG/_evp.i M2Crypto-0.20.2/SWIG/_evp.i
+--- M2Crypto/SWIG/_evp.i 2010-02-09 17:21:02.439565411 +0100
++++ M2Crypto-0.20.2/SWIG/_evp.i 2010-02-10 16:53:08.174537783 +0100
+@@ -463,39 +463,42 @@
+ }
+ %}
+
+-%threadallow pkey_write_pem_no_cipher;
+ %inline %{
+ int pkey_write_pem_no_cipher(EVP_PKEY *pkey, BIO *f, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, NULL, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+ %}
+
+-%threadallow pkey_write_pem;
+ %inline %{
+ int pkey_write_pem(EVP_PKEY *pkey, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, cipher, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+ %}
+
+-%threadallow pkey_read_pem;
+ %inline %{
+ EVP_PKEY *pkey_read_pem(BIO *f, PyObject *pyfunc) {
+ EVP_PKEY *pk;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ pk = PEM_read_bio_PrivateKey(f, NULL, passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return pk;
+ }
+diff -ur M2Crypto/SWIG/_pkcs7.i M2Crypto-0.20.2/SWIG/_pkcs7.i
+--- M2Crypto/SWIG/_pkcs7.i 2010-02-09 17:21:02.431815471 +0100
++++ M2Crypto-0.20.2/SWIG/_pkcs7.i 2010-02-10 16:55:43.516592774 +0100
+@@ -101,10 +101,9 @@
+ }
+ %}
+
+-%threadallow pkcs7_verify1;
+ %inline %{
+ PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, BIO *data, int flags) {
+- int outlen;
++ int res, outlen;
+ char *outbuf;
+ BIO *bio;
+ PyObject *ret;
+@@ -113,7 +112,10 @@
+ PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1");
+ return NULL;
+ }
+- if (!PKCS7_verify(pkcs7, stack, store, data, bio, flags)) {
++ Py_BEGIN_ALLOW_THREADS
++ res = PKCS7_verify(pkcs7, stack, store, data, bio, flags);
++ Py_END_ALLOW_THREADS
++ if (!res) {
+ PyErr_SetString(_pkcs7_err, ERR_reason_error_string(ERR_get_error()));
+ BIO_free(bio);
+ return NULL;
+diff -ur M2Crypto/SWIG/_rsa.i M2Crypto-0.20.2/SWIG/_rsa.i
+--- M2Crypto/SWIG/_rsa.i 2009-10-07 06:28:50.000000000 +0200
++++ M2Crypto-0.20.2/SWIG/_rsa.i 2010-02-10 16:50:40.029788004 +0100
+@@ -48,39 +48,42 @@
+ }
+ %}
+
+-%threadallow rsa_read_key;
+ %inline %{
+ RSA *rsa_read_key(BIO *f, PyObject *pyfunc) {
+ RSA *rsa;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ rsa = PEM_read_bio_RSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return rsa;
+ }
+ %}
+
+-%threadallow rsa_write_key;
+ %inline %{
+ int rsa_write_key(RSA *rsa, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_RSAPrivateKey(f, rsa, cipher, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
+ %}
+
+-%threadallow rsa_write_key_no_cipher;
+ %inline %{
+ int rsa_write_key_no_cipher(RSA *rsa, BIO *f, PyObject *pyfunc) {
+ int ret;
+
+ Py_INCREF(pyfunc);
++ Py_BEGIN_ALLOW_THREADS
+ ret = PEM_write_bio_RSAPrivateKey(f, rsa, NULL, NULL, 0,
+ passphrase_callback, (void *)pyfunc);
++ Py_END_ALLOW_THREADS
+ Py_DECREF(pyfunc);
+ return ret;
+ }
diff --git a/m2crypto.spec b/m2crypto.spec
index 8a88b15..492576e 100644
--- a/m2crypto.spec
+++ b/m2crypto.spec
@@ -6,7 +6,7 @@
Summary: Support for using OpenSSL in python scripts
Name: m2crypto
Version: 0.20.2
-Release: 4%{?dist}
+Release: 5%{?dist}
Source0: http://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-%{version}.tar.gz
# https://bugzilla.osafoundation.org/show_bug.cgi?id=2341
Patch0: m2crypto-0.18-timeouts.patch
@@ -14,6 +14,10 @@ Patch0: m2crypto-0.18-timeouts.patch
Patch1: m2crypto-0.20-gcc_macros.patch
# https://bugzilla.osafoundation.org/show_bug.cgi?id=12855
Patch2: m2crypto-0.20.1-openssl1.patch
+# https://bugzilla.osafoundation.org/show_bug.cgi?id=12935
+Patch3: m2crypto-0.20.2-threads.patch
+# https://bugzilla.osafoundation.org/show_bug.cgi?id=12936
+Patch4: m2crypto-0.20.2-testsuite.patch
License: MIT
Group: System Environment/Libraries
URL: http://wiki.osafoundation.org/bin/view/Projects/MeTooCrypto
@@ -26,9 +30,11 @@ This package allows you to call OpenSSL functions from python scripts.
%prep
%setup -q -n M2Crypto-%{version}
-%patch0 -p1
+%patch0 -p1 -b .timeouts
%patch1 -p1 -b .gcc_macros
%patch2 -p0 -b .openssl1
+%patch3 -p1 -b .threads
+%patch4 -p0 -b .testsuite
# Red Hat opensslconf.h #includes an architecture-specific file, but SWIG
# doesn't follow the #include.
@@ -76,12 +82,15 @@ done
# Windows-only
rm demo/Zope/starts.bat
-# Fix up documentation permssions
+# Fix up documentation permissions
find demo tests -type f -perm -111 -print0 | xargs -0 chmod a-x
+
python_path=$(which python)
grep -rl '/usr/bin/env python' demo tests \
| xargs sed -i "s,/usr/bin/env python,${python_path},"
+rm tests/*.py.* # Patch backup files
+
%clean
rm -rf $RPM_BUILD_ROOT
@@ -92,6 +101,10 @@ rm -rf $RPM_BUILD_ROOT
%{python_sitearch}/M2Crypto-*.egg-info
%changelog
+* Mon Feb 15 2010 Miloslav Trmač <mitr at redhat.com> - 0.20.2-5
+- Make test suite pass with OpenSSL 1.0.0
+- Don't ship patch backup files in %%doc
+
* Tue Jan 5 2010 Miloslav Trmač <mitr at redhat.com> - 0.20.2-4
- s/%%define/%%global/
More information about the scm-commits
mailing list