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

recast method destination_path as staged_path #6783

Merged
merged 1 commit into from
Oct 20, 2014
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
4 changes: 2 additions & 2 deletions doc/CASK_LANGUAGE_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ position at the end of the Cask:
| `title` | the Cask title
| `version` | the Cask version
| `homepage` | the Cask homepage
| `caskroom_path` | eg `/opt/homebrew-cask/Caskroom`
| `destination_path` | the staging location for this Cask, including version number, *eg* `/opt/homebrew-cask/Caskroom/adium/1.5.10`
| `caskroom_path` | the containing directory for all staged Casks, typically `/opt/homebrew-cask/Caskroom`
| `staged_path` | the staged location for this Cask, including version number, *eg* `/opt/homebrew-cask/Caskroom/adium/1.5.10`

Example:

Expand Down
9 changes: 7 additions & 2 deletions lib/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,16 @@ def caskroom_path
self.class.caskroom.join(title)
end

def destination_path
def staged_path
cask_version = version ? version : :unknown
caskroom_path.join(cask_version.to_s)
end

# todo transitional method, removeme after DSL 1.0
def destination_path
staged_path
end

def metadata_master_container_path
caskroom_path.join(self.class.metadata_subdir)
end
Expand Down Expand Up @@ -201,7 +206,7 @@ def metadata_subdir(leaf, timestamp=:latest, create=false)
end

def installed?
destination_path.exist?
staged_path.exist?
end

def to_s
Expand Down
4 changes: 2 additions & 2 deletions lib/cask/artifact/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def install_phase
To complete the installation of Cask #{@cask}, you must also
run the installer at

'#{@cask.destination_path.join(artifact.manual)}'
'#{@cask.staged_path.join(artifact.manual)}'

EOS
else
Expand All @@ -29,7 +29,7 @@ def install_phase
)
ohai "Running #{self.class.artifact_dsl_key} script #{executable}"
raise CaskInvalidError.new(@cask, "#{self.class.artifact_dsl_key} missing executable") if executable.nil?
@command.run(@cask.destination_path.join(executable), script_arguments)
@command.run(@cask.staged_path.join(executable), script_arguments)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/artifact/nested_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def uninstall_phase
end

def extract(container_relative_path)
source = @cask.destination_path.join(container_relative_path)
source = @cask.staged_path.join(container_relative_path)
container = Cask::Container.for_path(source, @command)
unless container
raise CaskError.new "Aw dang, could not identify nested container at '#{source}'"
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/artifact/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run_installer(pkg_description)
load_pkg_description pkg_description
ohai "Running installer for #{@cask}; your password may be necessary."
ohai "Package installers may write to any location; options such as --appdir are ignored."
source = @cask.destination_path.join(pkg_relative_path)
source = @cask.staged_path.join(pkg_relative_path)
unless source.exist?
raise CaskError.new "pkg source file not found: '#{source}'"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/artifact/symlinked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def summary
def load_specification(artifact_spec)
source_string, target_hash = artifact_spec
raise CaskInvalidError if source_string.nil?
@source = @cask.destination_path.join(source_string)
@source = @cask.staged_path.join(source_string)
if target_hash
raise CaskInvalidError unless target_hash.respond_to?(:keys)
target_hash.assert_valid_keys(:target)
Expand Down
4 changes: 2 additions & 2 deletions lib/cask/artifact/uninstall_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def dispatch_uninstall_directives(stanza, expand_tilde=false)

ohai "Running uninstall script #{executable}"
raise CaskInvalidError.new(@cask, "#{stanza} :early_script without :executable") if executable.nil?
@command.run(@cask.destination_path.join(executable), script_arguments)
@command.run(@cask.staged_path.join(executable), script_arguments)
sleep 1
end

Expand Down Expand Up @@ -274,7 +274,7 @@ def dispatch_uninstall_directives(stanza, expand_tilde=false)
{:sudo => true, :print_stdout => true},
:script)
raise CaskInvalidError.new(@cask, "#{stanza} :script without :executable.") if executable.nil?
@command.run(@cask.destination_path.join(executable), script_arguments)
@command.run(@cask.staged_path.join(executable), script_arguments)
sleep 1
end

Expand Down
9 changes: 7 additions & 2 deletions lib/cask/caveats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ def caskroom_path
@cask.class.caskroom.join(title)
end

def destination_path
def staged_path
caskroom_path.join(@cask.version.to_s)
end

# todo transitional method, removeme after DSL 1.0
def destination_path
staged_path
end

# DSL. Each method should handle output, following the convention of
# at least one trailing blank line so that the user can distinguish
# separate caveats.
Expand All @@ -50,7 +55,7 @@ def manual_installer(path)
To complete the installation of Cask #{@cask}, you must also
run the installer at

'#{destination_path.join(path)}'
'#{staged_path.join(path)}'

EOS
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/cli/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.help

def self.info(cask)
installation = if cask.installed?
"#{cask.destination_path} (#{cask.destination_path.cabv})"
"#{cask.staged_path} (#{cask.staged_path.cabv})"
else
"Not installed"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/container/air.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def self._installer_pathname

