Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More environment filtering tweaks #2620

Merged
merged 1 commit into from
May 14, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/diagnostic.rb
Expand Up @@ -100,7 +100,7 @@ def check_for_installed_developer_tools

# See https://github.com/Homebrew/legacy-homebrew/pull/9986
def check_path_for_trailing_slashes
bad_paths = PATH.new(ENV["PATH"]).select { |p| p.end_with?("/") }
bad_paths = PATH.new(ENV["HOMEBREW_PATH"]).select { |p| p.end_with?("/") }
return if bad_paths.empty?

inject_file_list bad_paths, <<-EOS.undent
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/download_strategy.rb
Expand Up @@ -520,6 +520,9 @@ def _fetch
bucket = $1
key = $2

ENV["AWS_ACCESS_KEY_ID"] = ENV["HOMEBREW_AWS_ACCESS_KEY_ID"]
ENV["AWS_SECRET_ACCESS_KEY"] = ENV["HOMEBREW_AWS_SECRET_ACCESS_KEY"]

obj = AWS::S3.new.buckets[bucket].objects[key]
begin
s3url = obj.url_for(:get)
Expand Down
39 changes: 14 additions & 25 deletions Library/Homebrew/manpages/brew.1.md.erb
Expand Up @@ -98,39 +98,25 @@ can take several different forms:
The formula file will be cached for later use.

## ENVIRONMENT
* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.

* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.

*Default:* `60`.

* `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`:
* `HOMEBREW_AWS_ACCESS_KEY_ID`, `HOMEBREW_AWS_SECRET_ACCESS_KEY`:
When using the `S3` download strategy, Homebrew will look in
these variables for access credentials (see
<https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment>
to retrieve these access credentials from AWS). If they are not set,
the `S3` download strategy will download with a public
(unsigned) URL.

* `BROWSER`:
If set, and `HOMEBREW_BROWSER` is not, use `BROWSER` as the web browser
when opening project homepages.

* `EDITOR`:
If set, and `HOMEBREW_EDITOR` and `VISUAL` are not, use `EDITOR` as the text editor.

* `GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.

Set this to force Homebrew to use a particular git binary.

* `HOMEBREW_BOTTLE_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles.

* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.

* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.

*Default:* `60`.

* `HOMEBREW_BROWSER`:
If set, uses this setting as the browser when opening project homepages,
instead of the OS default browser.
Expand Down Expand Up @@ -178,6 +164,12 @@ can take several different forms:
If set, Homebrew will always use its vendored, relocatable Ruby 2.0 version
even if the system version of Ruby is >=2.0.

