git: 30bb70e94e1b - main - lang/crystal: fix broken base SSL usage
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Mar 2022 17:14:24 UTC
The branch main has been updated by dch: URL: https://cgit.FreeBSD.org/ports/commit/?id=30bb70e94e1bed9b4c2953b7be0e56ba7adc902b commit 30bb70e94e1bed9b4c2953b7be0e56ba7adc902b Author: Dave Cottlehuber <dch@FreeBSD.org> AuthorDate: 2022-03-25 17:14:19 +0000 Commit: Dave Cottlehuber <dch@FreeBSD.org> CommitDate: 2022-03-25 17:14:19 +0000 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 --- lang/crystal/Makefile | 21 +++++++++++++++- .../files/extra-patch-src_openssl_lib__crypto.cr | 27 +++++++++++++++++++++ .../files/extra-patch-src_openssl_lib__ssl.cr | 28 ++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) 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