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

brew-cask: move to using tap cmd directory. #15381

Merged
merged 3 commits into from
Dec 9, 2015
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
170 changes: 0 additions & 170 deletions bin/brew-cask

This file was deleted.

71 changes: 9 additions & 62 deletions brew-cask.rb
Original file line number Diff line number Diff line change
@@ -1,73 +1,20 @@
begin
require Pathname(__FILE__).realpath.dirname.join("lib", "hbc", "version")
rescue
# todo: transitional, defensive, should not be needed.
# remove the begin/rescue logic after 1 Feb 2015
require Pathname(__FILE__).realpath.dirname.join("lib", "cask", "version")
HBC_VERSION = HOMEBREW_CASK_VERSION
end

# NOTE: Keep in sync with `find_ruby_2_plus` in `/bin/brew-cask`.
class Ruby20Requirement < Requirement
fatal true
default_formula "ruby"

satisfy :build_env => false do
result = false
favorite_ruby =
"/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby"

if File.executable?(favorite_ruby)
result = true
else
rubies = `/usr/bin/type -aP ruby`.split("\n")
rubies += [
"/usr/local/bin/ruby",
"#{`brew --repository 2>/dev/null`.strip}/bin/ruby",
]

rubies.uniq.each do |ruby|
version = /\d\.\d/.match(`#{ruby} --version 2>/dev/null`)

if version && Version.new(version.to_s) >= Version.new("2.0")
result = true
break
end
end
end

result
end

env do
ENV.prepend_path "PATH", which("ruby").dirname
end

def message; <<-EOS.undent
brew-cask needs Ruby >=2.0
EOS
end
end

class BrewCask < Formula
homepage "https://github.com/caskroom/homebrew-cask/"
url "https://github.com/caskroom/homebrew-cask.git", :tag => "v#{HBC_VERSION}"
head "https://github.com/caskroom/homebrew-cask.git", :branch => "master"

skip_clean "bin"
url "https://github.com/caskroom/homebrew-cask.git", :tag => "v0.60.0"

depends_on Ruby20Requirement
depends_on :ruby => "2.0"

def install
man1.install "doc/man/brew-cask.1"
prefix.install "lib" => "rubylib"
inreplace "bin/brew-cask", "/lib", "/rubylib"
end

prefix.install "Casks", "bin"
(bin+"brew-cask").chmod 0755
def caveats
<<-EOS.undent
You can uninstall this formula as `brew tap Caskroom/cask` is now all that's
needed to install Homebrew Cask and keep it up to date.
EOS
end

test do
system "#{bin}/brew-cask", "cask", "info", "google-chrome"
system "brew", "cask", "info", "google-chrome"
end
end
31 changes: 31 additions & 0 deletions cmd/brew-cask.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -EUTF-8:UTF-8
# encoding: UTF-8

# Ruby version check
unless RUBY_VERSION.split(".").first.to_i >= 2
alt_ruby = which "ruby"
alt_ruby_version = `#{alt_ruby} --version`.chomp[/\d\.\d/, 0] if alt_ruby

unless alt_ruby && alt_ruby_version.split(".").first.to_i >= 2
abort "Ruby 2.0 or above is required. You can install it with `brew install ruby`."
end

exec alt_ruby, "-W0", "-I#{HOMEBREW_LIBRARY_PATH}", "-rglobal", __FILE__, *ARGV
end

require 'pathname'

$LOAD_PATH.unshift(File.expand_path('../../lib', Pathname.new(__FILE__).realpath))

# todo remove internal Homebrew dependencies and remove this line
require 'vendor/homebrew-fork/global'

require 'hbc'

begin
Hbc::CLI.process(ARGV)
rescue Interrupt => e
puts
exit 130
end
exit 0
Loading