From 22bc5a94e71ba76d0ffb5ce3d959912e42d8dce5 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 18 Nov 2020 16:38:08 -0600 Subject: [PATCH] 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. --- Library/Homebrew/brew.sh | 23 +++++++++++++++-------- Library/Homebrew/cmd/update.sh | 9 +++++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index d0b15e080f..16df41f478 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -350,17 +350,23 @@ else curl_name_and_version="${curl_version_output%% (*}" if [[ $(numeric "${curl_name_and_version##* }") -lt $(numeric "$HOMEBREW_MINIMUM_CURL_VERSION") ]] 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_FORCE_BREWED_CURL=1 + if [[ -z $HOMEBREW_CURL_WARNING ]]; then + onoe "$message" + HOMEBREW_CURL_WARNING=1 + fi else - odie </dev/null || @@ -380,7 +381,11 @@ EOS ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] then # 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 if ! git --version &>/dev/null then