From 6250069ccbf36a2d03f272715ea57b40153e8ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 7 Nov 2023 12:13:46 +0100 Subject: [PATCH 1/3] Instruct Ruby to fail the build if openssl or psych are missing Normally, Ruby `make` step will print a warning about any missing extensions, but will not abort the build and instead proceed as normal. Since Ruby installations without openssl or psych are essentially broken, ruby-build used to have a `verify_openssl` build step to test if the newly built Ruby can load these extensions, and print helpful information and abort the build on errors: Loading the Ruby openssl extension failed ERROR: Ruby install aborted due to missing extensions The `verify_opensl` implementation was necessary to provide a good experience for ruby-build users, but was hacky and I would prefer to eliminate it. It appears that passing `--with-ext=openssl,psych` to the Ruby configure step marks those extensions as mandatory and fails the `make` process if they failed to build. This is exactly the behavior we want, so this enables the configure option for all Ruby builds. --- bin/ruby-build | 48 +++++++--------------------------------------- test/build.bats | 42 +++++++++++++++++++--------------------- test/compiler.bats | 2 +- 3 files changed, 28 insertions(+), 64 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index b1547f748b..66de58a0a5 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -673,6 +673,11 @@ build_package_standard_build() { package_option ruby configure --with-openssl-dir="/usr/local" fi fi + if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-ext* && + "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--without-ext* ]]; then + # Fail the `make` step if any of these extensions were not compiled. + package_option ruby configure --with-ext=openssl,psych,+ + fi fi ( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then @@ -1214,48 +1219,9 @@ build_package_openssl() { fi } -# Post-install check that the openssl extension was built. -# TODO: explore replacing this implementation with scanning the `make` log -# for the "Following extensions are not compiled" block. +# Kept for backward compatibility with 3rd-party definitions. build_package_verify_openssl() { - local msg - msg="->$(print_command "$RUBY_BIN" -e "