aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorDavid Broder-Rodgers2017-01-30 18:31:52 +0000
committerDavid Broder-Rodgers2017-01-30 18:31:52 +0000
commit13a3a57fa86678e3a3cb9272fe04285cb538c55b (patch)
treec345802d70ff32e2f787986b2f5392ac76f367fb /Library/Homebrew/cmd
parent3c566399cf8dab3aff8c54381e7b83b0e6ef3995 (diff)
parent35045b2934d94eabe302693a05b12fb530827454 (diff)
downloadbrew-13a3a57fa86678e3a3cb9272fe04285cb538c55b.tar.bz2
Merge remote-tracking branch 'origin/master' into insecure_audit
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/--prefix.rb2
-rw-r--r--Library/Homebrew/cmd/analytics.rb2
-rw-r--r--Library/Homebrew/cmd/deps.rb33
-rw-r--r--Library/Homebrew/cmd/fetch.rb5
-rw-r--r--Library/Homebrew/cmd/help.rb2
-rw-r--r--Library/Homebrew/cmd/info.rb2
-rw-r--r--Library/Homebrew/cmd/install.rb19
-rw-r--r--Library/Homebrew/cmd/linkapps.rb16
-rw-r--r--Library/Homebrew/cmd/tap-info.rb2
-rw-r--r--Library/Homebrew/cmd/uninstall.rb6
-rw-r--r--Library/Homebrew/cmd/unlinkapps.rb13
-rw-r--r--Library/Homebrew/cmd/update-report.rb43
-rw-r--r--Library/Homebrew/cmd/upgrade.rb24
-rw-r--r--Library/Homebrew/cmd/uses.rb28
14 files changed, 146 insertions, 51 deletions
diff --git a/Library/Homebrew/cmd/--prefix.rb b/Library/Homebrew/cmd/--prefix.rb
index c59830833..f6e7d2ee2 100644
--- a/Library/Homebrew/cmd/--prefix.rb
+++ b/Library/Homebrew/cmd/--prefix.rb
@@ -11,7 +11,7 @@ module Homebrew
if ARGV.named.empty?
puts HOMEBREW_PREFIX
else
- puts ARGV.resolved_formulae.map { |f| f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix }
+ puts ARGV.resolved_formulae.map(&:installed_prefix)
end
end
end
diff --git a/Library/Homebrew/cmd/analytics.rb b/Library/Homebrew/cmd/analytics.rb
index 2efa5a2d2..8a67a54a4 100644
--- a/Library/Homebrew/cmd/analytics.rb
+++ b/Library/Homebrew/cmd/analytics.rb
@@ -1,6 +1,6 @@
#: * `analytics` [`state`]:
#: Display anonymous user behaviour analytics state.
-#: Read more at <https://git.io/brew-analytics>.
+#: Read more at <http://docs.brew.sh/Analytics.html>.
#:
#: * `analytics` (`on`|`off`):
#: Turn on/off Homebrew's analytics.
diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb
index a5089392f..205cbe172 100644
--- a/Library/Homebrew/cmd/deps.rb
+++ b/Library/Homebrew/cmd/deps.rb
@@ -66,16 +66,16 @@ module Homebrew
else
all_deps = deps_for_formulae(ARGV.formulae, !ARGV.one?, &(mode.union? ? :| : :&))
all_deps = all_deps.select(&:installed?) if mode.installed?
- all_deps = if ARGV.include? "--full-name"
- all_deps.map(&:to_formula).map(&:full_name)
- else
- all_deps.map(&:name)
- end.uniq
+ all_deps = all_deps.map(&method(:dep_display_name)).uniq
all_deps.sort! unless mode.topo_order?
puts all_deps
end
end
+ def dep_display_name(d)
+ ARGV.include?("--full-name") ? d.to_formula.full_name : d.name
+ end
+
def deps_for_formula(f, recursive = false)
includes = []
ignores = []
@@ -127,7 +127,10 @@ module Homebrew
end
def puts_deps(formulae)
- formulae.each { |f| puts "#{f.full_name}: #{deps_for_formula(f).sort_by(&:name) * " "}" }
+ formulae.each do |f|
+ deps = deps_for_formula(f).sort_by(&:name).map(&method(:dep_display_name))
+ puts "#{f.full_name}: #{deps.join(" ")}"
+ end
end
def puts_deps_tree(formulae)
@@ -140,17 +143,25 @@ module Homebrew
def recursive_deps_tree(f, prefix)
reqs = f.requirements.select(&:default_formula?)
+ deps = f.deps.default
max = reqs.length - 1
reqs.each_with_index do |req, i|
- chr = i == max ? "└──" : "├──"
- puts prefix + "#{chr} :#{req.to_dependency.name}"
+ chr = if i == max && deps.empty?
+ "└──"
+ else
+ "├──"
+ end
+ puts prefix + "#{chr} :#{dep_display_name(req.to_dependency)}"
end
- deps = f.deps.default
max = deps.length - 1
deps.each_with_index do |dep, i|
- chr = i == max ? "└──" : "├──"
+ chr = if i == max
+ "└──"
+ else
+ "├──"
+ end
prefix_ext = i == max ? " " : "│ "
- puts prefix + "#{chr} #{dep.name}"
+ puts prefix + "#{chr} #{dep_display_name(dep)}"
recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_ext)
end
end
diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb
index f92ef03b2..820a27e31 100644
--- a/Library/Homebrew/cmd/fetch.rb
+++ b/Library/Homebrew/cmd/fetch.rb
@@ -18,8 +18,9 @@
#: If `--build-from-source` is passed, download the source rather than a
#: bottle.
#:
-#: If `--force-bottle` is passed, download a bottle if it exists for the current
-#: version of macOS, even if it would not be used during installation.
+#: If `--force-bottle` is passed, download a bottle if it exists for the
+#: current or newest version of macOS, even if it would not be used during
+#: installation.
require "formula"
diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb
index 982e24965..1378e7b1f 100644
--- a/Library/Homebrew/cmd/help.rb
+++ b/Library/Homebrew/cmd/help.rb
@@ -16,7 +16,7 @@ Troubleshooting:
Developers:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
- https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md
+ http://docs.brew.sh/Formula-Cookbook.html
Further help:
man brew
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index fc47e1731..1850ae003 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -14,7 +14,7 @@
#: information on all installed formulae.
#:
#: See the docs for examples of using the JSON:
-#: <https://github.com/Homebrew/brew/blob/master/docs/Querying-Brew.md>
+#: <http://docs.brew.sh/Querying-Brew.html>
require "blacklist"
require "caveats"
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 700cd9c3d..5a3aeb7b3 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -32,10 +32,10 @@
#: passed, then both <formula> and the dependencies installed as part of this process
#: are built from source even if bottles are available.
#:
-# Hidden developer option:
-# If `--force-bottle` is passed, install from a bottle if it exists
-# for the current version of macOS, even if custom options are given.
-#
+#: If `--force-bottle` is passed, install from a bottle if it exists for the
+#: current or newest version of macOS, even if it would not normally be used
+#: for installation.
+#:
#: If `--devel` is passed, and <formula> defines it, install the development version.
#:
#: If `--HEAD` is passed, and <formula> defines it, install the HEAD version,
@@ -44,9 +44,6 @@
#: If `--keep-tmp` is passed, the temporary files created during installation
#: are not deleted.
#:
-#: To install a newer version of HEAD use
-#: `brew rm <foo> && brew install --HEAD <foo>`.
-#:
#: * `install` `--interactive` [`--git`] <formula>:
#: Download and patch <formula>, then open a shell. This allows the user to
#: run `./configure --help` and otherwise determine how to turn the software
@@ -187,6 +184,14 @@ module Homebrew
# FormulaInstaller will handle this case.
formulae << f
end
+
+ # Even if we don't install this formula mark it as no longer just
+ # installed as a dependency.
+ next unless f.opt_prefix.directory?
+ keg = Keg.new(f.opt_prefix.resolved_path)
+ tab = Tab.for_keg(keg)
+ tab.installed_on_request = true
+ tab.write
end
perform_preinstall_checks
diff --git a/Library/Homebrew/cmd/linkapps.rb b/Library/Homebrew/cmd/linkapps.rb
index bd88409aa..7dd1a6b93 100644
--- a/Library/Homebrew/cmd/linkapps.rb
+++ b/Library/Homebrew/cmd/linkapps.rb
@@ -1,6 +1,11 @@
#: * `linkapps` [`--local`] [<formulae>]:
#: Find installed formulae that provide `.app`-style macOS apps and symlink them
-#: into `/Applications`, allowing for easier access.
+#: into `/Applications`, allowing for easier access (deprecated).
+#:
+#: Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using
+#: either aliases or symlinks and Homebrew formulae do not build "proper" `.app`
+#: bundles that can be relocated. Instead, please consider using `brew cask` and
+#: migrate formulae using `.app`s to casks.
#:
#: If no <formulae> are provided, all of them will have their apps symlinked.
#:
@@ -14,6 +19,15 @@ module Homebrew
module_function
def linkapps
+ opoo <<-EOS.undent
+ `brew linkapps` has been deprecated and will eventually be removed!
+
+ Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using
+ either aliases or symlinks and Homebrew formulae do not build "proper" `.app`
+ bundles that can be relocated. Instead, please consider using `brew cask` and
+ migrate formulae using `.app`s to casks.
+ EOS
+
target_dir = linkapps_target(local: ARGV.include?("--local"))
unless target_dir.directory?
diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb
index 0d9f8db3d..b46de30c1 100644
--- a/Library/Homebrew/cmd/tap-info.rb
+++ b/Library/Homebrew/cmd/tap-info.rb
@@ -13,7 +13,7 @@
#: Pass `--installed` to get information on installed taps.
#:
#: See the docs for examples of using the JSON:
-#: <https://github.com/Homebrew/brew/blob/master/docs/Querying-Brew.md>
+#: <http://docs.brew.sh/Querying-Brew.html>
require "tap"
diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb
index 505d4e4b2..5d02ebd1e 100644
--- a/Library/Homebrew/cmd/uninstall.rb
+++ b/Library/Homebrew/cmd/uninstall.rb
@@ -102,8 +102,8 @@ module Homebrew
attr_reader :reqs, :deps
def initialize(requireds, dependents)
- @reqs = requireds.compact
- @deps = dependents.compact
+ @reqs = requireds
+ @deps = dependents
end
protected
@@ -121,7 +121,7 @@ module Homebrew
end
def sample_command
- "brew uninstall --ignore-dependencies #{list reqs.map(&:name)}"
+ "brew uninstall --ignore-dependencies #{ARGV.named.join(" ")}"
end
def are_required_by_deps
diff --git a/Library/Homebrew/cmd/unlinkapps.rb b/Library/Homebrew/cmd/unlinkapps.rb
index d04ef9ee4..b2ba458bf 100644
--- a/Library/Homebrew/cmd/unlinkapps.rb
+++ b/Library/Homebrew/cmd/unlinkapps.rb
@@ -1,5 +1,10 @@
#: * `unlinkapps` [`--local`] [`--dry-run`] [<formulae>]:
-#: Remove symlinks created by `brew linkapps` from `/Applications`.
+#: Remove symlinks created by `brew linkapps` from `/Applications` (deprecated).
+#:
+#: Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using
+#: either aliases or symlinks and Homebrew formulae do not build "proper" `.app`
+#: bundles that can be relocated. Instead, please consider using `brew cask` and
+#: migrate formulae using `.app`s to casks.
#:
#: If no <formulae> are provided, all linked apps will be removed.
#:
@@ -15,6 +20,12 @@ module Homebrew
module_function
def unlinkapps
+ opoo <<-EOS.undent
+ `brew unlinkapps` has been deprecated and will eventually be removed!
+
+ Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using either aliases or symlinks and Homebrew formulae do not build "proper" `.app` bundles that can be relocated. Instead, please consider using `brew cask` and migrate formulae using `.app`s to casks.
+ EOS
+
target_dir = linkapps_target(local: ARGV.include?("--local"))
unlinkapps_from_dir(target_dir, dry_run: ARGV.dry_run?)
diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb
index 10b433dd2..dcf2891d9 100644
--- a/Library/Homebrew/cmd/update-report.rb
+++ b/Library/Homebrew/cmd/update-report.rb
@@ -35,7 +35,7 @@ module Homebrew
ohai "Homebrew has enabled anonymous aggregate user behaviour analytics."
puts <<-EOS.undent
#{Tty.bold}Read the analytics documentation (and how to opt-out) here:
- #{Formatter.url("https://git.io/brew-analytics")}#{Tty.reset}
+ #{Formatter.url("http://docs.brew.sh/Analytics.html")}#{Tty.reset}
EOS
@@ -387,7 +387,7 @@ class Reporter
end
end
- renamed_formulae = []
+ renamed_formulae = Set.new
@report[:D].each do |old_full_name|
old_name = old_full_name.split("/").last
new_name = tap.formula_renames[old_name]
@@ -402,10 +402,24 @@ class Reporter
renamed_formulae << [old_full_name, new_full_name] if @report[:A].include? new_full_name
end
+ @report[:A].each do |new_full_name|
+ new_name = new_full_name.split("/").last
+ old_name = tap.formula_renames.key(new_name)
+ next unless old_name
+
+ if tap.core_tap?
+ old_full_name = old_name
+ else
+ old_full_name = "#{tap}/#{old_name}"
+ end
+
+ renamed_formulae << [old_full_name, new_full_name]
+ end
+
unless renamed_formulae.empty?
@report[:A] -= renamed_formulae.map(&:last)
@report[:D] -= renamed_formulae.map(&:first)
- @report[:R] = renamed_formulae
+ @report[:R] = renamed_formulae.to_a
end
@report
@@ -421,18 +435,27 @@ class Reporter
new_tap_name = tap.tap_migrations[name]
next if new_tap_name.nil? # skip if not in tap_migrations list.
+ new_tap_user, new_tap_repo, new_tap_new_name = new_tap_name.split("/")
+ new_name = if new_tap_new_name
+ new_full_name = new_tap_new_name
+ new_tap_name = "#{new_tap_user}/#{new_tap_repo}"
+ new_tap_new_name
+ else
+ new_full_name = "#{new_tap_name}/#{name}"
+ name
+ end
+
# This means it is a Cask
if report[:DC].include? full_name
- next unless (HOMEBREW_PREFIX/"Caskroom"/name).exist?
+ next unless (HOMEBREW_PREFIX/"Caskroom"/new_name).exist?
new_tap = Tap.fetch(new_tap_name)
new_tap.install unless new_tap.installed?
ohai "#{name} has been moved to Homebrew.", <<-EOS.undent
To uninstall the cask run:
brew cask uninstall --force #{name}
EOS
- new_full_name = "#{new_tap_name}/#{name}"
- next if (HOMEBREW_CELLAR/name.split("/").last).directory?
- ohai "Installing #{name}..."
+ next if (HOMEBREW_CELLAR/new_name.split("/").last).directory?
+ ohai "Installing #{new_name}..."
system HOMEBREW_BREW_FILE, "install", new_full_name
begin
unless Formulary.factory(new_full_name).keg_only?
@@ -456,13 +479,13 @@ class Reporter
system HOMEBREW_BREW_FILE, "uninstall", "--force", name
ohai "brew prune"
system HOMEBREW_BREW_FILE, "prune"
- ohai "brew cask install #{name}"
- system HOMEBREW_BREW_FILE, "cask", "install", name
+ ohai "brew cask install #{new_name}"
+ system HOMEBREW_BREW_FILE, "cask", "install", new_name
else
ohai "#{name} has been moved to Homebrew-Cask.", <<-EOS.undent
To uninstall the formula and install the cask run:
brew uninstall --force #{name}
- brew cask install #{name}
+ brew cask install #{new_name}
EOS
end
else
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb
index 5b49a9f65..ce892f85c 100644
--- a/Library/Homebrew/cmd/upgrade.rb
+++ b/Library/Homebrew/cmd/upgrade.rb
@@ -94,14 +94,24 @@ module Homebrew
.select(&:directory?)
.map { |k| Keg.new(k.resolved_path) }
+ if f.opt_prefix.directory?
+ keg = Keg.new(f.opt_prefix.resolved_path)
+ tab = Tab.for_keg(keg)
+ end
+
fi = FormulaInstaller.new(f)
- fi.options = f.build.used_options
- fi.options &= f.options
- fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?)
- fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source?
- fi.verbose = ARGV.verbose?
- fi.quieter = ARGV.quieter?
- fi.debug = ARGV.debug?
+ fi.options = f.build.used_options
+ fi.options &= f.options
+ fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?)
+ fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source?
+ fi.verbose = ARGV.verbose?
+ fi.quieter = ARGV.quieter?
+ fi.debug = ARGV.debug?
+ fi.installed_on_request = !ARGV.named.empty?
+ if tab
+ fi.installed_as_dependency = tab.installed_as_dependency
+ fi.installed_on_request ||= tab.installed_on_request
+ end
fi.prelude
oh1 "Upgrading #{f.full_specified_name} #{fi.options.to_a.join " "}"
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb
index fb11a31a7..5f6611dfc 100644
--- a/Library/Homebrew/cmd/uses.rb
+++ b/Library/Homebrew/cmd/uses.rb
@@ -57,16 +57,36 @@ module Homebrew
elsif dep.build?
Dependency.prune unless includes.include?("build?")
end
+
+ # If a tap isn't installed, we can't find the dependencies of one
+ # its formulae, and an exception will be thrown if we try.
+ if dep.is_a?(TapDependency) && !dep.tap.installed?
+ Dependency.keep_but_prune_recursive_deps
+ end
+ end
+
+ dep_formulae = deps.map do |dep|
+ begin
+ dep.to_formula
+ rescue
+ end
+ end.compact
+
+ reqs_by_formula = ([f] + dep_formulae).flat_map do |formula|
+ formula.requirements.map { |req| [formula, req] }
end
- reqs = f.recursive_requirements do |dependent, req|
+
+ reqs_by_formula.reject! do |dependent, req|
if req.recommended?
- Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req)
+ ignores.include?("recommended?") || dependent.build.without?(req)
elsif req.optional?
- Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req)
+ !includes.include?("optional?") && !dependent.build.with?(req)
elsif req.build?
- Requirement.prune unless includes.include?("build?")
+ !includes.include?("build?")
end
end
+
+ reqs = reqs_by_formula.map(&:last)
else
deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }