python-M2Crypto: libressl 2.7 fix (via OpenBSD)

This commit is contained in:
Alessio Sergi 2018-04-27 07:53:15 +02:00
parent 425bfff513
commit 49e5617e8f
2 changed files with 140 additions and 6 deletions

View File

@ -0,0 +1,140 @@
--- SWIG/_bio.i.orig
+++ SWIG/_bio.i
@@ -293,8 +293,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)
+
+#if !defined(LIBRESSL_VERSION_NUMBER)
+static
+#endif
+BIO_METHOD *
BIO_meth_new( int type, const char *name )
{
BIO_METHOD *method = malloc( sizeof(BIO_METHOD) );
@@ -306,7 +310,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 ) {
--- SWIG/_evp.i.orig
+++ SWIG/_evp.i
@@ -19,7 +19,7 @@ Copyright (c) 2009-2010 Heikki Toivonen. All rights re
#include <openssl/rsa.h>
#include <openssl/opensslv.h>
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
HMAC_CTX *HMAC_CTX_new(void) {
HMAC_CTX *ret = PyMem_Malloc(sizeof(HMAC_CTX));
--- SWIG/_lib11_compat.i.orig
+++ 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>
--- SWIG/_lib.i.orig
+++ SWIG/_lib.i
@@ -21,7 +21,7 @@
%{
/* OpenSSL 1.0.2 copmatbility shim */
-#if OPENSSL_VERSION_NUMBER < 0x10002000L
+#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined(LIBRESSL_VERSION_NUMBER)
typedef void (*OPENSSL_sk_freefunc)(void *);
typedef void *(*OPENSSL_sk_copyfunc)(const void *);
typedef struct stack_st OPENSSL_STACK;
@@ -499,7 +499,7 @@ int passphrase_callback(char *buf, int num, int v, voi
%inline %{
void lib_init() {
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
SSLeay_add_all_algorithms();
ERR_load_ERR_strings();
#endif
--- SWIG/_ssl.i.orig
+++ SWIG/_ssl.i
@@ -275,7 +275,7 @@ const SSL_METHOD *sslv3_method(void) {
#endif
const SSL_METHOD *tlsv1_method(void) {
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
PyErr_WarnEx(PyExc_DeprecationWarning,
"Function TLSv1_method has been deprecated.", 1);
#endif
--- SWIG/_threads.i.orig
+++ 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, co
}
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);
--- SWIG/libcrypto-compat.h.orig
+++ SWIG/libcrypto-compat.h
@@ -1,7 +1,7 @@
#ifndef LIBCRYPTO_COMPAT_H
#define LIBCRYPTO_COMPAT_H
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
#include <openssl/rsa.h>
#include <openssl/dsa.h>

View File

@ -14,12 +14,6 @@ license="MIT"
homepage="https://gitlab.com/m2crypto/m2crypto/"
distfiles="${PYPI_SITE}/M/M2Crypto/M2Crypto-${version}.tar.gz"
checksum=0faf8588cc472061ed90ef3dd2f1c11fc3d61d8ac368853ff05fa23a768ee893
broken="https://build.voidlinux.eu/builders/x86_64-musl_builder/builds/9596/steps/shell_3/logs/stdio"
pre_configure() {
sed -i 's/OPENSSL_VERSION_NUMBER < 0x10100000L/OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)/g' SWIG/*.i
sed -i 's/OPENSSL_VERSION_NUMBER >= 0x10100000L/OPENSSL_VERSION_NUMBER >= 0x10100000L \&\& !defined(LIBRESSL_VERSION_NUMBER)/g' SWIG/*.i
}
post_install() {
vlicense LICENCE