Skip to content

Commit

Permalink
Also install openssl11/openssl3 depending on the Ruby version for…
Browse files Browse the repository at this point in the history
… MacPorts.
  • Loading branch information
postmodern committed Dec 1, 2023
1 parent c295d85 commit 22987ed
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
22 changes: 13 additions & 9 deletions share/ruby-install/ruby/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@ ruby_dir_name="ruby-$ruby_version"
ruby_mirror="${ruby_mirror:-https://cache.ruby-lang.org/pub/ruby}"
ruby_url="${ruby_url:-$ruby_mirror/$ruby_version_family/$ruby_archive}"

if [[ "$package_manager" == "brew" ]]; then
case "$ruby_version_family" in
2.*|3.0) openssl_version="1.1" ;;
*) openssl_version="3" ;;
esac
fi
case "$package_manager" in
brew|port)
case "$ruby_version_family" in
2.*|3.0) openssl_version="1.1" ;;
*) openssl_version="3" ;;
esac
;;
esac

#
# Install [email protected] or [email protected] depending on the Ruby version,
# only for homebrew.
#
function install_optional_deps()
{
if [[ "$package_manager" == "brew" ]]; then
install_packages "openssl@${openssl_version}"
fi
case "$package_manager" in
brew) install_packages "openssl@${openssl_version}" ;;
port) install_packages "openssl${openssl_version/./}" ;;
esac
}

#
Expand All @@ -52,6 +55,7 @@ function configure_ruby()
;;
port)
opt_dir="/opt/local"
openssl_dir="/opt/local"
;;
esac

Expand Down
34 changes: 33 additions & 1 deletion test/ruby-tests/functions_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function test_ruby_version_family()
"$ruby_version_family"
}

function test_openssl_version_when_package_manager_is_not_brew()
function test_openssl_version_when_package_manager_is_not_brew_or_port()
{
local original_package_manager="$package_manager"
package_manager="apt"
Expand Down Expand Up @@ -65,6 +65,38 @@ function test_openssl_version_when_package_manager_is_brew_and_ruby_version_is_g
package_manager="$original_package_manager"
}

function test_openssl_version_when_package_manager_is_port_and_ruby_version_is_less_than_3_1_0()
{
local original_package_manager="$package_manager"
package_manager="port"
ruby_version="3.0.0"

source "$ruby_install_dir/functions.sh"
source "$ruby_install_dir/ruby/functions.sh"

assertEquals "did not correctly set \$openssl_version" \
"1.1" \
"$openssl_version"

package_manager="$original_package_manager"
}

function test_openssl_version_when_package_manager_is_port_and_ruby_version_is_greater_equal_to_3_1_0()
{
local original_package_manager="$package_manager"
package_manager="port"
ruby_version="3.1.0"

source "$ruby_install_dir/functions.sh"
source "$ruby_install_dir/ruby/functions.sh"

assertEquals "did not correctly set \$openssl_version" \
"3" \
"$openssl_version"

package_manager="$original_package_manager"
}

function test_ruby_archive_ext()
{
assertEquals "did not set \$ruby_archive_ext to tar.xz" \
Expand Down

0 comments on commit 22987ed

Please sign in to comment.