diff options
| author | Adam Vandenberg | 2012-05-03 20:31:00 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2012-05-03 20:31:00 -0700 |
| commit | 19ed253b2df843c29de6de5cdf6b9e87c5ef32da (patch) | |
| tree | 8784dd95e38a1fa0b6097825e9ad96329784a49b | |
| parent | b4872a2f02bf6baa43bbcecec6db762edba49f04 (diff) | |
| download | homebrew-19ed253b2df843c29de6de5cdf6b9e87c5ef32da.tar.bz2 | |
Detect uncompressed tars
From a patch by @RuiPereira
Closes #12011.
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 30e9b0043..3fcb4f270 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -74,7 +74,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy when :zip quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @tarball_path chdir - when :gzip, :bzip2, :compress + when :gzip, :bzip2, :compress, :tar # Assume these are also tarred # TODO check if it's really a tar archive safe_system '/usr/bin/tar', 'xf', @tarball_path diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 515356861..f17209fa0 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -247,9 +247,10 @@ class Pathname # OS X installer package return :pkg if self.extname == '.pkg' - # get the first six bytes + # Get enough of the file to detect common file types + # POSIX tar magic has a 257 byte offset magic_bytes = nil - File.open(self) { |f| magic_bytes = f.read(6) } + File.open(self) { |f| magic_bytes = f.read(262) } # magic numbers stolen from /usr/share/file/magic/ case magic_bytes @@ -257,6 +258,7 @@ class Pathname when /^\037\213/ then :gzip when /^BZh/ then :bzip2 when /^\037\235/ then :compress + when /^.{257}ustar/ then :tar when /^\xFD7zXZ\x00/ then :xz when /^Rar!/ then :rar else |
