mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Use HOMEBREW_CURL universally, including formulae
This commit is contained in:
parent
1909d89d00
commit
30b24cf4ad
@ -77,9 +77,9 @@ begin
|
||||
path = PATH.new(ENV["PATH"])
|
||||
homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
|
||||
|
||||
# Add SCM wrappers.
|
||||
path.prepend(HOMEBREW_SHIMS_PATH/"scm")
|
||||
homebrew_path.prepend(HOMEBREW_SHIMS_PATH/"scm")
|
||||
# Add shared wrappers.
|
||||
path.prepend(HOMEBREW_SHIMS_PATH/"shared")
|
||||
homebrew_path.prepend(HOMEBREW_SHIMS_PATH/"shared")
|
||||
|
||||
ENV["PATH"] = path
|
||||
|
||||
|
@ -165,8 +165,12 @@ brew() {
|
||||
"${HOMEBREW_BREW_FILE}" "$@"
|
||||
}
|
||||
|
||||
curl() {
|
||||
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/curl" "$@"
|
||||
}
|
||||
|
||||
git() {
|
||||
"${HOMEBREW_LIBRARY}/Homebrew/shims/scm/git" "$@"
|
||||
"${HOMEBREW_LIBRARY}/Homebrew/shims/shared/git" "$@"
|
||||
}
|
||||
|
||||
# Search given executable in PATH (remove dependency for `which` command)
|
||||
@ -554,7 +558,7 @@ else
|
||||
fi
|
||||
|
||||
HOMEBREW_USER_AGENT="${HOMEBREW_PRODUCT}/${HOMEBREW_USER_AGENT_VERSION} (${HOMEBREW_SYSTEM}; ${HOMEBREW_PROCESSOR} ${HOMEBREW_OS_USER_AGENT_VERSION})"
|
||||
curl_version_output="$("${HOMEBREW_CURL}" --version 2>/dev/null)"
|
||||
curl_version_output="$(curl --version 2>/dev/null)"
|
||||
curl_name_and_version="${curl_version_output%% (*}"
|
||||
HOMEBREW_USER_AGENT_CURL="${HOMEBREW_USER_AGENT} ${curl_name_and_version// //}"
|
||||
|
||||
|
@ -18,12 +18,20 @@
|
||||
# shellcheck disable=SC2154
|
||||
source "${HOMEBREW_LIBRARY}/Homebrew/utils/lock.sh"
|
||||
|
||||
# Replaces the function in Library/Homebrew/brew.sh to cache the Git executable to
|
||||
# provide speedup when using Git repeatedly (as update.sh does).
|
||||
# Replaces the function in Library/Homebrew/brew.sh to cache the Curl/Git executable to
|
||||
# provide speedup when using Curl/Git repeatedly (as update.sh does).
|
||||
curl() {
|
||||
if [[ -z "${CURL_EXECUTABLE}" ]]
|
||||
then
|
||||
CURL_EXECUTABLE="$("${HOMEBREW_LIBRARY}/Homebrew/shims/shared/curl" --homebrew=print-path)"
|
||||
fi
|
||||
"${CURL_EXECUTABLE}" "$@"
|
||||
}
|
||||
|
||||
git() {
|
||||
if [[ -z "${GIT_EXECUTABLE}" ]]
|
||||
then
|
||||
GIT_EXECUTABLE="$("${HOMEBREW_LIBRARY}/Homebrew/shims/scm/git" --homebrew=print-path)"
|
||||
GIT_EXECUTABLE="$("${HOMEBREW_LIBRARY}/Homebrew/shims/shared/git" --homebrew=print-path)"
|
||||
fi
|
||||
"${GIT_EXECUTABLE}" "$@"
|
||||
}
|
||||
@ -564,7 +572,7 @@ EOS
|
||||
# HOMEBREW_CURL is set by brew.sh (and isn't mispelt here)
|
||||
# shellcheck disable=SC2153
|
||||
UPSTREAM_SHA_HTTP_CODE="$(
|
||||
"${HOMEBREW_CURL}" \
|
||||
curl \
|
||||
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
|
||||
--silent --max-time 3 \
|
||||
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \
|
||||
|
@ -28,7 +28,8 @@ module Stdenv
|
||||
|
||||
self["HOMEBREW_ENV"] = "std"
|
||||
|
||||
PATH.new(ENV["HOMEBREW_PATH"]).each { |p| prepend_path "PATH", p }
|
||||
PATH.new(ENV["HOMEBREW_PATH"]).reverse_each { |p| prepend_path "PATH", p }
|
||||
prepend_path "PATH", HOMEBREW_SHIMS_PATH/"shared"
|
||||
|
||||
# Set the default pkg-config search path, overriding the built-in paths
|
||||
# Anything in PKG_CONFIG_PATH is searched before paths in this variable
|
||||
|
1
Library/Homebrew/shims/linux/super/curl
Symbolic link
1
Library/Homebrew/shims/linux/super/curl
Symbolic link
@ -0,0 +1 @@
|
||||
../../shared/curl
|
@ -1 +1 @@
|
||||
../../scm/git
|
||||
../../shared/git
|
@ -1 +1 @@
|
||||
../../scm/svn
|
||||
../../shared/svn
|
1
Library/Homebrew/shims/mac/super/curl
Symbolic link
1
Library/Homebrew/shims/mac/super/curl
Symbolic link
@ -0,0 +1 @@
|
||||
../../shared/curl
|
@ -1 +1 @@
|
||||
../../scm/git
|
||||
../../shared/git
|
@ -1 +1 @@
|
||||
../../scm/svn
|
||||
../../shared/svn
|
20
Library/Homebrew/shims/shared/curl
Executable file
20
Library/Homebrew/shims/shared/curl
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Make our $HOMEBREW_CURL selection universal - including in formulae usage.
|
||||
|
||||
# HOMEBREW_LIBRARY is set by bin/brew
|
||||
# HOMEBREW_CURL is set by brew.sh
|
||||
# shellcheck disable=SC2154
|
||||
if [[ -z "${HOMEBREW_LIBRARY}" ]]
|
||||
then
|
||||
echo "${0##*/}: This shim is internal and must be run via brew." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh"
|
||||
|
||||
try_exec_non_system "${HOMEBREW_CURL:-curl}" "$@"
|
||||
safe_exec "/usr/bin/curl" "$@"
|
||||
|
||||
echo "Could not execute curl. Try HOMEBREW_FORCE_BREWED_CURL=1" >&2
|
||||
exit 1
|
1
Library/Homebrew/shims/super/curl
Symbolic link
1
Library/Homebrew/shims/super/curl
Symbolic link
@ -0,0 +1 @@
|
||||
../shared/curl
|
@ -1 +1 @@
|
||||
../scm/git
|
||||
../shared/git
|
@ -1 +1 @@
|
||||
../scm/svn
|
||||
../shared/svn
|
@ -146,7 +146,7 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
config.before(:each, :needs_svn) do
|
||||
svn_shim = HOMEBREW_SHIMS_PATH/"scm/svn"
|
||||
svn_shim = HOMEBREW_SHIMS_PATH/"shared/svn"
|
||||
skip "Subversion is not installed." unless quiet_system svn_shim, "--version"
|
||||
|
||||
svn_shim_path = Pathname(Utils.popen_read(svn_shim, "--homebrew=print-path").chomp.presence)
|
||||
|
@ -12,7 +12,7 @@ describe Utils::Git do
|
||||
end
|
||||
|
||||
before do
|
||||
git = HOMEBREW_SHIMS_PATH/"scm/git"
|
||||
git = HOMEBREW_SHIMS_PATH/"shared/git"
|
||||
|
||||
HOMEBREW_CACHE.cd do
|
||||
system git, "init"
|
||||
@ -201,7 +201,7 @@ describe Utils::Git do
|
||||
|
||||
context "when git is available" do
|
||||
it "returns true when git remote exists", :needs_network do
|
||||
git = HOMEBREW_SHIMS_PATH/"scm/git"
|
||||
git = HOMEBREW_SHIMS_PATH/"shared/git"
|
||||
url = "https://github.com/Homebrew/homebrew.github.io"
|
||||
repo = HOMEBREW_CACHE/"hey"
|
||||
repo.mkpath
|
||||
|
@ -10,7 +10,7 @@ describe Utils::Svn do
|
||||
|
||||
describe "::available?" do
|
||||
it "returns svn version if svn available" do
|
||||
if quiet_system "#{HOMEBREW_SHIMS_PATH}/scm/svn", "--version"
|
||||
if quiet_system "#{HOMEBREW_SHIMS_PATH}/shared/svn", "--version"
|
||||
expect(described_class).to be_available
|
||||
else
|
||||
expect(described_class).not_to be_available
|
||||
@ -20,7 +20,7 @@ describe Utils::Svn do
|
||||
|
||||
describe "::version" do
|
||||
it "returns svn version if svn available" do
|
||||
if quiet_system "#{HOMEBREW_SHIMS_PATH}/scm/svn", "--version"
|
||||
if quiet_system "#{HOMEBREW_SHIMS_PATH}/shared/svn", "--version"
|
||||
expect(described_class.version).to match(/^\d+\.\d+\.\d+$/)
|
||||
else
|
||||
expect(described_class.version).to be_nil
|
||||
|
@ -19,14 +19,7 @@ module Utils
|
||||
def curl_executable(use_homebrew_curl: false)
|
||||
return Formula["curl"].opt_bin/"curl" if use_homebrew_curl
|
||||
|
||||
@curl ||= [
|
||||
ENV["HOMEBREW_CURL"],
|
||||
which("curl"),
|
||||
"/usr/bin/curl",
|
||||
].compact.map { |c| Pathname(c) }.find(&:executable?)
|
||||
raise "No executable `curl` was found" unless @curl
|
||||
|
||||
@curl
|
||||
@curl_executable ||= HOMEBREW_SHIMS_PATH/"shared/curl"
|
||||
end
|
||||
|
||||
sig {
|
||||
|
@ -30,7 +30,7 @@ module Utils
|
||||
def git
|
||||
return @git if defined?(@git)
|
||||
|
||||
@git = HOMEBREW_SHIMS_PATH/"scm/git"
|
||||
@git = HOMEBREW_SHIMS_PATH/"shared/git"
|
||||
end
|
||||
|
||||
def remote_exists?(url)
|
||||
|
@ -22,7 +22,7 @@ module Utils
|
||||
def version
|
||||
return @version if defined?(@version)
|
||||
|
||||
stdout, _, status = system_command(HOMEBREW_SHIMS_PATH/"scm/svn", args: ["--version"], print_stderr: false)
|
||||
stdout, _, status = system_command(HOMEBREW_SHIMS_PATH/"shared/svn", args: ["--version"], print_stderr: false)
|
||||
@version = status.success? ? stdout.chomp[/svn, version (\d+(?:\.\d+)*)/, 1] : nil
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user