Skip to content

Commit

Permalink
exclude __MACOSX dir when unzipping
Browse files Browse the repository at this point in the history
should take care of Homebrew#222
  • Loading branch information
phinze committed Apr 28, 2013
1 parent 2b7b530 commit 0de91ed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def install(cask)
ohai "Success! #{cask} installed to #{cask.destination_path}"

unless cask.caveats.empty?
ohai 'Caveats', cask.caveats
ohai 'Caveats', cask.caveats
end
end

Expand Down Expand Up @@ -63,7 +63,7 @@ def _with_extracted_mountpoints(path)
elsif _zip?(path)
destdir = "/tmp/brewcask_#{@title}_extracted"
`mkdir -p '#{destdir}'`
`unzip -d '#{destdir}' '#{path}'`
`unzip -d '#{destdir}' '#{path}' -x '__MACOSX/*'`
begin
yield destdir
ensure
Expand Down
8 changes: 8 additions & 0 deletions test/cask/installer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
}, /Here are some things you might want to know/)
with_caveats.must_be :installed?
end

it "does not extract __MACOSX directories from zips" do
with_macosx_dir = Cask.load('with-macosx-dir')
shutup do
Cask::Installer.install(with_macosx_dir)
end
with_macosx_dir.destination_path.join('__MACOSX').wont_be :directory?
end
end

describe "uninstall" do
Expand Down
6 changes: 6 additions & 0 deletions test/support/Casks/with-macosx-dir.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class WithMacosxDir < TestCask
url TestHelper.local_binary('MyFancyApp.zip')
homepage 'http://example.com/MyFancyApp'
version '1.2.3'
sha1 'b0475c34136c8e00ceb4b95c245291d53d5deab3'
end
Binary file added test/support/binaries/MyFancyApp.zip
Binary file not shown.

0 comments on commit 0de91ed

Please sign in to comment.