mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-01-01 14:44:48 +01:00
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.
This commit is contained in:
parent
4b7ce4d00f
commit
6250069ccb
3 changed files with 28 additions and 64 deletions
|
@ -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 "<SCRIPT>")"
|
||||
|
||||
colorize 36 "$msg"
|
||||
echo
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
"$RUBY_BIN" -e '
|
||||
manager = ARGV[0]
|
||||
packages = {
|
||||
"apt-get" => Hash.new {|h,k| "lib#{k}-dev" }.update(
|
||||
"openssl" => "libssl-dev",
|
||||
"zlib" => "zlib1g-dev"
|
||||
),
|
||||
"yum" => Hash.new {|h,k| "#{k}-devel" }.update(
|
||||
"yaml" => "libyaml-devel"
|
||||
)
|
||||
}
|
||||
ext_name = Hash.new {|h,k| k }.update("yaml" => "psych")
|
||||
|
||||
failed = %w[openssl readline zlib yaml].reject do |lib|
|
||||
begin
|
||||
require lib
|
||||
rescue LoadError => e
|
||||
$stderr.puts "Loading the Ruby #{lib} extension failed (#{e})"
|
||||
$stderr.puts "See the extension log at #{Dir.pwd}/ext/#{ext_name[lib]}/mkmf.log"
|
||||
end
|
||||
end
|
||||
|
||||
if failed.size > 0
|
||||
$stderr.puts "ERROR: Ruby install aborted due to missing extensions"
|
||||
$stderr.print "Try running `%s install -y %s` to fetch missing dependencies.\n\n" % [
|
||||
manager,
|
||||
failed.map { |lib| packages.fetch(manager)[lib] }.join(" ")
|
||||
] unless manager.empty?
|
||||
exit 1
|
||||
end
|
||||
' "$(basename "$(type -p yum apt-get | head -1)")"
|
||||
true
|
||||
}
|
||||
|
||||
# Kept for backward compatibility with 3rd-party definitions.
|
||||
|
|
|
@ -111,7 +111,7 @@ assert_build_log() {
|
|||
yaml-0.1.6: [--prefix=$INSTALL_ROOT]
|
||||
make -j 2
|
||||
make install
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -144,7 +144,7 @@ yaml-0.1.6: [--prefix=$INSTALL_ROOT]
|
|||
make -j 2
|
||||
make install
|
||||
patch -p0 --force -i $TMP/ruby-patch.XXX
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -177,7 +177,7 @@ yaml-0.1.6: [--prefix=$INSTALL_ROOT]
|
|||
make -j 2
|
||||
make install
|
||||
patch -p1 --force -i $TMP/ruby-patch.XXX
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -211,7 +211,7 @@ yaml-0.1.6: [--prefix=$INSTALL_ROOT]
|
|||
make -j 2
|
||||
make install
|
||||
patch -p1 --force -i $TMP/ruby-patch.XXX
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -237,7 +237,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-libyaml-dir=$brew_libdir]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-libyaml-dir=$brew_libdir,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -261,7 +261,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-gmp-dir=$gmp_libdir]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-gmp-dir=$gmp_libdir,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -285,7 +285,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-readline-dir=$readline_libdir]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-readline-dir=$readline_libdir,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -310,7 +310,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-readline-dir=/custom]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+,--with-readline-dir=/custom]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -337,7 +337,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -374,7 +374,7 @@ DEF
|
|||
openssl-1.1.1w: [--prefix=${INSTALL_ROOT}/openssl,--openssldir=${INSTALL_ROOT}/openssl/ssl,zlib-dynamic,no-ssl3,shared]
|
||||
make -j 2
|
||||
make install_sw install_ssldirs
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=$INSTALL_ROOT/openssl]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=$INSTALL_ROOT/openssl,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -398,7 +398,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=/path/to/openssl]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+,--with-openssl-dir=/path/to/openssl]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -448,7 +448,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=$TMP/homebrew/opt/openssl@3.0]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=$TMP/homebrew/opt/openssl@3.0,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -471,7 +471,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,cppflags=-DYJIT_FORCE_ENABLE -DRUBY_PATCHLEVEL_NAME=test,--with-openssl-dir=/path/to/openssl,--with-readline-dir=/custom]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,cppflags=-DYJIT_FORCE_ENABLE -DRUBY_PATCHLEVEL_NAME=test,--with-openssl-dir=/path/to/openssl,--with-ext=openssl,psych,+,--with-readline-dir=/custom]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -494,7 +494,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
@ -518,7 +518,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 4
|
||||
make install
|
||||
OUT
|
||||
|
@ -532,8 +532,7 @@ OUT
|
|||
stub_make_install
|
||||
|
||||
export -n MAKE_OPTS
|
||||
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/test"
|
||||
run_inline_definition <<DEF
|
||||
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/test" run_inline_definition <<DEF
|
||||
install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
|
||||
DEF
|
||||
assert_success
|
||||
|
@ -543,7 +542,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=/test]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+,--with-openssl-dir=/test]
|
||||
make -j 1
|
||||
make install
|
||||
OUT
|
||||
|
@ -566,7 +565,7 @@ DEF
|
|||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install --globalmake RUBYMAKE=true with spaces
|
||||
OUT
|
||||
|
@ -594,8 +593,7 @@ CONF
|
|||
stub apply 'echo apply "$@" >> build.log'
|
||||
stub_make_install
|
||||
|
||||
export RUBY_CONFIGURE="${TMP}/custom-configure"
|
||||
run_inline_definition <<DEF
|
||||
RUBY_CONFIGURE="${TMP}/custom-configure" run_inline_definition <<DEF
|
||||
install_package "ruby-2.0.0" "http://ruby-lang.org/pub/ruby-2.0.0.tar.gz"
|
||||
DEF
|
||||
assert_success
|
||||
|
@ -606,7 +604,7 @@ DEF
|
|||
|
||||
assert_build_log <<OUT
|
||||
apply -p1 -i /my/patch.diff
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT]
|
||||
ruby-2.0.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
|
|
@ -31,7 +31,7 @@ DEF
|
|||
assert_success
|
||||
run cat build.log
|
||||
assert_output <<OUT
|
||||
./configure --prefix=$INSTALL_ROOT
|
||||
./configure --prefix=$INSTALL_ROOT --with-ext=openssl,psych,+
|
||||
CC=clang
|
||||
CFLAGS=no
|
||||
make -j 2
|
||||
|
|
Loading…
Reference in a new issue