Allow searching/installing Homebrew Casks.
People want to install things like GIMP using Homebrew so let's make it easier for them to find a decent installation method. Closes Homebrew/homebrew#34496. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
264886cfc9
commit
52cda8fd80
@ -19,7 +19,8 @@ module Homebrew
|
|||||||
msg = blacklisted? name
|
msg = blacklisted? name
|
||||||
raise "No available formula for #{name}\n#{msg}" if msg
|
raise "No available formula for #{name}\n#{msg}" if msg
|
||||||
end
|
end
|
||||||
if not File.exist? name and name =~ HOMEBREW_TAP_FORMULA_REGEX then
|
if !File.exist?(name) && (name =~ HOMEBREW_TAP_FORMULA_REGEX \
|
||||||
|
|| name =~ HOMEBREW_CASK_TAP_FORMULA_REGEX)
|
||||||
install_tap $1, $2
|
install_tap $1, $2
|
||||||
end
|
end
|
||||||
end unless ARGV.force?
|
end unless ARGV.force?
|
||||||
@ -27,6 +28,17 @@ module Homebrew
|
|||||||
begin
|
begin
|
||||||
formulae = []
|
formulae = []
|
||||||
|
|
||||||
|
if ARGV.casks.any?
|
||||||
|
brew_cask = Formulary.factory("brew-cask")
|
||||||
|
install_formula(brew_cask) unless brew_cask.installed?
|
||||||
|
|
||||||
|
ARGV.casks.each do |c|
|
||||||
|
cmd = "brew", "cask", "install", c
|
||||||
|
ohai cmd.join " "
|
||||||
|
system *cmd
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
ARGV.formulae.each do |f|
|
ARGV.formulae.each do |f|
|
||||||
# Building head-only without --HEAD is an error
|
# Building head-only without --HEAD is an error
|
||||||
if not ARGV.build_head? and f.stable.nil?
|
if not ARGV.build_head? and f.stable.nil?
|
||||||
|
@ -76,6 +76,7 @@ module Homebrew
|
|||||||
%w{Homebrew binary},
|
%w{Homebrew binary},
|
||||||
%w{Homebrew python},
|
%w{Homebrew python},
|
||||||
%w{Homebrew php},
|
%w{Homebrew php},
|
||||||
|
%w{Caskroom cask},
|
||||||
]
|
]
|
||||||
|
|
||||||
def query_regexp(query)
|
def query_regexp(query)
|
||||||
@ -94,7 +95,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def search_tap user, repo, rx
|
def search_tap user, repo, rx
|
||||||
return [] if (HOMEBREW_LIBRARY/"Taps/#{user.downcase}/homebrew-#{repo.downcase}").directory?
|
if (HOMEBREW_LIBRARY/"Taps/#{user.downcase}/homebrew-#{repo.downcase}").directory? && \
|
||||||
|
"#{user}/#{repo}" != "Caskroom/cask"
|
||||||
|
return []
|
||||||
|
end
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
tree = {}
|
tree = {}
|
||||||
@ -113,7 +117,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
paths = tree["Formula"] || tree["HomebrewFormula"] || tree["."] || []
|
paths = tree["Formula"] || tree["HomebrewFormula"] || tree["Casks"] || tree["."] || []
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
name = File.basename(path, ".rb")
|
name = File.basename(path, ".rb")
|
||||||
results << "#{user}/#{repo}/#{name}" if rx === name
|
results << "#{user}/#{repo}/#{name}" if rx === name
|
||||||
|
@ -13,7 +13,11 @@ module HomebrewArgvExtension
|
|||||||
|
|
||||||
def formulae
|
def formulae
|
||||||
require "formula"
|
require "formula"
|
||||||
@formulae ||= downcased_unique_named.map { |name| Formulary.factory(name, spec) }
|
@formulae ||= (downcased_unique_named - casks).map { |name| Formulary.factory(name, spec) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def casks
|
||||||
|
@casks ||= downcased_unique_named.grep HOMEBREW_CASK_TAP_FORMULA_REGEX
|
||||||
end
|
end
|
||||||
|
|
||||||
def kegs
|
def kegs
|
||||||
|
@ -6,3 +6,5 @@ HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.]+)$}
|
|||||||
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/([\w-]+)/([\w-]+)}
|
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/([\w-]+)/([\w-]+)}
|
||||||
# match taps' formula path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula
|
# match taps' formula path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula
|
||||||
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source)
|
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source)
|
||||||
|
# match the default brew-cask tap e.g. Caskroom/cask
|
||||||
|
HOMEBREW_CASK_TAP_FORMULA_REGEX = %r{^(Caskroom)/(cask)/([\w+-.]+)$}
|
||||||
|
@ -11,6 +11,11 @@ class ArgvExtensionTests < Homebrew::TestCase
|
|||||||
assert_raises(FormulaUnavailableError) { @argv.formulae }
|
assert_raises(FormulaUnavailableError) { @argv.formulae }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_argv_casks
|
||||||
|
@argv.unshift 'mxcl'
|
||||||
|
assert_equal [], @argv.casks
|
||||||
|
end
|
||||||
|
|
||||||
def test_argv_kegs
|
def test_argv_kegs
|
||||||
keg = HOMEBREW_CELLAR + "mxcl/10.0"
|
keg = HOMEBREW_CELLAR + "mxcl/10.0"
|
||||||
keg.mkpath
|
keg.mkpath
|
||||||
|
Loading…
x
Reference in New Issue
Block a user