2013-07-27 02:54:40 +08:00
|
|
|
HOMEBREW_CACHE_CASKS = HOMEBREW_CACHE.join('Casks')
|
|
|
|
|
2015-02-08 05:56:06 +08:00
|
|
|
module Hbc; end
|
2012-03-05 10:46:30 +08:00
|
|
|
|
2015-01-01 22:08:06 +08:00
|
|
|
require 'hbc/extend'
|
|
|
|
require 'hbc/artifact'
|
|
|
|
require 'hbc/audit'
|
|
|
|
require 'hbc/auditor'
|
2015-02-08 05:56:06 +08:00
|
|
|
require 'hbc/cask'
|
2015-01-01 22:08:06 +08:00
|
|
|
require 'hbc/without_source'
|
|
|
|
require 'hbc/checkable'
|
|
|
|
require 'hbc/cli'
|
|
|
|
require 'hbc/cask_dependencies'
|
|
|
|
require 'hbc/caveats'
|
|
|
|
require 'hbc/container'
|
|
|
|
require 'hbc/download'
|
|
|
|
require 'hbc/download_strategy'
|
|
|
|
require 'hbc/exceptions'
|
|
|
|
require 'hbc/fetcher'
|
|
|
|
require 'hbc/hardware'
|
|
|
|
require 'hbc/installer'
|
|
|
|
require 'hbc/locations'
|
|
|
|
require 'hbc/macos'
|
|
|
|
require 'hbc/options'
|
|
|
|
require 'hbc/pkg'
|
|
|
|
require 'hbc/pretty_listing'
|
|
|
|
require 'hbc/qualified_token'
|
|
|
|
require 'hbc/scopes'
|
|
|
|
require 'hbc/source'
|
|
|
|
require 'hbc/staged'
|
|
|
|
require 'hbc/system_command'
|
|
|
|
require 'hbc/topological_hash'
|
|
|
|
require 'hbc/underscore_supporting_uri'
|
|
|
|
require 'hbc/url'
|
|
|
|
require 'hbc/url_checker'
|
|
|
|
require 'hbc/utils'
|
2015-01-08 03:40:14 +08:00
|
|
|
require 'hbc/verify'
|
2015-01-01 22:08:06 +08:00
|
|
|
require 'hbc/version'
|
2013-09-22 10:44:49 +08:00
|
|
|
|
2014-12-21 02:23:10 +08:00
|
|
|
require 'vendor/plist'
|
2012-03-05 10:46:30 +08:00
|
|
|
|
2015-02-08 05:56:06 +08:00
|
|
|
module Hbc
|
2015-01-01 22:08:06 +08:00
|
|
|
include Hbc::Locations
|
|
|
|
include Hbc::Scopes
|
|
|
|
include Hbc::Options
|
|
|
|
include Hbc::Utils
|
2012-10-14 05:17:52 +08:00
|
|
|
|
2014-12-31 00:27:05 +08:00
|
|
|
# todo: restrict visibility of this to the DSL
|
2015-01-01 22:08:06 +08:00
|
|
|
::MacOS = Hbc::MacOS
|
|
|
|
::Hardware = Hbc::Hardware
|
2014-12-31 00:27:05 +08:00
|
|
|
|
2012-03-05 10:46:30 +08:00
|
|
|
def self.init
|
2014-10-04 20:23:28 +08:00
|
|
|
# todo: Creating directories should be deferred until needed.
|
|
|
|
# Currently this fire and even asks for sudo password
|
|
|
|
# if a first-time user simply runs "brew cask --help".
|
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?
|
2014-02-05 22:57:35 +08:00
|
|
|
HOMEBREW_CACHE_CASKS.mkpath unless HOMEBREW_CACHE_CASKS.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"
|
2014-02-21 22:30:37 +08:00
|
|
|
current_user = Etc.getpwuid(Process.euid).name
|
2014-01-09 03:22:32 +08:00
|
|
|
if caskroom.parent.writable?
|
2014-09-10 01:16:44 +08:00
|
|
|
system '/bin/mkdir', '--', caskroom
|
2014-01-09 03:22:32 +08:00
|
|
|
else
|
2014-05-07 22:56:04 +08:00
|
|
|
toplevel_dir = caskroom
|
|
|
|
toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root?
|
|
|
|
unless toplevel_dir.directory?
|
|
|
|
# If a toplevel dir such as '/opt' must be created, enforce standard permissions.
|
|
|
|
# sudo in system is rude.
|
|
|
|
system '/usr/bin/sudo', '--', '/bin/mkdir', '--', toplevel_dir
|
|
|
|
system '/usr/bin/sudo', '--', '/bin/chmod', '--', '0775', toplevel_dir
|
|
|
|
end
|
2014-01-09 03:22:32 +08:00
|
|
|
# sudo in system is rude.
|
2014-01-25 09:40:38 +08:00
|
|
|
system '/usr/bin/sudo', '--', '/bin/mkdir', '-p', '--', caskroom
|
2014-05-07 22:56:04 +08:00
|
|
|
unless caskroom.parent == toplevel_dir
|
2014-12-15 02:53:07 +08:00
|
|
|
system '/usr/bin/sudo', '--', '/usr/sbin/chown', '-R', '--', "#{current_user}:staff", caskroom.parent.to_s
|
2014-05-07 22:56:04 +08:00
|
|
|
end
|
2014-01-09 03:22:32 +08:00
|
|
|
end
|
2013-04-07 06:14:04 +08:00
|
|
|
end
|
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'
|
2015-01-01 22:08:06 +08:00
|
|
|
cask = Hbc::Source.for_query(query).load
|
2014-06-18 20:33:24 +08:00
|
|
|
cask.dumpcask
|
2014-01-23 07:29:00 +08:00
|
|
|
cask
|
2012-03-05 10:46:30 +08:00
|
|
|
end
|
|
|
|
end
|