Fixed installation info output and imports

This commit is contained in:
Zach Auten 2019-02-19 18:23:26 -05:00
commit ed80b60834
6 changed files with 61 additions and 34 deletions

View File

@ -414,7 +414,8 @@ update-preinstall() {
[[ -z "$HOMEBREW_AUTO_UPDATE_CHECKED" ]] || return [[ -z "$HOMEBREW_AUTO_UPDATE_CHECKED" ]] || return
[[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]] || return [[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]] || return
if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || "$HOMEBREW_COMMAND" = "tap" || if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" ||
"$HOMEBREW_COMMAND" = "tap" && $HOMEBREW_ARG_COUNT -gt 1 ||
"$HOMEBREW_CASK_COMMAND" = "install" || "$HOMEBREW_CASK_COMMAND" = "upgrade" ]] "$HOMEBREW_CASK_COMMAND" = "install" || "$HOMEBREW_CASK_COMMAND" = "upgrade" ]]
then then
export HOMEBREW_AUTO_UPDATING="1" export HOMEBREW_AUTO_UPDATING="1"

View File

@ -1,4 +1,5 @@
require "json" require "json"
require "cask/installer"
module Cask module Cask
class Cmd class Cmd
@ -51,12 +52,17 @@ module Cask
end end
def self.installation_info(cask) def self.installation_info(cask)
install_info = ""
if cask.installed? if cask.installed?
cask.versions.each do |version| cask.versions.each do |version|
versioned_staged_path = cask.caskroom_path.join(version) versioned_staged_path = cask.caskroom_path.join(version)
message = versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist") install_info << versioned_staged_path.to_s
versioned_staged_path.to_s.concat(" (").concat(message).concat(")") .concat(" (")
.concat(versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist"))
.concat(")")
install_info << "\n"
end end
return install_info.strip
else else
"Not installed" "Not installed"
end end

View File

@ -135,6 +135,7 @@ module Homebrew
check_constraint_violations check_constraint_violations
Homebrew.args[:remaining] = remaining_args Homebrew.args[:remaining] = remaining_args
Homebrew.args.freeze Homebrew.args.freeze
cmdline_args.freeze
@parser @parser
end end

View File

@ -31,7 +31,8 @@ module Homebrew
end end
def irb def irb
irb_args.parse # work around IRB modifying ARGV.
irb_args.parse(ARGV.dup)
if args.examples? if args.examples?
puts "'v8'.f # => instance of the v8 formula" puts "'v8'.f # => instance of the v8 formula"

View File

@ -30,7 +30,8 @@ module HomebrewArgvExtension
end end
def named def named
@named ||= self - options_only # TODO: use @instance variable to ||= cache when moving to CLI::Parser
self - options_only
end end
def options_only def options_only
@ -43,7 +44,8 @@ module HomebrewArgvExtension
def formulae def formulae
require "formula" require "formula"
@formulae ||= (downcased_unique_named - casks).map do |name| # TODO: use @instance variable to ||= cache when moving to CLI::Parser
(downcased_unique_named - casks).map do |name|
if name.include?("/") || File.exist?(name) if name.include?("/") || File.exist?(name)
Formulary.factory(name, spec) Formulary.factory(name, spec)
else else
@ -54,19 +56,22 @@ module HomebrewArgvExtension
def resolved_formulae def resolved_formulae
require "formula" require "formula"
@resolved_formulae ||= (downcased_unique_named - casks).map do |name| # TODO: use @instance variable to ||= cache when moving to CLI::Parser
(downcased_unique_named - casks).map do |name|
Formulary.resolve(name, spec: spec(nil)) Formulary.resolve(name, spec: spec(nil))
end.uniq(&:name) end.uniq(&:name)
end end
def casks def casks
@casks ||= downcased_unique_named.grep HOMEBREW_CASK_TAP_CASK_REGEX # TODO: use @instance variable to ||= cache when moving to CLI::Parser
downcased_unique_named.grep HOMEBREW_CASK_TAP_CASK_REGEX
end end
def kegs def kegs
require "keg" require "keg"
require "formula" require "formula"
@kegs ||= downcased_unique_named.map do |name| # TODO: use @instance variable to ||= cache when moving to CLI::Parser
downcased_unique_named.map do |name|
raise UsageError if name.empty? raise UsageError if name.empty?
rack = Formulary.to_rack(name.downcase) rack = Formulary.to_rack(name.downcase)
@ -109,7 +114,7 @@ module HomebrewArgvExtension
end end
def include?(arg) def include?(arg)
!(@n = index(arg)).nil? !index(arg).nil?
end end
def next def next
@ -281,7 +286,8 @@ module HomebrewArgvExtension
def downcased_unique_named def downcased_unique_named
# Only lowercase names, not paths, bottle filenames or URLs # Only lowercase names, not paths, bottle filenames or URLs
@downcased_unique_named ||= named.map do |arg| # TODO: use @instance variable to ||= cache when moving to CLI::Parser
named.map do |arg|
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg) if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
arg arg
else else

