2013-07-27 02:54:40 +08:00
|
|
|
HOMEBREW_CACHE_CASKS = HOMEBREW_CACHE.join('Casks')
|
|
|
|
|
2012-03-05 10:46:30 +08:00
|
|
|
class Cask; end
|
|
|
|
|
2014-01-11 00:42:18 +08:00
|
|
|
require 'download_strategy'
|
|
|
|
|
2013-09-23 22:32:46 +08:00
|
|
|
require 'cask/artifact'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/audit'
|
|
|
|
require 'cask/auditor'
|
2013-12-06 09:38:23 +08:00
|
|
|
require 'cask/without_source'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/checkable'
|
|
|
|
require 'cask/cli'
|
2014-01-15 06:41:11 +08:00
|
|
|
require 'cask/caveats'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/container'
|
|
|
|
require 'cask/download'
|
2013-12-06 03:26:56 +08:00
|
|
|
require 'cask/download_strategy'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/dsl'
|
|
|
|
require 'cask/exceptions'
|
|
|
|
require 'cask/fetcher'
|
|
|
|
require 'cask/installer'
|
|
|
|
require 'cask/link_checker'
|
2013-09-23 22:32:46 +08:00
|
|
|
require 'cask/locations'
|
2014-01-06 04:30:53 +08:00
|
|
|
require 'cask/options'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/pkg'
|
2013-11-04 02:23:08 +08:00
|
|
|
require 'cask/pretty_listing'
|
2014-01-04 20:14:35 +08:00
|
|
|
require 'cask/qualified_cask_name'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/scopes'
|
2013-11-17 03:40:51 +08:00
|
|
|
require 'cask/source'
|
2013-09-22 10:44:49 +08:00
|
|
|
require 'cask/system_command'
|
2013-09-22 06:07:19 +08:00
|
|
|
require 'cask/underscore_supporting_uri'
|
2013-12-16 03:18:47 +08:00
|
|
|
require 'cask/url'
|
2014-01-23 07:29:00 +08:00
|
|
|
require 'cask/utils'
|
2014-01-29 23:00:13 +08:00
|
|
|
require 'cask/version'
|
2013-09-22 10:44:49 +08:00
|
|
|
|
|
|
|
require 'plist/parser'
|
2012-03-05 10:46:30 +08:00
|
|
|
|
|
|
|
class Cask
|
2012-10-14 05:30:59 +08:00
|
|
|
include Cask::DSL
|
2013-09-23 22:32:46 +08:00
|
|
|
include Cask::Locations
|
2012-10-14 05:48:25 +08:00
|
|
|
include Cask::Scopes
|
2014-01-06 04:30:53 +08:00
|
|
|
include Cask::Options
|
2012-10-14 05:17:52 +08:00
|
|
|
|
2012-03-05 10:46:30 +08:00
|
|
|
def self.init
|
2014-01-23 07:29:00 +08:00
|
|
|
odebug 'Creating directories'
|
2012-10-16 08:25:35 +08:00
|
|
|
HOMEBREW_CACHE.mkpath unless HOMEBREW_CACHE.exist?
|
2013-04-07 06:14:04 +08:00
|
|
|
unless caskroom.exist?
|
|
|
|
ohai "We need to make Caskroom for the first time at #{caskroom}"
|
2013-05-27 23:35:44 +08:00
|
|
|
ohai "We'll set permissions properly so we won't need sudo in the future"
|
2013-04-07 06:14:04 +08:00
|
|
|
current_user = ENV['USER']
|
2014-01-09 03:22:32 +08:00
|
|
|
if caskroom.parent.writable?
|
2014-01-25 01:59:17 +08:00
|
|
|
system '/bin/mkdir', caskroom
|
2014-01-09 03:22:32 +08:00
|
|
|
else
|
|
|
|
# sudo in system is rude.
|
2014-01-25 09:40:38 +08:00
|
|
|
system '/usr/bin/sudo', '--', '/bin/mkdir', '-p', '--', caskroom
|
|
|
|
system '/usr/bin/sudo', '--', '/usr/sbin/chown', '-R', '--', "#{current_user}:staff", caskroom.parent
|
2014-01-09 03:22:32 +08:00
|
|
|
end
|
2013-04-07 06:14:04 +08:00
|
|
|
end
|
2012-10-16 08:25:35 +08:00
|
|
|
appdir.mkpath unless appdir.exist?
|
2013-11-29 08:45:49 +08:00
|
|
|
qlplugindir.mkpath unless qlplugindir.exist?
|
2014-01-28 23:17:50 +08:00
|
|
|
screen_saverdir.mkpath unless screen_saverdir.exist?
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
2013-11-17 03:40:51 +08:00
|
|
|
def self.load(query)
|
2014-01-23 07:29:00 +08:00
|
|
|
odebug 'Loading Cask definitions'
|
|
|
|
cask = Cask::Source.for_query(query).load
|
|
|
|
odumpcask cask
|
|
|
|
cask
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.title
|
2012-12-18 07:59:58 +08:00
|
|
|
self.name.gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').downcase
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
attr_reader :title
|
|
|
|
def initialize(title=self.class.title)
|
|
|
|
@title = title
|
|
|
|
end
|
|
|
|
|
2013-11-11 04:48:16 +08:00
|
|
|
def caskroom_path
|
2013-12-06 09:38:23 +08:00
|
|
|
self.class.caskroom.join(title)
|
2013-11-11 04:48:16 +08:00
|
|
|
end
|
|
|
|
|
2012-03-05 10:46:30 +08:00
|
|
|
def destination_path
|
2013-12-06 09:38:23 +08:00
|
|
|
caskroom_path.join(version)
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def installed?
|
2012-10-21 02:34:11 +08:00
|
|
|
destination_path.exist?
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
@title
|
|
|
|
end
|
|
|
|
end
|