From c214952e2be417bce392a2cc93614088d8fb88f5 Mon Sep 17 00:00:00 2001 From: Caleb Xu Date: Mon, 24 Jun 2024 12:10:46 -0400 Subject: [PATCH] cmd/vendor-install: extract portable-ruby download info --- Library/Homebrew/cmd/vendor-install.sh | 44 ++++++++++--------- .../vendor/portable-ruby-arm64-darwin | 2 + .../vendor/portable-ruby-x86_64-darwin | 2 + .../vendor/portable-ruby-x86_64-linux | 2 + 4 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 Library/Homebrew/vendor/portable-ruby-arm64-darwin create mode 100644 Library/Homebrew/vendor/portable-ruby-x86_64-darwin create mode 100644 Library/Homebrew/vendor/portable-ruby-x86_64-linux diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh index 14c60c6deb..21feac9437 100644 --- a/Library/Homebrew/cmd/vendor-install.sh +++ b/Library/Homebrew/cmd/vendor-install.sh @@ -14,36 +14,37 @@ VENDOR_DIR="${HOMEBREW_LIBRARY}/Homebrew/vendor" # Built from https://github.com/Homebrew/homebrew-portable-ruby. set_ruby_variables() { - if [[ -n "${HOMEBREW_MACOS}" ]] + # Handle the case where /usr/local/bin/brew is run under arm64. + # It's a x86_64 installation there (we refuse to install arm64 binaries) so + # use a x86_64 Portable Ruby. + if [[ -n "${HOMEBREW_MACOS}" && "${VENDOR_PHYSICAL_PROCESSOR}" == "arm64" && "${HOMEBREW_PREFIX}" == "/usr/local" ]] then - if [[ "${VENDOR_PHYSICAL_PROCESSOR}" == "x86_64" ]] || - # Handle the case where /usr/local/bin/brew is run under arm64. - # It's a x86_64 installation there (we refuse to install arm64 binaries) so - # use a x86_64 Portable Ruby. - [[ "${VENDOR_PHYSICAL_PROCESSOR}" == "arm64" && "${HOMEBREW_PREFIX}" == "/usr/local" ]] + ruby_PROCESSOR="x86_64" + ruby_OS="darwin" + else + ruby_PROCESSOR="${VENDOR_PHYSICAL_PROCESSOR}" + if [[ -n "${HOMEBREW_MACOS}" ]] then - ruby_FILENAME="portable-ruby-${HOMEBREW_PORTABLE_RUBY_VERSION}.el_capitan.bottle.tar.gz" - ruby_SHA="a5ef040e054444a0eb2cbcc1032fed14702dfbe2e55b25e609f3ce643f23c4ee" - elif [[ "${VENDOR_PHYSICAL_PROCESSOR}" == "arm64" ]] + ruby_OS="darwin" + elif [[ -n "${HOMEBREW_LINUX}" ]] then - ruby_FILENAME="portable-ruby-${HOMEBREW_PORTABLE_RUBY_VERSION}.arm64_big_sur.bottle.tar.gz" - ruby_SHA="49847c7a13f7094b211f6d0025900dd23716be07dac894a3d6941d7696296306" + ruby_OS="linux" fi - elif [[ -n "${HOMEBREW_LINUX}" ]] + fi + + ruby_PLATFORMINFO="${HOMEBREW_LIBRARY}/Homebrew/vendor/portable-ruby-${ruby_PROCESSOR}-${ruby_OS}" + if [[ -f "${ruby_PLATFORMINFO}" ]] then - case "${VENDOR_PROCESSOR}" in - x86_64) - ruby_FILENAME="portable-ruby-${HOMEBREW_PORTABLE_RUBY_VERSION}.x86_64_linux.bottle.tar.gz" - ruby_SHA="40a1dbc25bb1a8bbdf0bba53d3f16c45416be12d4c6d48b4530f90b2a77d64ce" - ;; - *) ;; - esac + # ruby_TAG and ruby_SHA will be set via the sourced file if it exists + # shellcheck disable=SC1090 + source "${ruby_PLATFORMINFO}" fi # Dynamic variables can't be detected by shellcheck # shellcheck disable=SC2034 - if [[ -n "${ruby_SHA}" && -n "${ruby_FILENAME}" ]] + if [[ -n "${ruby_TAG}" && -n "${ruby_SHA}" ]] then + ruby_FILENAME="portable-ruby-${HOMEBREW_PORTABLE_RUBY_VERSION}.${ruby_TAG}.bottle.tar.gz" ruby_URLs=() if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN}" ]] then @@ -284,6 +285,9 @@ homebrew-vendor-install() { local url_var local sha_var + unset VENDOR_PHYSICAL_PROCESSOR + unset VENDOR_PROCESSOR + for option in "$@" do case "${option}" in diff --git a/Library/Homebrew/vendor/portable-ruby-arm64-darwin b/Library/Homebrew/vendor/portable-ruby-arm64-darwin new file mode 100644 index 0000000000..931624f90a --- /dev/null +++ b/Library/Homebrew/vendor/portable-ruby-arm64-darwin @@ -0,0 +1,2 @@ +ruby_TAG=arm64_big_sur +ruby_SHA=49847c7a13f7094b211f6d0025900dd23716be07dac894a3d6941d7696296306 diff --git a/Library/Homebrew/vendor/portable-ruby-x86_64-darwin b/Library/Homebrew/vendor/portable-ruby-x86_64-darwin new file mode 100644 index 0000000000..5121655b98 --- /dev/null +++ b/Library/Homebrew/vendor/portable-ruby-x86_64-darwin @@ -0,0 +1,2 @@ +ruby_TAG=el_capitan +ruby_SHA=a5ef040e054444a0eb2cbcc1032fed14702dfbe2e55b25e609f3ce643f23c4ee diff --git a/Library/Homebrew/vendor/portable-ruby-x86_64-linux b/Library/Homebrew/vendor/portable-ruby-x86_64-linux new file mode 100644 index 0000000000..71c4c4b928 --- /dev/null +++ b/Library/Homebrew/vendor/portable-ruby-x86_64-linux @@ -0,0 +1,2 @@ +ruby_TAG=x86_64_linux +ruby_SHA=40a1dbc25bb1a8bbdf0bba53d3f16c45416be12d4c6d48b4530f90b2a77d64ce