Don't use file, just check the magic numbers instead
Closes Homebrew/homebrew#58
This commit is contained in:
parent
e339a2a73f
commit
ad01b141b7
@ -49,12 +49,15 @@ class HttpDownloadStrategy <AbstractDownloadStrategy
|
|||||||
return @dl # thus performs checksum verification
|
return @dl # thus performs checksum verification
|
||||||
end
|
end
|
||||||
def stage
|
def stage
|
||||||
case `file -b #{@dl}`
|
# magic numbers stolen from /usr/share/file/magic/
|
||||||
when /^Zip archive data/
|
File.open(@dl) do |f|
|
||||||
|
# get the first four bytes
|
||||||
|
case f.read(4)
|
||||||
|
when /^PK\003\004/ # .zip archive
|
||||||
safe_system '/usr/bin/unzip', '-qq', @dl
|
safe_system '/usr/bin/unzip', '-qq', @dl
|
||||||
chdir
|
chdir
|
||||||
when /^(gzip|bzip2) compressed data/
|
when /^\037\213/, /^BZh/ # gzip/bz2 compressed
|
||||||
# TODO do file -z now to see if it is in fact a tar
|
# TODO check if it's really a tar archive
|
||||||
safe_system '/usr/bin/tar', 'xf', @dl
|
safe_system '/usr/bin/tar', 'xf', @dl
|
||||||
chdir
|
chdir
|
||||||
else
|
else
|
||||||
@ -66,6 +69,7 @@ class HttpDownloadStrategy <AbstractDownloadStrategy
|
|||||||
FileUtils.mv @dl, File.basename(@url)
|
FileUtils.mv @dl, File.basename(@url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
private
|
private
|
||||||
def chdir
|
def chdir
|
||||||
entries=Dir['*']
|
entries=Dir['*']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user