Skip to content

Commit 5162902

Browse files
committed
Use HOMEBREW_CURL universally, including formulae
1 parent 1909d89 commit 5162902

File tree

19 files changed

+57
-31
lines changed

19 files changed

+57
-31
lines changed

Library/Homebrew/brew.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class MissingEnvironmentVariables < RuntimeError; end
7777
path = PATH.new(ENV["PATH"])
7878
homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
7979

80-
# Add SCM wrappers.
81-
path.prepend(HOMEBREW_SHIMS_PATH/"scm")
82-
homebrew_path.prepend(HOMEBREW_SHIMS_PATH/"scm")
80+
# Add shared wrappers.
81+
path.prepend(HOMEBREW_SHIMS_PATH/"shared")
82+
homebrew_path.prepend(HOMEBREW_SHIMS_PATH/"shared")
8383

8484
ENV["PATH"] = path
8585

Library/Homebrew/brew.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,12 @@ brew() {
165165
"${HOMEBREW_BREW_FILE}" "$@"
166166
}
167167

168+
curl() {
169+
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/curl" "$@"
170+
}
171+
168172
git() {
169-
"${HOMEBREW_LIBRARY}/Homebrew/shims/scm/git" "$@"
173+
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/git" "$@"
170174
}
171175

172176
# Search given executable in PATH (remove dependency for `which` command)
@@ -554,7 +558,7 @@ else
554558
fi
555559

556560
HOMEBREW_USER_AGENT="${HOMEBREW_PRODUCT}/${HOMEBREW_USER_AGENT_VERSION} (${HOMEBREW_SYSTEM}; ${HOMEBREW_PROCESSOR} ${HOMEBREW_OS_USER_AGENT_VERSION})"
557-
curl_version_output="$("${HOMEBREW_CURL}" --version 2>/dev/null)"
561+
curl_version_output="$(curl --version 2>/dev/null)"
558562
curl_name_and_version="${curl_version_output%% (*}"
559563
HOMEBREW_USER_AGENT_CURL="${HOMEBREW_USER_AGENT} ${curl_name_and_version// //}"
560564

Library/Homebrew/cmd/update.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@
1818
# shellcheck disable=SC2154
1919
source "${HOMEBREW_LIBRARY}/Homebrew/utils/lock.sh"
2020

21-
# Replaces the function in Library/Homebrew/brew.sh to cache the Git executable to
22-
# provide speedup when using Git repeatedly (as update.sh does).
21+
# Replaces the function in Library/Homebrew/brew.sh to cache the Curl/Git executable to
22+
# provide speedup when using Curl/Git repeatedly (as update.sh does).
23+
curl() {
24+
if [[ -z "${CURL_EXECUTABLE}" ]]
25+
then
26+
CURL_EXECUTABLE="$("${HOMEBREW_LIBRARY}/Homebrew/shims/shared/curl" --homebrew=print-path)"
27+
fi
28+
"${CURL_EXECUTABLE}" "$@"
29+
}
30+
2331
git() {
2432
if [[ -z "${GIT_EXECUTABLE}" ]]
2533
then
26-
GIT_EXECUTABLE="$("${HOMEBREW_LIBRARY}/Homebrew/shims/scm/git" --homebrew=print-path)"
34+
GIT_EXECUTABLE="$("${HOMEBREW_LIBRARY}/Homebrew/shims/shared/git" --homebrew=print-path)"
2735
fi
2836
"${GIT_EXECUTABLE}" "$@"
2937
}
@@ -564,7 +572,7 @@ EOS
564572
# HOMEBREW_CURL is set by brew.sh (and isn't mispelt here)
565573
# shellcheck disable=SC2153
566574
UPSTREAM_SHA_HTTP_CODE="$(
567-
"${HOMEBREW_CURL}" \
575+
curl \
568576
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
569577
--silent --max-time 3 \
570578
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \

Library/Homebrew/extend/ENV/std.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a
2828

2929
self["HOMEBREW_ENV"] = "std"
3030

31-
PATH.new(ENV["HOMEBREW_PATH"]).each { |p| prepend_path "PATH", p }
31+
PATH.new(ENV["HOMEBREW_PATH"]).reverse_each { |p| prepend_path "PATH", p }
32+
prepend_path "PATH", HOMEBREW_SHIMS_PATH/"shared"
3233

3334
# Set the default pkg-config search path, overriding the built-in paths
3435
# Anything in PKG_CONFIG_PATH is searched before paths in this variable
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../scm/git
1+
../../shared/git
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../scm/svn
1+
../../shared/svn
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../scm/git
1+
../../shared/git
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../scm/svn
1+
../../shared/svn

Library/Homebrew/shims/shared/curl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Make our $HOMEBREW_CURL selection universal - including in formulae usage.
4+
5+
# HOMEBREW_LIBRARY is set by bin/brew
6+
# HOMEBREW_CURL is set by brew.sh
7+
# shellcheck disable=SC2154
8+
if [[ -z "${HOMEBREW_LIBRARY}" ]]
9+
then
10+
echo "${0##*/}: This shim is internal and must be run via brew." >&2
11+
exit 1
12+
fi
13+
14+
source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh"
15+
16+
try_exec_non_system "${HOMEBREW_CURL:-curl}" "$@"
17+
safe_exec "/usr/bin/curl" "$@"
18+
19+
echo "Could not execute curl. Try HOMEBREW_FORCE_BREWED_CURL=1" >&2
20+
exit 1
File renamed without changes.

0 commit comments

Comments
 (0)