* `HOMEBREW_GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.

Set this to force Homebrew to use a particular git binary.

* `HOMEBREW_GITHUB_API_TOKEN`:
A personal access token for the GitHub API, which you can create at
<https://github.com/settings/tokens>. If set, GitHub will allow you a
Expand Down Expand Up @@ -243,9 +235,6 @@ can take several different forms:
* `HOMEBREW_VERBOSE`:
If set, Homebrew always assumes `--verbose` when running commands.

* `VISUAL`:
If set, and `HOMEBREW_EDITOR` is not, use `VISUAL` as the text editor.

## USING HOMEBREW BEHIND A PROXY

Homebrew uses several commands for downloading files (e.g. `curl`, `git`, `svn`).
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/shims/scm/git
Expand Up @@ -86,7 +86,6 @@ fi
case "$(lowercase "$SCM_FILE")" in
git)
[[ -n "$HOMEBREW_GIT" ]] && safe_exec "$(which "$HOMEBREW_GIT")" "$@"
[[ -n "$GIT" ]] && safe_exec "$(which "$GIT")" "$@"
;;
svn)
[[ -n "$HOMEBREW_SVN" ]] && safe_exec "$(which "$HOMEBREW_SVN")" "$@"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/diagnostic_spec.rb
Expand Up @@ -7,7 +7,7 @@
end

specify "#check_path_for_trailing_slashes" do
ENV["PATH"] += File::PATH_SEPARATOR + "/foo/bar/"
ENV["HOMEBREW_PATH"] += File::PATH_SEPARATOR + "/foo/bar/"
expect(subject.check_path_for_trailing_slashes)
.to match("Some directories in your path end in a slash")
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/utils.rb
Expand Up @@ -320,7 +320,7 @@ def which_all(cmd, path = ENV["PATH"])
end

def which_editor
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.reject(&:empty?).first
editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL").compact.reject(&:empty?).first
if editor
editor_name, _, editor_args = editor.partition " "
editor_path = which(editor_name, ENV["HOMEBREW_PATH"])
Expand Down Expand Up @@ -356,7 +356,7 @@ def exec_editor(*args)
end

def exec_browser(*args)
browser = ENV["HOMEBREW_BROWSER"] || ENV["BROWSER"]
browser = ENV["HOMEBREW_BROWSER"]
browser ||= OS::PATH_OPEN if defined?(OS::PATH_OPEN)
return unless browser
safe_exec(browser, *args)
Expand Down
5 changes: 4 additions & 1 deletion bin/brew
Expand Up @@ -44,7 +44,10 @@ fi

HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"

for VAR in EDITOR PATH BINTRAY_USER BINTRAY_KEY
# Whitelist and copy to HOMEBREW_* all variables previously mentioned in
# manpage or used elsewhere by Homebrew.
for VAR in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY BINTRAY_USER BINTRAY_KEY \
BROWSER EDITOR GIT PATH VISUAL
do
VAR_NEW="HOMEBREW_${VAR}"
[[ -n "${!VAR_NEW}" ]] && continue
Expand Down
39 changes: 14 additions & 25 deletions docs/Manpage.md
Expand Up @@ -910,39 +910,25 @@ can take several different forms:
The formula file will be cached for later use.

## ENVIRONMENT
* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.

* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.

*Default:* `60`.

* `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`:
* `HOMEBREW_AWS_ACCESS_KEY_ID`, `HOMEBREW_AWS_SECRET_ACCESS_KEY`:
When using the `S3` download strategy, Homebrew will look in
these variables for access credentials (see
<https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment>
to retrieve these access credentials from AWS). If they are not set,
the `S3` download strategy will download with a public
(unsigned) URL.

* `BROWSER`:
If set, and `HOMEBREW_BROWSER` is not, use `BROWSER` as the web browser
when opening project homepages.

* `EDITOR`:
If set, and `HOMEBREW_EDITOR` and `VISUAL` are not, use `EDITOR` as the text editor.

* `GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.

Set this to force Homebrew to use a particular git binary.