def extract
@command.run!(self.class.installer_cmd,
:args => ['-silent', '-location', @cask.destination_path, Pathname.new(@path).realpath])
:args => ['-silent', '-location', @cask.staged_path, Pathname.new(@path).realpath])
end
end
8 changes: 4 additions & 4 deletions lib/cask/container/bzip2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ def self.me?(criteria)
end

def extract
Dir.mktmpdir do |staging_dir|
@command.run!('/usr/bin/ditto', :args => ['--', @path, staging_dir])
@command.run!('/usr/bin/bunzip2', :args => ['-q', '--', Pathname(staging_dir).join(@path.basename)])
@command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path])
Dir.mktmpdir do |unpack_dir|
@command.run!('/usr/bin/ditto', :args => ['--', @path, unpack_dir])
@command.run!('/usr/bin/bunzip2', :args => ['-q', '--', Pathname(unpack_dir).join(@path.basename)])
@command.run!('/usr/bin/ditto', :args => ['--', unpack_dir, @cask.staged_path])
end
end
end
6 changes: 3 additions & 3 deletions lib/cask/container/cab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def extract
if ! Pathname.new(cabextract).exist?
raise CaskError.new "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on :formula => 'cabextract'"
end
Dir.mktmpdir do |staging_dir|
@command.run!(cabextract, :args => ['-d', staging_dir, '--', @path])
@command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path])
Dir.mktmpdir do |unpack_dir|
@command.run!(cabextract, :args => ['-d', unpack_dir, '--', @path])
@command.run!('/usr/bin/ditto', :args => ['--', unpack_dir, @cask.staged_path])
end
end
end
2 changes: 1 addition & 1 deletion lib/cask/container/dmg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def extract
# - or support some type of text filter to be passed to
# :print_stderr instead of true/false
:print_stderr => false,
:args => ['--', mount, @cask.destination_path])
:args => ['--', mount, @cask.staged_path])
end
ensure
eject!
Expand Down
6 changes: 3 additions & 3 deletions lib/cask/container/generic_unar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def extract
if ! Pathname.new(unar).exist?
raise CaskError.new "Expected to find unar executable. Cask #{@cask} must add: depends_on :formula => 'unar'"
end
Dir.mktmpdir do |staging_dir|
@command.run!(unar, :args => ['-q', '-D', '-o', staging_dir, '--', @path])
@command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path])
Dir.mktmpdir do |unpack_dir|
@command.run!(unar, :args => ['-q', '-D', '-o', unpack_dir, '--', @path])
@command.run!('/usr/bin/ditto', :args => ['--', unpack_dir, @cask.staged_path])
end
end
end
8 changes: 4 additions & 4 deletions lib/cask/container/gzip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def self.me?(criteria)
end

def extract
Dir.mktmpdir do |staging_dir|
@command.run!('/usr/bin/ditto', :args => ['--', @path, staging_dir])
@command.run!('/usr/bin/gunzip', :args => ['-q', '--', Pathname(staging_dir).join(@path.basename)])
@command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path])
Dir.mktmpdir do |unpack_dir|
@command.run!('/usr/bin/ditto', :args => ['--', @path, unpack_dir])
@command.run!('/usr/bin/gunzip', :args => ['-q', '--', Pathname(unpack_dir).join(@path.basename)])
@command.run!('/usr/bin/ditto', :args => ['--', unpack_dir, @cask.staged_path])
end
end
end
2 changes: 1 addition & 1 deletion lib/cask/container/naked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def self.me?(criteria)
end

def extract
@command.run!('/usr/bin/ditto', :args => ['--', @path, @cask.destination_path.join(target_file)])
@command.run!('/usr/bin/ditto', :args => ['--', @path, @cask.staged_path.join(target_file)])
end

def target_file
Expand Down
6 changes: 3 additions & 3 deletions lib/cask/container/tar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def self.me?(criteria)
end

def extract
Dir.mktmpdir do |staging_dir|
@command.run!('/usr/bin/tar', :args => ['xf', @path, '-C', staging_dir])
@command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path])
Dir.mktmpdir do |unpack_dir|
@command.run!('/usr/bin/tar', :args => ['xf', @path, '-C', unpack_dir])
@command.run!('/usr/bin/ditto', :args => ['--', unpack_dir, @cask.staged_path])
end
end
end
6 changes: 3 additions & 3 deletions lib/cask/container/xar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def self.me?(criteria)
end

def extract
Dir.mktmpdir do |staging_dir|
@command.run!('/usr/bin/xar', :args => ['-xf', @path, '-C', staging_dir])
@command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path])
Dir.mktmpdir do |unpack_dir|
@command.run!('/usr/bin/xar', :args => ['-xf', @path, '-C', unpack_dir])
@command.run!('/usr/bin/ditto', :args => ['--', unpack_dir, @cask.staged_path])
end
end
end
2 changes: 1 addition & 1 deletion lib/cask/container/zip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ def self.me?(criteria)
end

