aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Cottlehuber <dch@FreeBSD.org>2022-03-25 17:14:19 +0000
committerDave Cottlehuber <dch@FreeBSD.org>2022-03-25 17:14:19 +0000
commit30bb70e94e1bed9b4c2953b7be0e56ba7adc902b (patch)
treef02ca98b1d47a64a0e93e57b231049e0454b6934
parentb78fab0d18ceaa159154bed70c402c6b083253a7 (diff)
downloadports-30bb70e94e1bed9b4c2953b7be0e56ba7adc902b.tar.gz
ports-30bb70e94e1bed9b4c2953b7be0e56ba7adc902b.zip
lang/crystal: fix broken base SSL usage
crystal needs pkgconfig to determine precisely which SSL variant is present, and patch itself accordingly, but this is not present in FreeBSD base. Patch directly, what would have been provided by pkgconfig, for currently supported FreeBSD versions. PR: 257658 Approved by: greg@unrelenting.technology (maintainer) Differential Revision: https://reviews.freebsd.org/D31435
-rw-r--r--lang/crystal/Makefile21
-rw-r--r--lang/crystal/files/extra-patch-src_openssl_lib__crypto.cr27
-rw-r--r--lang/crystal/files/extra-patch-src_openssl_lib__ssl.cr28
3 files changed, 75 insertions, 1 deletions
diff --git a/lang/crystal/Makefile b/lang/crystal/Makefile
index 46c942add542..be4aa0c53286 100644
--- a/lang/crystal/Makefile
+++ b/lang/crystal/Makefile
@@ -1,5 +1,6 @@
PORTNAME= crystal
DISTVERSION= 1.2.2
+PORTREVISION= 1
CATEGORIES= lang
MASTER_SITES= https://dl.unrelenting.technology/crystal/:bootstrap
DISTFILES= ${BOOTSTRAP_PATH}:bootstrap
@@ -22,7 +23,7 @@ BUILD_DEPENDS= ${LOCALBASE}/bin/llvm-config${LLVM_VERSION}:devel/llvm${BOOTSTRAP
git:devel/git
RUN_DEPENDS= pkg-config:devel/pkgconf
-USES= compiler gmake pkgconfig
+USES= compiler gmake pkgconfig ssl
USE_GITHUB= yes
GH_ACCOUNT= crystal-lang
@@ -52,6 +53,15 @@ OPTIONS_SUB= yes
IGNORE= not supported on anything but FreeBSD
.endif
+# crystal needs pkgconfig to determine SSL variants but these are not
+# present in FreeBSD base. We splice in the correct info based on
+# FreeBSD version and hope it doesn't change during minor releases.
+# See post-patch for the substitutions of these patches.
+.if ${SSL_DEFAULT} == "base"
+EXTRA_PATCHES= ${PATCHDIR}/extra-patch-src_openssl_lib__crypto.cr \
+ ${PATCHDIR}/extra-patch-src_openssl_lib__ssl.cr
+.endif
+
post-extract:
${MKDIR} ${WRKSRC}/.build
${CP} ${DISTDIR}/${DIST_SUBDIR}/${BOOTSTRAP_PATH} ${WRKSRC}/.build/crystal
@@ -59,6 +69,15 @@ post-extract:
${LN} -s x86_64-freebsd ${WRKSRC}/src/lib_c/aarch64-portbld-freebsd
${LN} -s x86_64-freebsd ${WRKSRC}/src/lib_c/aarch64-freebsd
+post-patch:
+.if ${SSL_DEFAULT} == "base" && ${OSREL:R} < 15
+ @${REINPLACE_CMD} \
+ -e 's|CRYSTAL_SSL_VERSION|1.1.1|g' \
+ -e 's|CRYSTAL_SSL_LDFLAGS|${OPENSSLLIB}|g' \
+ ${WRKSRC}/src/openssl/lib_ssl.cr \
+ ${WRKSRC}/src/openssl/lib_crypto.cr
+.endif
+
do-build-DOCS-on:
cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} docs \
CRYSTAL_CACHE_DIR="${WRKDIR}/cache"
diff --git a/lang/crystal/files/extra-patch-src_openssl_lib__crypto.cr b/lang/crystal/files/extra-patch-src_openssl_lib__crypto.cr
new file mode 100644
index 000000000000..d935d28e2021
--- /dev/null
+++ b/lang/crystal/files/extra-patch-src_openssl_lib__crypto.cr
@@ -0,0 +1,27 @@
+--- src/openssl/lib_crypto.cr.orig 2021-08-08 15:06:11 UTC
++++ src/openssl/lib_crypto.cr
+@@ -1,21 +1,11 @@
+ {% begin %}
+ lib LibCrypto
+- {% from_libressl = (`hash pkg-config 2> /dev/null || printf %s false` != "false") &&
+- (`test -f $(pkg-config --silence-errors --variable=includedir libcrypto)/openssl/opensslv.h || printf %s false` != "false") &&
+- (`printf "#include <openssl/opensslv.h>\nLIBRESSL_VERSION_NUMBER" | ${CC:-cc} $(pkg-config --cflags --silence-errors libcrypto || true) -E -`.chomp.split('\n').last != "LIBRESSL_VERSION_NUMBER") %}
+- {% ssl_version = `hash pkg-config 2> /dev/null && pkg-config --silence-errors --modversion libcrypto || printf %s 0.0.0`.split.last.gsub(/[^0-9.]/, "") %}
+-
+- {% if from_libressl %}
+- LIBRESSL_VERSION = {{ ssl_version }}
+- OPENSSL_VERSION = "0.0.0"
+- {% else %}
+- LIBRESSL_VERSION = "0.0.0"
+- OPENSSL_VERSION = {{ ssl_version }}
+- {% end %}
++ LIBRESSL_VERSION = "0.0.0"
++ OPENSSL_VERSION = "CRYSTAL_SSL_VERSION"
+ end
+ {% end %}
+
+-@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'`")]
++@[Link(ldflags: "-LCRYSTAL_SSL_LDFLAGS -lcrypto")]
+ lib LibCrypto
+ alias Char = LibC::Char
+ alias Int = LibC::Int
diff --git a/lang/crystal/files/extra-patch-src_openssl_lib__ssl.cr b/lang/crystal/files/extra-patch-src_openssl_lib__ssl.cr
new file mode 100644
index 000000000000..54181f2f4b95
--- /dev/null
+++ b/lang/crystal/files/extra-patch-src_openssl_lib__ssl.cr
@@ -0,0 +1,28 @@
+--- src/openssl/lib_ssl.cr.orig 2021-08-08 15:06:09 UTC
++++ src/openssl/lib_ssl.cr
+@@ -6,22 +6,12 @@ require "./lib_crypto"
+
+ {% begin %}
+ lib LibSSL
+- {% from_libressl = (`hash pkg-config 2> /dev/null || printf %s false` != "false") &&
+- (`test -f $(pkg-config --silence-errors --variable=includedir libssl)/openssl/opensslv.h || printf %s false` != "false") &&
+- (`printf "#include <openssl/opensslv.h>\nLIBRESSL_VERSION_NUMBER" | ${CC:-cc} $(pkg-config --cflags --silence-errors libssl || true) -E -`.chomp.split('\n').last != "LIBRESSL_VERSION_NUMBER") %}
+- {% ssl_version = `hash pkg-config 2> /dev/null && pkg-config --silence-errors --modversion libssl || printf %s 0.0.0`.split.last.gsub(/[^0-9.]/, "") %}
+-
+- {% if from_libressl %}
+- LIBRESSL_VERSION = {{ ssl_version }}
+- OPENSSL_VERSION = "0.0.0"
+- {% else %}
+- LIBRESSL_VERSION = "0.0.0"
+- OPENSSL_VERSION = {{ ssl_version }}
+- {% end %}
++ LIBRESSL_VERSION = "0.0.0"
++ OPENSSL_VERSION = "CRYSTAL_SSL_VERSION"
+ end
+ {% end %}
+
+-@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'`")]
++@[Link(ldflags: "-LCRYSTAL_SSL_LDFLAGS -lssl")]
+ lib LibSSL
+ alias Int = LibC::Int
+ alias Char = LibC::Char