LoginSignup
1

posted at

updated at

Organization

ruby-build で openssl がインストールされちゃう話

ruby-build で openssl がインストールされてしまうので調査した

自分でインストールした lib に強制可能か知りたかった

向き先を強制するなら RUBY_CONFIGURE_OPTS が良さそう

  • ruby-build は定義に share ディレクトリを使ってそう
$ ls /usr/local/Cellar/ruby-build/20211109/share/ruby-build | head
1.8.5-p52
1.8.5-p113
1.8.5-p114
1.8.5-p115
1.8.5-p231
1.8.6
1.8.6-p36
1.8.6-p110
1.8.6-p111
1.8.6-p114
$ cat /usr/local/Cellar/ruby-build/20211109/share/ruby-build/3.0.2
install_package "openssl-1.1.1l" "https://www.openssl.org/source/openssl-1.1.1l.tar.gz#0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1" mac_openssl --if has_broken_mac_openssl
install_package "ruby-3.0.2" "https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.gz#5085dee0ad9f06996a8acec7ebea4a8735e6fac22f22e2d98c3f2bc3bef7e6f1" ldflags_dirs enable_shared standard verify_openssl
  • 上記のバージョンによる定義を source して使ってそう
$ grep -n '^source' /usr/local/Cellar/ruby-build/20211109/bin/ruby-build
1466:source "$DEFINITION_PATH"
$ grep -n -A2 '^install_package()' /usr/local/Cellar/ruby-build/20211109/bin/ruby-build
169:install_package() {
170-  install_package_using "tarball" 1 "$@"
171-}
$ grep -n -A27 '^install_package_using()' /usr/local/Cellar/ruby-build/20211109/bin/ruby-build
181:install_package_using() {
182-  local package_type="$1"
183-  local package_type_nargs="$2"
184-  local package_name="$3"
185-  shift 3
186-
187-  local fetch_args=( "$package_name" "${@:1:$package_type_nargs}" )
188-  local make_args=( "$package_name" )
189-  local arg last_arg
190-
191-  for arg in "${@:$(( $package_type_nargs + 1 ))}"; do
192-    if [ "$last_arg" = "--if" ]; then
193-      "$arg" || return 0
194-    elif [ "$arg" != "--if" ]; then
195-      make_args["${#make_args[@]}"]="$arg"
196-    fi
197-    last_arg="$arg"
198-  done
199-
200-  pushd "$BUILD_PATH" >&4
201-  "fetch_${package_type}" "${fetch_args[@]}"
202-  make_package "${make_args[@]}"
203-  popd >&4
204-
205-  { echo "Installed ${package_name} to ${PREFIX_PATH}"
206-    echo
207-  } >&2
208-}

install_package() が動作するかどうかは --if で制御されている

$ grep -n -A5 '^has_broken_mac_openssl()' /usr/local/Cellar/ruby-build/20211109/bin/ruby-build
1075:has_broken_mac_openssl() {
1076-  is_mac || return 1
1077-  local openssl_version="$(/usr/bin/openssl version 2>/dev/null || true)"
1078-  [[ $openssl_version = "OpenSSL 0.9.8"?* || $openssl_version = "LibreSSL"* ]] &&
1079-  [[ "$RUBY_CONFIGURE_OPTS" != *--with-openssl-dir=* ]]
1080-}

RUBY_CONFIGURE_OPTS の有無で決定できそう.

Refs

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
1