If the download is a .jar, don't unzip it
Also remove special casing for two existing jar formula.
This commit is contained in:
parent
d3fe4a8acc
commit
6e485cc9b1
@ -75,24 +75,30 @@ class CurlDownloadStrategy <AbstractDownloadStrategy
|
|||||||
|
|
||||||
def stage
|
def stage
|
||||||
# magic numbers stolen from /usr/share/file/magic/
|
# magic numbers stolen from /usr/share/file/magic/
|
||||||
File.open(@dl) do |f|
|
if @dl.extname == '.jar'
|
||||||
|
magic_bytes = nil
|
||||||
|
else
|
||||||
# get the first four bytes
|
# get the first four bytes
|
||||||
case f.read(4)
|
File.open(@dl) { |f| magic_bytes = f.read(4) }
|
||||||
when /^PK\003\004/ # .zip archive
|
end
|
||||||
quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @dl
|
|
||||||
chdir
|
case magic_bytes
|
||||||
when /^\037\213/, /^BZh/ # gzip/bz2 compressed
|
when /^PK\003\004/ # .zip archive
|
||||||
# TODO check if it's really a tar archive
|
quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @dl
|
||||||
safe_system '/usr/bin/tar', 'xf', @dl
|
chdir
|
||||||
chdir
|
when /^\037\213/, /^BZh/ # gzip/bz2 compressed
|
||||||
else
|
# TODO check if it's really a tar archive
|
||||||
# we are assuming it is not an archive, use original filename
|
safe_system '/usr/bin/tar', 'xf', @dl
|
||||||
# this behaviour is due to ScriptFileFormula expectations
|
chdir
|
||||||
# So I guess we should cp, but we mv, for this historic reason
|
else
|
||||||
# HOWEVER if this breaks some expectation you had we *will* change the
|
# we are assuming it is not an archive, use original filename
|
||||||
# behaviour, just open an issue at github
|
# this behaviour is due to ScriptFileFormula expectations
|
||||||
FileUtils.mv @dl, File.basename(@url)
|
# So I guess we should cp, but we mv, for this historic reason
|
||||||
end
|
# HOWEVER if this breaks some expectation you had we *will* change the
|
||||||
|
# behaviour, just open an issue at github
|
||||||
|
# We also do this for jar files, as they are in fact zip files, but
|
||||||
|
# we don't want to unzip them
|
||||||
|
FileUtils.mv @dl, File.basename(@url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user