commit: 3ebcec43bf7e3d80c361a45e3ab95c4229c09906 Author: orbea <orbea <AT> riseup <DOT> net> AuthorDate: Sun Nov 10 23:53:35 2024 +0000 Commit: orbea <orbea <AT> riseup <DOT> net> CommitDate: Sun Nov 10 23:53:35 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=3ebcec43
dev-python/m2crypto: add 0.43.0 Signed-off-by: orbea <orbea <AT> riseup.net> dev-python/m2crypto/Manifest | 1 + .../m2crypto/files/m2crypto-libressl-0.43.0.patch | 165 +++++++++++++++++++++ dev-python/m2crypto/m2crypto-0.43.0.ebuild | 74 +++++++++ 3 files changed, 240 insertions(+) diff --git a/dev-python/m2crypto/Manifest b/dev-python/m2crypto/Manifest index 97f6e8c..478d208 100644 --- a/dev-python/m2crypto/Manifest +++ b/dev-python/m2crypto/Manifest @@ -1 +1,2 @@ DIST m2crypto-0.42.0.tar.gz 240072 BLAKE2B 86b9f340eb90a8fc94b09faa20a676a3a63c0c64a0902a6729face72b602a2f55941c156ecb3d522a823457d2514e96b147585264200674e11dfaba3d19790de SHA512 b36fb6d1ca401de9741118ab8d43113511bf27d32f45d2257ed70ea8d3b8a3beaf811731dbbece00a6b990366c43096c6b5f5b12d4649ae923bff98c5fc8e674 +DIST m2crypto-0.43.0.tar.gz 366785 BLAKE2B 611daee57c5605246c0a505604e54ec7e029301194ed75bcb7c02ec04f0246a3dc05e13c8c00f1cc15496495a81c098b203cf69a75ce5a65ea3c7a1c0445e5d3 SHA512 c5232956a88de51bd3a1e02859b7a308eabb4e055cc0c8aac2d8d34a60c60a4a4c7160db4060ec07f559134a04eb41c6ab116a194ec3f7441d342e6d38f9add9 diff --git a/dev-python/m2crypto/files/m2crypto-libressl-0.43.0.patch b/dev-python/m2crypto/files/m2crypto-libressl-0.43.0.patch new file mode 100644 index 0000000..aca4704 --- /dev/null +++ b/dev-python/m2crypto/files/m2crypto-libressl-0.43.0.patch @@ -0,0 +1,165 @@ +$OpenBSD: patch-src_M2Crypto_BIO_py,v 1.1 2021/07/24 20:02:04 sthen Exp $ + +Partially revert https://gitlab.com/m2crypto/m2crypto/commit/738cd0bf3dc2ee619f598290d5bf4c2190987f16: + + * Fix BIO.File ... return type of BIO.readline() and close properly. + That is, flush BIO.File() before closing and close also underlying + system file. + +For Python 2 this results in: + +python2 -c "import M2Crypto; M2Crypto.BIO.openfile('/etc/ssl/cert.pem')" +Traceback (most recent call last): + File "<string>", line 1, in <module> + File "/usr/local/lib/python2.7/site-packages/M2Crypto/BIO.py", line 284, in openfile + return File(f) + File "/usr/local/lib/python2.7/site-packages/M2Crypto/BIO.py", line 239, in __init__ + pyfile.flush() +IOError: [Errno 9] Bad file descriptor + +https://gitlab.com/m2crypto/m2crypto/issues/211 + +--- a/src/M2Crypto/BIO.py ++++ b/src/M2Crypto/BIO.py +@@ -232,8 +232,9 @@ class File(BIO): + # + # https://docs.python.org/3.3/c-api/file.html + # +- pyfile.flush() +- self.fname = pyfile.name ++ if six.PY3: ++ pyfile.flush() ++ self.fname = pyfile.name + self.pyfile = pyfile + # Be wary of https://github.com/openssl/openssl/pull/1925 + # BIO_new_fd is NEVER to be used before OpenSSL 1.1.1 +@@ -245,15 +246,17 @@ class File(BIO): + self.bio = m2.bio_new_pyfile(pyfile, m2.bio_noclose) + + self.close_pyfile = close_pyfile +- self.closed = False ++ if six.PY3: ++ self.closed = False + + def flush(self) -> None: + super(File, self).flush() + self.pyfile.flush() + + def close(self) -> None: +- self.flush() +- super(File, self).close() ++ if six.PY3: ++ self.flush() ++ super(File, self).close() + if self.close_pyfile: + self.pyfile.close() + +--- a/src/SWIG/_bio.i ++++ b/src/SWIG/_bio.i +@@ -307,8 +307,12 @@ int bio_should_write(BIO* a) { + } + + /* Macros for things not defined before 1.1.0 */ +-#if OPENSSL_VERSION_NUMBER < 0x10100000L +-static BIO_METHOD * ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050000fL) ++ ++#if !defined(LIBRESSL_VERSION_NUMBER) ++static ++#endif ++BIO_METHOD * + BIO_meth_new( int type, const char *name ) + { + Py_BEGIN_ALLOW_THREADS +@@ -322,7 +326,10 @@ BIO_meth_new( int type, const char *name ) + return method; + } + +-static void ++#if !defined(LIBRESSL_VERSION_NUMBER) ++static ++#endif ++void + BIO_meth_free( BIO_METHOD *meth ) + { + if ( meth == NULL ) { +--- a/src/SWIG/_lib11_compat.i ++++ b/src/SWIG/_lib11_compat.i +@@ -8,7 +8,7 @@ + */ + + %{ +-#if OPENSSL_VERSION_NUMBER < 0x10100000L ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + + #include <string.h> + #include <openssl/engine.h> +@@ -24,6 +24,8 @@ static void *CRYPTO_zalloc(size_t num, const char *file, int line) + return ret; + } + ++#endif ++#if OPENSSL_VERSION_NUMBER < 0x10100000L + #include <openssl/bn.h> + + #ifndef BN_F_BN_GENCB_NEW +--- a/src/SWIG/_threads.i ++++ b/src/SWIG/_threads.i +@@ -5,7 +5,7 @@ + #include <pythread.h> + #include <openssl/crypto.h> + +-#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L ++#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + #define CRYPTO_num_locks() (CRYPTO_NUM_LOCKS) + static PyThread_type_lock lock_cs[CRYPTO_num_locks()]; + static long lock_count[CRYPTO_num_locks()]; +@@ -13,7 +13,7 @@ static int thread_mode = 0; + #endif + + void threading_locking_callback(int mode, int type, const char *file, int line) { +-#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L ++#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + if (mode & CRYPTO_LOCK) { + PyThread_acquire_lock(lock_cs[type], WAIT_LOCK); + lock_count[type]++; +@@ -25,7 +25,7 @@ void threading_locking_callback(int mode, int type, const char *file, int line) + } + + unsigned long threading_id_callback(void) { +-#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L ++#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + return (unsigned long)PyThread_get_thread_ident(); + #else + return (unsigned long)0; +@@ -35,7 +35,7 @@ unsigned long threading_id_callback(void) { + + %inline %{ + void threading_init(void) { +-#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L ++#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + int i; + if (!thread_mode) { + for (i=0; i<CRYPTO_num_locks(); i++) { +@@ -50,7 +50,7 @@ void threading_init(void) { + } + + void threading_cleanup(void) { +-#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L ++#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + int i; + if (thread_mode) { + CRYPTO_set_locking_callback(NULL); +--- a/src/SWIG/_x509.i ++++ b/src/SWIG/_x509.i +@@ -110,8 +110,10 @@ extern int X509_cmp_current_time(ASN1_TIME *); + + %rename(x509_check_purpose) X509_check_purpose; + extern int X509_check_purpose(X509 *, int, int); ++#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x4000000fL + %rename(x509_check_trust) X509_check_trust; + extern int X509_check_trust(X509 *, int, int); ++#endif + + %rename(x509_write_pem) PEM_write_bio_X509; + %threadallow PEM_write_bio_X509; diff --git a/dev-python/m2crypto/m2crypto-0.43.0.ebuild b/dev-python/m2crypto/m2crypto-0.43.0.ebuild new file mode 100644 index 0000000..5c74336 --- /dev/null +++ b/dev-python/m2crypto/m2crypto-0.43.0.ebuild @@ -0,0 +1,74 @@ +# Copyright 2018-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_EXT=1 +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{10..12} ) +PYPI_PN="M2Crypto" +PYTHON_REQ_USE="threads(+)" + +inherit distutils-r1 toolchain-funcs pypi + +DESCRIPTION="A Python crypto and SSL toolkit" +HOMEPAGE=" + https://gitlab.com/m2crypto/m2crypto/ + https://pypi.org/project/M2Crypto/ +" + +# openssl via src/SWIG/_lib11_compat.i +LICENSE="MIT openssl" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos" +IUSE="abi_mips_n32 abi_mips_n64 abi_mips_o32" + +DEPEND=" + dev-libs/openssl:= +" +RDEPEND=" + ${DEPEND} +" +BDEPEND=" + >=dev-lang/swig-2.0.9 +" + +PATCHES=( + "${FILESDIR}"/${PN}-libressl-0.43.0.patch +) + +swig_define() { + local x + for x; do + if tc-cpp-is-true "defined(${x})"; then + SWIG_FEATURES+=" -D${x}" + fi + done +} + +src_prepare() { + # relies on very exact clock behavior which apparently fails + # with inconvenient CONFIG_HZ* + sed -e 's:test_server_simple_timeouts:_&:' \ + -i tests/test_ssl.py || die + distutils-r1_src_prepare +} + +python_compile() { + # setup.py looks at platform.machine() to determine swig options. + # For exotic ABIs, we need to give swig a hint. + local -x SWIG_FEATURES= + + # https://bugs.gentoo.org/617946 + swig_define __ILP32__ + + # https://bugs.gentoo.org/674112 + swig_define __ARM_PCS_VFP + + distutils-r1_python_compile +} + +python_test() { + "${EPYTHON}" -m unittest -b -v tests.alltests.suite || + die "Tests failed for ${EPYTHON}" +}
