Commit b945b7ae authored by Benoit Daloze's avatar Benoit Daloze
Browse files

Install openssl whenever the system version does not match

* Make supported openssl versions explicit per definition.
parent fb0e82c6
Loading
Loading
Loading
Loading
+39 −8
Original line number Diff line number Diff line
@@ -1086,17 +1086,48 @@ use_homebrew_readline() {
has_broken_mac_openssl() {
  is_mac || return 1
  local openssl_version="$(/usr/bin/openssl version 2>/dev/null || true)"
  [[ $openssl_version = "OpenSSL 0.9.8"?* || $openssl_version = "LibreSSL"* ]] &&
  [[ "$RUBY_CONFIGURE_OPTS" != *--with-openssl-dir=* ]]
  [[ $openssl_version = "OpenSSL 0.9.8"?* || $openssl_version = "LibreSSL"* ]]
}

needs_openssl() {
  [[ "$RUBY_CONFIGURE_OPTS" != *--with-openssl-dir=* ]] &&
  {
system_openssl_version() {
  local version_text=$(
    openssl version 2>/dev/null ||
    printf '#include <openssl/opensslv.h>\nOPENSSL_VERSION_TEXT\n' | cc -xc -E - 2>/dev/null
  } | grep -q "OpenSSL 3" ||
  has_broken_mac_openssl
    printf '#include <openssl/opensslv.h>\nOPENSSL_VERSION_TEXT\n' | cc -xc -E - 2>/dev/null | tail -n 1)
  if [[ $version_text == *"OpenSSL "* ]]; then
    local version=${version_text#*OpenSSL }
    version=${version%% *}
    echo $version | sed 's/[^0-9]//g' | sed 's/^0*//'
  else
    echo "No system openssl version was found" >&2
    echo 000
  fi
}

# openssl gem 1.1.1
needs_openssl_096_102() {
  [[ "$RUBY_CONFIGURE_OPTS" == *--with-openssl-dir=* ]] && return 1
  has_broken_mac_openssl && return 0

  local version=$(system_openssl_version)
  (( $version < 96 || $version >= 110 ))
}

# openssl gem 2.2.1
needs_openssl_101_111() {
  [[ "$RUBY_CONFIGURE_OPTS" == *--with-openssl-dir=* ]] && return 1
  has_broken_mac_openssl && return 0

  local version=$(system_openssl_version)
  (( $version < 101 || $version >= 300 ))
}

# openssl gem 3.0.0
needs_openssl_102_300() {
  [[ "$RUBY_CONFIGURE_OPTS" == *--with-openssl-dir=* ]] && return 1
  has_broken_mac_openssl && return 0

  local version=$(system_openssl_version)
  (( $version < 102 || $version >= 400 ))
}

use_homebrew_openssl() {
+1 −1
Original line number Diff line number Diff line
@@ -18,6 +18,6 @@ url="https://cache.ruby-lang.org/pub/ruby/${major_minor_version}/${basename}"
sha256=$(sha256sum "$release_directory/$basename" | cut -d ' ' -f 1)

cat > "$file" <<EOS
install_package "openssl-1.1.1q" "https://www.openssl.org/source/openssl-1.1.1q.tar.gz#d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca" openssl --if has_broken_mac_openssl
install_package "openssl-1.1.1q" "https://www.openssl.org/source/openssl-1.1.1q.tar.gz#d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca" openssl --if needs_openssl_102_300
install_package "ruby-${version}" "${url}#${sha256}" ldflags_dirs enable_shared standard verify_openssl
EOS
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ URI.open(file).each do |package|

  definition = <<-TEMPLATE
require_llvm 3.7
install_package "openssl-1.0.2o" "https://www.openssl.org/source/openssl-1.0.2o.tar.gz#ec3f5c9714ba0fd45cb4e087301eb1336c317e0d20b575a125050470e8089e4d" openssl --if needs_openssl
install_package "openssl-1.0.2u" "https://www.openssl.org/source/openssl-1.0.2u.tar.gz#ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16" openssl --if needs_openssl_096_102
install_package "rubinius-#{version}" "#{package_url}##{sha256}" rbx
  TEMPLATE

+1 −1
Original line number Diff line number Diff line
install_package "openssl-1.0.2u" "https://www.openssl.org/source/openssl-1.0.2u.tar.gz#ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16" openssl --if needs_openssl
install_package "openssl-1.0.2u" "https://www.openssl.org/source/openssl-1.0.2u.tar.gz#ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16" openssl --if needs_openssl_096_102
install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749" --if needs_yaml
install_git "ruby-1.9.3-dev" "https://github.com/ruby/ruby.git" "ruby_1_9_3" warn_eol autoconf standard
+1 −1
Original line number Diff line number Diff line
require_gcc
install_package "openssl-1.0.2u" "https://www.openssl.org/source/openssl-1.0.2u.tar.gz#ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16" openssl --if needs_openssl
install_package "openssl-1.0.2u" "https://www.openssl.org/source/openssl-1.0.2u.tar.gz#ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16" openssl --if needs_openssl_096_102
install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749" --if needs_yaml
install_package "ruby-1.9.3-p0" "https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.bz2#ca8ba4e564fc5f98b210a5784e43dfffef9471222849e46f8e848b37e9f38acf" warn_eol standard
install_package "rubygems-1.8.23" "https://rubygems.org/rubygems/rubygems-1.8.23.tgz#e4a1c6bbaac411eaab94deae78228b7584033a1f10a022f52bffa9613aa29061" ruby
Loading