aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2018-03-26 13:50:18 +0200
committerJakub Jirutka <jakub@jirutka.cz>2018-03-26 14:05:55 +0200
commit6de36ee0aa2db3c3bdea5d439c42a97b392695ed (patch)
tree810175e18d465c4a06afc7bc2d44387e0c8e780c /testing
parentec716252e53b81d188f9024bdca230ab813dee5b (diff)
downloadaports-6de36ee0aa2db3c3bdea5d439c42a97b392695ed.tar.bz2
aports-6de36ee0aa2db3c3bdea5d439c42a97b392695ed.tar.xz
testing/crystal: fix compatibility with LibreSSL
Diffstat (limited to 'testing')
-rw-r--r--testing/crystal/APKBUILD9
-rw-r--r--testing/crystal/libressl.patch120
2 files changed, 125 insertions, 4 deletions
diff --git a/testing/crystal/APKBUILD b/testing/crystal/APKBUILD
index cec2afea81..121e4ab4da 100644
--- a/testing/crystal/APKBUILD
+++ b/testing/crystal/APKBUILD
@@ -1,9 +1,8 @@
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
-# TODO: Fix SSL bindings for LibreSSL (https://github.com/crystal-lang/crystal/issues/4676)
pkgname=crystal
pkgver=0.24.2
-pkgrel=3
+pkgrel=4
_bootver=0.24.2
_llvmver=5
pkgdesc="The Crystal Programming Language"
@@ -11,7 +10,7 @@ url="https://crystal-lang.org/"
arch="x86_64 aarch64"
license="Apache-2.0"
depends="gc-dev libatomic_ops libevent-dev libxml2-dev gcc gmp-dev pcre-dev yaml-dev"
-checkdepends="openssl-dev paxmark readline-dev tzdata zlib-dev"
+checkdepends="libressl-dev paxmark readline-dev tzdata zlib-dev"
makedepends="llvm$_llvmver-dev ${BUILD_STATIC:+"llvm$_llvmver-static"}"
subpackages="$pkgname-doc
$pkgname-bash-completion:bashcomp:noarch
@@ -27,6 +26,7 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/crystal-lang/$pkgname/archiv
aarch64-linux-musl.patch
fix-codegen-specs.patch
disable-specs-using-GB2312-encoding.patch
+ libressl.patch
"
builddir="$srcdir/$pkgname-$pkgver"
@@ -130,4 +130,5 @@ d1641f538cb1ae9f817b57e19800b0af91e3723c752fba38b2644b8acc66d80862c6bef22194f1f4
dec4ed7abfd215eec825bed97b1e40bf3aa8bd959a4ec7153ea1bc51d409d892ebec19ddb0372e3a543e74c7018aca0c1f3cf956fa1d95efb946c8c3417c8749 paxmark.patch
0252e850b79d622fe69329fac3653128b1cc0108961c928a9efa8fa5df1bce13692b6a520697c45c37791a9e6547d5ec7f0f11905e8299902055ab3dbdfd7556 aarch64-linux-musl.patch
702927a86c2e934511415e97093fb6fe04e2e63dd5a4e2e2b1fcc772c7f02e037f1b05e516943222f282515fc562618a83442e2d53cc899933a2b2e8ad8dd53d fix-codegen-specs.patch
-269976fbc990dde075769e651c9fac6e7e0b39681e55cbd067c6d2a790c58a096bdc9981f62ae69b5217623025ba768daa63bc5316bd8ddd18192d88839aedcb disable-specs-using-GB2312-encoding.patch"
+269976fbc990dde075769e651c9fac6e7e0b39681e55cbd067c6d2a790c58a096bdc9981f62ae69b5217623025ba768daa63bc5316bd8ddd18192d88839aedcb disable-specs-using-GB2312-encoding.patch
+b5c9c03ad6b648759262a896da3dfbe530ea2d626a5d18fbade08af14a32f8556cdcaf593504db405ff6e5772d3bf00d9d1a8af82f677436602c5bbcbf69b1c6 libressl.patch"
diff --git a/testing/crystal/libressl.patch b/testing/crystal/libressl.patch
new file mode 100644
index 0000000000..680c50e5e5
--- /dev/null
+++ b/testing/crystal/libressl.patch
@@ -0,0 +1,120 @@
+From a834b9a274b5dcb076b64ca855bcccc322cdd07c Mon Sep 17 00:00:00 2001
+From: lvmbdv <ata.kuyumcu@protonmail.com>
+Date: Fri, 2 Feb 2018 23:31:19 +0300
+Subject: [PATCH] Fixed OpenSSL bindings to recognize LibreSSL
+
+This patch is ported from https://github.com/crystal-lang/crystal/pull/5676.
+
+diff --git a/src/openssl/lib_crypto.cr b/src/openssl/lib_crypto.cr
+index 458ad13..7e42604 100644
+--- a/src/openssl/lib_crypto.cr
++++ b/src/openssl/lib_crypto.cr
+@@ -1,11 +1,23 @@
+ {% begin %}
+ lib LibCrypto
+- OPENSSL_110 = {{ `command -v pkg-config > /dev/null && pkg-config --atleast-version=1.1.0 libcrypto || printf %s false`.stringify != "false" }}
+- OPENSSL_102 = {{ `command -v pkg-config > /dev/null && pkg-config --atleast-version=1.0.2 libcrypto || printf %s false`.stringify != "false" }}
++ # An extra zero is appended to the output of LIBRESSL_VERSION to make it 0 when LibreSSL does not exist on the system.
++ # Any comparisons to it should be affixed with an extra zero as well e.g. `(LIBRESSL_VERSION_NUMBER >= 0x2050500F0)`.
++ LIBRESSL_VERSION = {{ system("echo \"#include <openssl/opensslv.h>\nLIBRESSL_VERSION_NUMBER\" | " +
++ (env("CC") || "cc") + " " + `pkg-config --cflags --silence-errors libssl || true`.chomp.stringify + " -E -").chomp.split('\n').last.split('L').first.id + "0" }}
++ OPENSSL_VERSION = {{ system("echo \"#include <openssl/opensslv.h>\nOPENSSL_VERSION_NUMBER\" | " +
++ (env("CC") || "cc") + " " + `pkg-config --cflags --silence-errors libssl || true`.chomp.stringify + " -E -").chomp.split('\n').last.split('L').first.id }}
+ end
+ {% end %}
+
+-@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'`")]
++{% begin %}
++ lib LibCrypto
++ OPENSSL_110 = {{ (LibCrypto::LIBRESSL_VERSION == 0) && (LibCrypto::OPENSSL_VERSION >= 0x10101000) }}
++ OPENSSL_102 = {{ (LibCrypto::LIBRESSL_VERSION == 0) && (LibCrypto::OPENSSL_VERSION >= 0x10002000) }}
++ LIBRESSL_250 = {{ LibCrypto::LIBRESSL_VERSION >= 0x205000000 }}
++ end
++{% end %}
++
++@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s ' -lcrypto'`")]
+ lib LibCrypto
+ alias Char = LibC::Char
+ alias Int = LibC::Int
+diff --git a/src/openssl/lib_ssl.cr b/src/openssl/lib_ssl.cr
+index e69f82b..b8786b8 100644
+--- a/src/openssl/lib_ssl.cr
++++ b/src/openssl/lib_ssl.cr
+@@ -2,12 +2,13 @@ require "./lib_crypto"
+
+ {% begin %}
+ lib LibSSL
+- OPENSSL_110 = {{ `command -v pkg-config > /dev/null && pkg-config --atleast-version=1.1.0 libssl || printf %s false`.stringify != "false" }}
+- OPENSSL_102 = {{ `command -v pkg-config > /dev/null && pkg-config --atleast-version=1.0.2 libssl || printf %s false`.stringify != "false" }}
++ OPENSSL_110 = {{ LibCrypto::OPENSSL_110 }}
++ OPENSSL_102 = {{ LibCrypto::OPENSSL_102 }}
++ LIBRESSL_250 = {{ LibCrypto::LIBRESSL_250 }}
+ end
+ {% end %}
+
+-@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs libssl || printf %s '-lssl -lcrypto'`")]
++@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'`")]
+ lib LibSSL
+ alias Int = LibC::Int
+ alias Char = LibC::Char
+@@ -198,13 +199,17 @@ lib LibSSL
+ fun sslv23_method = SSLv23_method : SSLMethod
+ {% end %}
+
+- {% if OPENSSL_102 %}
++ {% if OPENSSL_102 || LIBRESSL_250 %}
+ alias ALPNCallback = (SSL, Char**, Char*, Char*, Int, Void*) -> Int
+- alias X509VerifyParam = LibCrypto::X509VerifyParam
+
+- fun ssl_get0_param = SSL_get0_param(handle : SSL) : X509VerifyParam
+ fun ssl_get0_alpn_selected = SSL_get0_alpn_selected(handle : SSL, data : Char**, len : LibC::UInt*) : Void
+ fun ssl_ctx_set_alpn_select_cb = SSL_CTX_set_alpn_select_cb(ctx : SSLContext, cb : ALPNCallback, arg : Void*) : Void
++ {% end %}
++
++ {% if OPENSSL_102 %}
++ alias X509VerifyParam = LibCrypto::X509VerifyParam
++
++ fun ssl_get0_param = SSL_get0_param(handle : SSL) : X509VerifyParam
+ fun ssl_ctx_get0_param = SSL_CTX_get0_param(ctx : SSLContext) : X509VerifyParam
+ fun ssl_ctx_set1_param = SSL_CTX_set1_param(ctx : SSLContext, param : X509VerifyParam) : Int
+ {% end %}
+diff --git a/src/openssl/ssl/context.cr b/src/openssl/ssl/context.cr
+index b21568d..a694abd 100644
+--- a/src/openssl/ssl/context.cr
++++ b/src/openssl/ssl/context.cr
+@@ -304,7 +304,7 @@ abstract class OpenSSL::SSL::Context
+ LibSSL.ssl_ctx_set_verify(@handle, mode, nil)
+ end
+
+- {% if LibSSL::OPENSSL_102 %}
++ {% if LibSSL::OPENSSL_102 || LibSSL::LIBRESSL_250 %}
+
+ @alpn_protocol : Pointer(Void)?
+
+@@ -337,6 +337,10 @@ abstract class OpenSSL::SSL::Context
+ LibSSL.ssl_ctx_set_alpn_select_cb(@handle, alpn_cb, alpn_protocol)
+ end
+
++ {% end %}
++
++ {% if LibSSL::OPENSSL_102 %}
++
+ # Set this context verify param to the default one of the given name.
+ #
+ # Depending on the OpenSSL version, the available defaults are
+diff --git a/src/openssl/ssl/socket.cr b/src/openssl/ssl/socket.cr
+index 10fc100..14c3c16 100644
+--- a/src/openssl/ssl/socket.cr
++++ b/src/openssl/ssl/socket.cr
+@@ -119,7 +119,7 @@ abstract class OpenSSL::SSL::Socket < IO
+ @bio.io.flush
+ end
+
+- {% if LibSSL::OPENSSL_102 %}
++ {% if LibSSL::OPENSSL_102 || LibSSL::LIBRESSL_250 %}
+ # Returns the negotiated ALPN protocol (eg: `"h2"`) of `nil` if no protocol was
+ # negotiated.
+ def alpn_protocol
+--
+2.10.1 (Apple Git-78)
+