View File

@ -1,8 +1,7 @@
require "formulary" require "formulary"
require "cask/cmd/abstract_command" require "cask/cmd/abstract_command"
require "cask/cmd" require "cask/cmd/info"
require "cask/cask_loader" require "cask/cask_loader"
require "cask/installer"
module Homebrew module Homebrew
module MissingFormula module MissingFormula
@ -15,34 +14,35 @@ module Homebrew
def blacklisted_reason(name) def blacklisted_reason(name)
case name.downcase case name.downcase
when "gem", /^rubygems?$/ then <<~EOS when "gem", /^rubygems?$/ then <<~EOS
Homebrew provides gem via: `brew install ruby`. macOS provides gem as part of Ruby. To install a newer version:
brew install ruby
EOS EOS
when "tex", "tex-live", "texlive", "latex" then <<~EOS when "tex", "tex-live", "texlive", "latex" then <<~EOS
Installing TeX from source is weird and gross, requires a lot of patches, There are three versions of MacTeX.
and only builds 32-bit (and thus can't use Homebrew dependencies)
We recommend using a MacTeX distribution: https://www.tug.org/mactex/ Full installation:
You can install it with Homebrew Cask:
brew cask install mactex brew cask install mactex
Full installation without bundled applications:
brew cask install mactex-no-gui
Minimal installation:
brew cask install basictex
EOS EOS
when "pip" then <<~EOS when "pip" then <<~EOS
pip is part of the python formula, and can be installed with: pip is part of the python formula:
brew install python brew install python
However you will then have two Pythons installed on your Mac,
so alternatively you can install pip via the instructions at:
#{Formatter.url("https://pip.readthedocs.io/en/stable/installing/")}
EOS EOS
when "pil" then <<~EOS when "pil" then <<~EOS
Instead of PIL, consider `pip2 install pillow`. Instead of PIL, consider pillow:
pip2 install pillow
EOS EOS
when "macruby" then <<~EOS when "macruby" then <<~EOS
MacRuby is not packaged and is on an indefinite development hiatus. MacRuby has been discontinued. Consider RubyMotion:
You can read more about it at: brew cask install rubymotion
#{Formatter.url("https://github.com/MacRuby/MacRuby")}
EOS EOS
when /(lib)?lzma/ then <<~EOS when /(lib)?lzma/ then <<~EOS
lzma is now part of the xz formula, and can be installed with: lzma is now part of the xz formula:
brew install xz brew install xz
EOS EOS
when "gtest", "googletest", "google-test" then <<~EOS when "gtest", "googletest", "google-test" then <<~EOS
@ -58,10 +58,11 @@ module Homebrew
ruin SSH's security. ruin SSH's security.
EOS EOS
when "gsutil" then <<~EOS when "gsutil" then <<~EOS
Install gsutil with `pip2 install gsutil` gsutil is available through pip:
pip2 install gsutil
EOS EOS
when "gfortran" then <<~EOS when "gfortran" then <<~EOS
GNU Fortran is now part of the GCC formula, and can be installed with: GNU Fortran is part of the GCC formula:
brew install gcc brew install gcc
EOS EOS
when "play" then <<~EOS when "play" then <<~EOS
@ -73,9 +74,16 @@ module Homebrew
#{Formatter.url("https://www.playframework.com/documentation/2.3.x/Highlights23")} #{Formatter.url("https://www.playframework.com/documentation/2.3.x/Highlights23")}
EOS EOS
when "haskell-platform" then <<~EOS when "haskell-platform" then <<~EOS
We no longer package haskell-platform. Consider installing ghc, The components of the Haskell Platform are available separately.
cabal-install and stack instead:
brew install ghc cabal-install stack Glasgow Haskell Compiler:
brew install ghc
Cabal build system:
brew install cabal-install
Haskell Stack tool:
brew install haskell-stack
EOS EOS
when "mysqldump-secure" then <<~EOS when "mysqldump-secure" then <<~EOS
The creator of mysqldump-secure tried to game our popularity metrics. The creator of mysqldump-secure tried to game our popularity metrics.
@ -87,9 +95,13 @@ module Homebrew
brew cask install ngrok brew cask install ngrok
EOS EOS
when "cargo" then <<~EOS when "cargo" then <<~EOS
cargo is part of the rust formula, and can be installed with: cargo is part of the rust formula:
brew install rust brew install rust
EOS EOS
when "uconv" then <<~EOS
uconv is part of the icu4c formula:
brew install icu4c
EOS
end end
end end
alias generic_blacklisted_reason blacklisted_reason alias generic_blacklisted_reason blacklisted_reason