Properly handle outdated cURL

`HOMEBREW_CURL_PATH` has an effect only when `HOMEBREW_DEVELOPER` is set. However, the part of `brew.sh` that prints a message about outdated cURL disregards the value of `HOMEBREW_DEVELOPER`, which leads to a misleadnig message telling the user that `HOMEBREW_CURL_PATH` is outdated even though another cURL was used/tested.

This PR fixes it and instructs Homebrew to:

1. Display a warning message when system cURL is outdated and either `HOMEBREW_CURL_PATH` **or `HOMEBREW_DEVELOPER`** are not set. New `HOMEBREW_CURL_WARNING` variable is set to display the above warning only once (useful when `brew` calls itself internally).
2. Display `Installing Homebrew cURL` before auto-installing cURL in `update.sh` (due to `HOMEBREW_FORCE_BREWED_CURL`) and stop/exit if this step fails.
3. Display `Installing Homebrew Git` before auto-installing Git in `update.sh` (due to `HOMEBREW_FORCE_BREWED_GIT`) and stop/exit if this step fails.
This commit is contained in:
Maxim Belkin 2020-11-18 16:38:08 -06:00
parent 66b6828ab5
commit 22bc5a94e7
No known key found for this signature in database
GPG Key ID: AC71560D4C5F2338
2 changed files with 22 additions and 10 deletions

View File

@ -350,17 +350,23 @@ else
curl_name_and_version="${curl_version_output%% (*}" curl_name_and_version="${curl_version_output%% (*}"
if [[ $(numeric "${curl_name_and_version##* }") -lt $(numeric "$HOMEBREW_MINIMUM_CURL_VERSION") ]] if [[ $(numeric "${curl_name_and_version##* }") -lt $(numeric "$HOMEBREW_MINIMUM_CURL_VERSION") ]]
then then
if [[ -z $HOMEBREW_CURL_PATH ]]; then message="Your cURL version is too old.
Minimum required version: ${HOMEBREW_MINIMUM_CURL_VERSION}
Your cURL version: ${curl_name_and_version##* }
Your cURL executable: $(type -p $HOMEBREW_CURL)
To point Homebrew to cURL ${HOMEBREW_MINIMUM_CURL_VERSION} or newer,
enable developer mode by setting HOMEBREW_DEVELOPER to 1,
then set HOMEBREW_CURL_PATH to the location of cURL executable."
if [[ -z $HOMEBREW_CURL_PATH || -z $HOMEBREW_DEVELOPER ]]; then
HOMEBREW_SYSTEM_CURL_TOO_OLD=1 HOMEBREW_SYSTEM_CURL_TOO_OLD=1
HOMEBREW_FORCE_BREWED_CURL=1 HOMEBREW_FORCE_BREWED_CURL=1
if [[ -z $HOMEBREW_CURL_WARNING ]]; then
onoe "$message"
HOMEBREW_CURL_WARNING=1
fi
else else
odie <<EOS odie "$message"
The version of cURL that you provided to Homebrew using HOMEBREW_CURL_PATH is too old.
Minimum required version: ${HOMEBREW_MINIMUM_CURL_VERSION}.
Your cURL version: ${curl_name_and_version##* }.
Please point Homebrew to cURL ${HOMEBREW_MINIMUM_CURL_VERSION} or newer
or unset HOMEBREW_CURL_PATH variable.
EOS
fi fi
fi fi
@ -418,6 +424,7 @@ export HOMEBREW_TEMP
export HOMEBREW_CELLAR export HOMEBREW_CELLAR
export HOMEBREW_SYSTEM export HOMEBREW_SYSTEM
export HOMEBREW_CURL export HOMEBREW_CURL
export HOMEBREW_CURL_WARNING
export HOMEBREW_SYSTEM_CURL_TOO_OLD export HOMEBREW_SYSTEM_CURL_TOO_OLD
export HOMEBREW_GIT export HOMEBREW_GIT
export HOMEBREW_MINIMUM_GIT_VERSION export HOMEBREW_MINIMUM_GIT_VERSION

View File

@ -372,7 +372,8 @@ EOS
if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" && if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
! -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] ! -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]]
then then
brew install curl ohai "Installing Homebrew cURL"
brew install curl || odie "Failed to install cURL"
fi fi
if ! git --version &>/dev/null || if ! git --version &>/dev/null ||
@ -380,7 +381,11 @@ EOS
! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]]
then then
# we cannot install brewed git if homebrew/core is unavailable. # we cannot install brewed git if homebrew/core is unavailable.
[[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && brew install git if [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]]
then
ohai "Installing Homebrew Git"
brew install git || odie "Failed to install Git"
fi
unset GIT_EXECUTABLE unset GIT_EXECUTABLE
if ! git --version &>/dev/null if ! git --version &>/dev/null
then then