Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Library/Homebrew/brew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class MissingEnvironmentVariables < RuntimeError; end
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

Expand Down
8 changes: 6 additions & 2 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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// //}"

Expand Down
16 changes: 12 additions & 4 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" "$@"
}
Expand Down Expand Up @@ -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}" \
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/extend/ENV/std.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a

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
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/shims/linux/super/curl
2 changes: 1 addition & 1 deletion Library/Homebrew/shims/linux/super/git
2 changes: 1 addition & 1 deletion Library/Homebrew/shims/linux/super/svn
1 change: 1 addition & 0 deletions Library/Homebrew/shims/mac/super/curl
2 changes: 1 addition & 1 deletion Library/Homebrew/shims/mac/super/git
2 changes: 1 addition & 1 deletion Library/Homebrew/shims/mac/super/svn
20 changes: 20 additions & 0 deletions Library/Homebrew/shims/shared/curl
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Library/Homebrew/shims/super/curl
2 changes: 1 addition & 1 deletion Library/Homebrew/shims/super/git
2 changes: 1 addition & 1 deletion Library/Homebrew/shims/super/svn
2 changes: 1 addition & 1 deletion Library/Homebrew/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
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)
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/utils/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end

before do
git = HOMEBREW_SHIMS_PATH/"scm/git"
git = HOMEBREW_SHIMS_PATH/"shared/git"

HOMEBREW_CACHE.cd do
system git, "init"
Expand Down Expand Up @@ -201,7 +201,7 @@

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
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/utils/svn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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
Expand All @@ -20,7 +20,7 @@

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
Expand Down
9 changes: 1 addition & 8 deletions Library/Homebrew/utils/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ module Curl
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 {
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def path
def git
return @git if defined?(@git)

@git = HOMEBREW_SHIMS_PATH/"scm/git"
@git = HOMEBREW_SHIMS_PATH/"shared/git"
end

def remote_exists?(url)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/svn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def available?
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

Expand Down