* `HOMEBREW_BOTTLE_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles.

* `HOMEBREW_ARTIFACT_DOMAIN`:
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries.

* `HOMEBREW_AUTO_UPDATE_SECS`:
If set, Homebrew will only check for autoupdates once per this seconds interval.

*Default:* `60`.

* `HOMEBREW_BROWSER`:
If set, uses this setting as the browser when opening project homepages,
instead of the OS default browser.
Expand Down Expand Up @@ -990,6 +976,12 @@ can take several different forms:
If set, Homebrew will always use its vendored, relocatable Ruby 2.0 version
even if the system version of Ruby is >=2.0.

* `HOMEBREW_GIT`:
When using Git, Homebrew will use `GIT` if set,
a Homebrew-built Git if installed, or the system-provided binary.

Set this to force Homebrew to use a particular git binary.

* `HOMEBREW_GITHUB_API_TOKEN`:
A personal access token for the GitHub API, which you can create at
<https://github.com/settings/tokens>. If set, GitHub will allow you a
Expand Down Expand Up @@ -1055,9 +1047,6 @@ can take several different forms:
* `HOMEBREW_VERBOSE`:
If set, Homebrew always assumes `--verbose` when running commands.

* `VISUAL`:
If set, and `HOMEBREW_EDITOR` is not, use `VISUAL` as the text editor.

## USING HOMEBREW BEHIND A PROXY

Homebrew uses several commands for downloading files (e.g. `curl`, `git`, `svn`).
Expand Down
42 changes: 15 additions & 27 deletions manpages/brew.1
Expand Up @@ -941,29 +941,6 @@ Homebrew can install formulae via URL, e\.g\. \fBhttps://raw\.github\.com/Homebr
.SH "ENVIRONMENT"
.
.TP
\fBAWS_ACCESS_KEY_ID\fR, \fBAWS_SECRET_ACCESS_KEY\fR
When using the \fBS3\fR download strategy, Homebrew will look in these variables for access credentials (see \fIhttps://docs\.aws\.amazon\.com/cli/latest/userguide/cli\-chap\-getting\-started\.html#cli\-environment\fR to retrieve these access credentials from AWS)\. If they are not set, the \fBS3\fR download strategy will download with a public (unsigned) URL\.
.
.TP
\fBBROWSER\fR
If set, and \fBHOMEBREW_BROWSER\fR is not, use \fBBROWSER\fR as the web browser when opening project homepages\.
.
.TP
\fBEDITOR\fR
If set, and \fBHOMEBREW_EDITOR\fR and \fBVISUAL\fR are not, use \fBEDITOR\fR as the text editor\.
.
.TP
\fBGIT\fR
When using Git, Homebrew will use \fBGIT\fR if set, a Homebrew\-built Git if installed, or the system\-provided binary\.
.
.IP
Set this to force Homebrew to use a particular git binary\.
.
.TP
\fBHOMEBREW_BOTTLE_DOMAIN\fR
If set, instructs Homebrew to use the given URL as a download mirror for bottles\.
.
.TP
\fBHOMEBREW_ARTIFACT_DOMAIN\fR
If set, instructs Homebrew to use the given URL as a download mirror for bottles and binaries\.
.
Expand All @@ -975,6 +952,14 @@ If set, Homebrew will only check for autoupdates once per this seconds interval\
\fIDefault:\fR \fB60\fR\.
.
.TP
\fBHOMEBREW_AWS_ACCESS_KEY_ID\fR, \fBHOMEBREW_AWS_SECRET_ACCESS_KEY\fR
When using the \fBS3\fR download strategy, Homebrew will look in these variables for access credentials (see \fIhttps://docs\.aws\.amazon\.com/cli/latest/userguide/cli\-chap\-getting\-started\.html#cli\-environment\fR to retrieve these access credentials from AWS)\. If they are not set, the \fBS3\fR download strategy will download with a public (unsigned) URL\.
.
.TP
\fBHOMEBREW_BOTTLE_DOMAIN\fR
If set, instructs Homebrew to use the given URL as a download mirror for bottles\.
.
.TP
\fBHOMEBREW_BROWSER\fR
If set, uses this setting as the browser when opening project homepages, instead of the OS default browser\.
.
Expand Down Expand Up @@ -1021,6 +1006,13 @@ If set, Homebrew will use this editor when editing a single formula, or several
If set, Homebrew will always use its vendored, relocatable Ruby 2\.0 version even if the system version of Ruby is >=2\.0\.
.
.TP
\fBHOMEBREW_GIT\fR
When using Git, Homebrew will use \fBGIT\fR if set, a Homebrew\-built Git if installed, or the system\-provided binary\.
.
.IP
Set this to force Homebrew to use a particular git binary\.
.
.TP
\fBHOMEBREW_GITHUB_API_TOKEN\fR
A personal access token for the GitHub API, which you can create at \fIhttps://github\.com/settings/tokens\fR\. If set, GitHub will allow you a greater number of API requests\. See \fIhttps://developer\.github\.com/v3/#rate\-limiting\fR for more information\. Homebrew uses the GitHub API for features such as \fBbrew search\fR\.
.
Expand Down Expand Up @@ -1086,10 +1078,6 @@ This issue typically occurs when using FileVault or custom SSD configurations\.
\fBHOMEBREW_VERBOSE\fR
If set, Homebrew always assumes \fB\-\-verbose\fR when running commands\.
.
.TP
\fBVISUAL\fR
If set, and \fBHOMEBREW_EDITOR\fR is not, use \fBVISUAL\fR as the text editor\.
.
.SH "USING HOMEBREW BEHIND A PROXY"
Homebrew uses several commands for downloading files (e\.g\. \fBcurl\fR, \fBgit\fR, \fBsvn\fR)\. Many of these tools can download via a proxy\. It\'s common for these tools to read proxy parameters from environment variables\.
.
Expand Down