def extract
@command.run!('/usr/bin/ditto', :args => ['-xk', '--', @path, @cask.destination_path])
@command.run!('/usr/bin/ditto', :args => ['-xk', '--', @path, @cask.staged_path])
end
end
7 changes: 6 additions & 1 deletion lib/cask/dsl/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def caskroom_path
@cask.class.caskroom.join(title)
end

def destination_path
def staged_path
caskroom_path.join(@cask.version.to_s)
end

# todo transitional method, removeme after DSL 1.0
def destination_path
staged_path
end
end
6 changes: 3 additions & 3 deletions lib/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def summary
else
"#{Tty.blue}==>#{Tty.white} Success!#{Tty.reset} "
end
s << "#{@cask} installed to '#{@cask.destination_path}' (#{@cask.destination_path.cabv})"
s << "#{@cask} installed to '#{@cask.staged_path}' (#{@cask.staged_path.cabv})"
end

def download
Expand All @@ -76,7 +76,7 @@ def download

def extract_primary_container
odebug "Extracting primary container"
FileUtils.mkdir_p @cask.destination_path
FileUtils.mkdir_p @cask.staged_path
container = if @cask.container_type
Cask::Container.from_type(@cask.container_type)
else
Expand Down Expand Up @@ -172,7 +172,7 @@ def purge_versioned_files
odebug "Purging files for version #{@cask.version} of Cask #{@cask}"

# versioned staged distribution
permissions_rmtree(@cask.destination_path)
permissions_rmtree(@cask.staged_path)

# Homebrew-cask metadata
if @cask.metadata_versioned_container_path.respond_to?(:children) and
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/pretty_listing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ def initialize(cask)
end

def print
::PrettyListing.new(cask.destination_path)
::PrettyListing.new(cask.staged_path)
end
end
2 changes: 1 addition & 1 deletion lib/cask/staged.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Cask::Staged
def info_plist
"#{destination_path}/#{@cask.artifacts[:link].first.first}/Contents/Info.plist"
"#{staged_path}/#{@cask.artifacts[:link].first.first}/Contents/Info.plist"
end

def plist_exec(cmd)
Expand Down
7 changes: 6 additions & 1 deletion lib/cask/without_source.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
class Cask::WithoutSource < Cask
def destination_path
def staged_path
caskroom_path.children.first
end

# todo transitional method, removeme after DSL 1.0
def destination_path
staged_path
end

def to_s
"#{title} (!)"
end
Expand Down
6 changes: 3 additions & 3 deletions test/cask/artifact/alt_target_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
TestHelper.install_without_artifacts(cask)
end

appsubdir = (subdir_cask.destination_path/'subdir').tap(&:mkpath)
FileUtils.mv((subdir_cask.destination_path/'Caffeine.app'), appsubdir)
appsubdir = (subdir_cask.staged_path/'subdir').tap(&:mkpath)
FileUtils.mv((subdir_cask.staged_path/'Caffeine.app'), appsubdir)

shutup do
Cask::Artifact::App.new(subdir_cask).install_phase
Expand All @@ -67,7 +67,7 @@
it "only uses linkables when they are specified" do
cask = local_alt_caffeine

app_path = cask.destination_path.join('Caffeine.app')
app_path = cask.staged_path.join('Caffeine.app')
FileUtils.cp_r app_path, app_path.sub('Caffeine.app', 'CaffeineAgain.app')

shutup do
Expand Down
6 changes: 3 additions & 3 deletions test/cask/artifact/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
TestHelper.install_without_artifacts(cask)
end

appsubdir = (subdir_cask.destination_path/'subdir').tap(&:mkpath)
FileUtils.mv((subdir_cask.destination_path/'Caffeine.app'), appsubdir)
appsubdir = (subdir_cask.staged_path/'subdir').tap(&:mkpath)
FileUtils.mv((subdir_cask.staged_path/'Caffeine.app'), appsubdir)

shutup do
Cask::Artifact::App.new(subdir_cask).install_phase
Expand All @@ -53,7 +53,7 @@
it "only uses linkables when they are specified" do
cask = local_caffeine

app_path = cask.destination_path.join('Caffeine.app')
app_path = cask.staged_path.join('Caffeine.app')
FileUtils.cp_r app_path, app_path.sub('Caffeine.app', 'CaffeineAgain.app')

shutup do
Expand Down
2 changes: 1 addition & 1 deletion test/cask/artifact/nested_container_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Cask::Artifact::NestedContainer.new(cask).install_phase
end

cask.destination_path.join('MyNestedApp.app').must_be :directory?
cask.staged_path.join('MyNestedApp.app').must_be :directory?
end
end
end
2 changes: 1 addition & 1 deletion test/cask/artifact/pkg_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
it 'runs the system installer on the specified pkgs' do
pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand)

Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/installer', '-pkg', @cask.destination_path/'MyFancyPkg'/'Fancy.pkg', '-target', '/'])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/installer', '-pkg', @cask.staged_path/'MyFancyPkg'/'Fancy.pkg', '-target', '/'])

shutup do
pkg.install_phase
Expand Down
Loading