Skip to content

Commit 3a666a1

Browse files
authored
Merge pull request #2562 from rbenv/brew-prefix-fix
Fix linking to Homebrew OpenSSL
2 parents fd0460e + 95b8873 commit 3a666a1

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

bin/ruby-build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ pkgconfig_prefix() {
11181118
prefix="$(pkg-config --variable=prefix "$1" 2>/dev/null || true)"
11191119
[ -n "$prefix" ] || return 1
11201120
brew_prefix="$(brew --prefix 2>/dev/null || true)"
1121-
if [[ -n $prefix_prefix && ( $prefix == "$brew_prefix"/Cellar/* || \
1121+
if [[ -n $brew_prefix && ( $prefix == "$brew_prefix"/Cellar/* || \
11221122
$prefix == "$(brew --repository 2>/dev/null || true)"/Cellar/* ) ]]; then
11231123
return 1
11241124
fi

test/build.bats

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,44 @@ make install
593593
OUT
594594
}
595595

596+
@test "link to Homebrew OpenSSL ignoring pkg-config" {
597+
cached_tarball "ruby-3.2.0" configure
598+
599+
local homebrew_prefix="${TMP}/homebrew"
600+
executable "${homebrew_prefix}/opt/openssl@3/bin/openssl" <<EXE
601+
#!/$BASH
602+
[ "\$1" = "version" ] || exit 1
603+
echo 'OpenSSL 3.2.1 20 Dec 2019'
604+
EXE
605+
606+
stub_repeated uname '-s : echo Linux'
607+
stub cc '-xc -E - : echo "OpenSSL 1.0.1a 1 Aug 2023"'
608+
stub_repeated brew \
609+
'list : echo "openssl@3"' \
610+
"--prefix : if [ \$# -ge 2 ]; then echo '$homebrew_prefix'/opt/\$2; else echo '$homebrew_prefix'; fi " \
611+
"--repository : echo '$homebrew_prefix'"
612+
stub pkg-config "--variable=prefix openssl : echo '$homebrew_prefix'/Cellar/openssl@3/3.2.1"
613+
stub_make_install
614+
615+
run_inline_definition <<DEF
616+
install_package "openssl-1.1.1w" "https://www.openssl.org/source/openssl-1.1.1w.tar.gz" openssl --if needs_openssl:1.1.0-3.2.x
617+
install_package "ruby-3.2.0" "http://ruby-lang.org/ruby/2.0/ruby-3.2.0.tar.gz"
618+
DEF
619+
assert_success
620+
621+
unstub uname
622+
unstub cc
623+
unstub brew
624+
unstub pkg-config
625+
unstub make
626+
627+
assert_build_log <<OUT
628+
ruby-3.2.0: [--prefix=$INSTALL_ROOT,--with-openssl-dir=$TMP/homebrew/opt/openssl@3,--with-ext=openssl,psych,+]
629+
make -j 2
630+
make install
631+
OUT
632+
}
633+
596634
@test "forward extra command-line arguments as configure flags" {
597635
cached_tarball "ruby-3.2.0" configure
598636

0 commit comments

Comments
 (0)