Detect uncompressed tars
From a patch by @RuiPereira Closes Homebrew/homebrew#12011.
This commit is contained in:
		
							parent
							
								
									fc77a38d03
								
							
						
					
					
						commit
						428781723b
					
				@ -74,7 +74,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
 | 
				
			|||||||
    when :zip
 | 
					    when :zip
 | 
				
			||||||
      quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @tarball_path
 | 
					      quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @tarball_path
 | 
				
			||||||
      chdir
 | 
					      chdir
 | 
				
			||||||
    when :gzip, :bzip2, :compress
 | 
					    when :gzip, :bzip2, :compress, :tar
 | 
				
			||||||
      # Assume these are also tarred
 | 
					      # Assume these are also tarred
 | 
				
			||||||
      # TODO check if it's really a tar archive
 | 
					      # TODO check if it's really a tar archive
 | 
				
			||||||
      safe_system '/usr/bin/tar', 'xf', @tarball_path
 | 
					      safe_system '/usr/bin/tar', 'xf', @tarball_path
 | 
				
			||||||
 | 
				
			|||||||
@ -247,9 +247,10 @@ class Pathname
 | 
				
			|||||||
    # OS X installer package
 | 
					    # OS X installer package
 | 
				
			||||||
    return :pkg if self.extname == '.pkg'
 | 
					    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
 | 
					    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/
 | 
					    # magic numbers stolen from /usr/share/file/magic/
 | 
				
			||||||
    case magic_bytes
 | 
					    case magic_bytes
 | 
				
			||||||
@ -257,6 +258,7 @@ class Pathname
 | 
				
			|||||||
    when /^\037\213/     then :gzip
 | 
					    when /^\037\213/     then :gzip
 | 
				
			||||||
    when /^BZh/          then :bzip2
 | 
					    when /^BZh/          then :bzip2
 | 
				
			||||||
    when /^\037\235/     then :compress
 | 
					    when /^\037\235/     then :compress
 | 
				
			||||||
 | 
					    when /^.{257}ustar/  then :tar
 | 
				
			||||||
    when /^\xFD7zXZ\x00/ then :xz
 | 
					    when /^\xFD7zXZ\x00/ then :xz
 | 
				
			||||||
    when /^Rar!/         then :rar
 | 
					    when /^Rar!/         then :rar
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user