diff options
| author | Max Howell | 2009-12-21 18:29:13 +0000 |
|---|---|---|
| committer | Max Howell | 2009-12-21 18:39:01 +0000 |
| commit | 07cd2877b2ef0a3c06022289f1744c7214e07fef (patch) | |
| tree | e8b2d85a9eca57be27ef92f13e5382df6eecd1fc /Library | |
| parent | f3a314fd2b7b3e2c09d1b1f3a7e08fa1a67ce7a3 (diff) | |
| download | homebrew-07cd2877b2ef0a3c06022289f1744c7214e07fef.tar.bz2 | |
If the download is a .jar, don't unzip it
Also remove special casing for two existing jar formula.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Formula/jython.rb | 4 | ||||
| -rw-r--r-- | Library/Formula/sbt.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 40 |
3 files changed, 23 insertions, 25 deletions
diff --git a/Library/Formula/jython.rb b/Library/Formula/jython.rb index 7e257a228..b554954aa 100644 --- a/Library/Formula/jython.rb +++ b/Library/Formula/jython.rb @@ -6,10 +6,6 @@ class Jython <Formula homepage 'http://www.jython.org' md5 '2ee978eff4306b23753b3fe9d7af5b37' - def download_strategy - NoUnzipCurlDownloadStrategy # Don't unzip jar. - end - def install system "java", "-jar", JAR, "-s", "-d", prefix end diff --git a/Library/Formula/sbt.rb b/Library/Formula/sbt.rb index 07da98760..89790e98a 100644 --- a/Library/Formula/sbt.rb +++ b/Library/Formula/sbt.rb @@ -6,10 +6,6 @@ class Sbt <Formula homepage 'http://code.google.com/p/simple-build-tool' md5 'e3593448b3be17ce1666c6241b8d2f90' - def download_strategy - NoUnzipCurlDownloadStrategy # Don't unzip jar. - end - def install (bin+'sbt').write <<-EOS #!/bin/sh diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index fc66e09dd..134fbe2fd 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -75,24 +75,30 @@ class CurlDownloadStrategy <AbstractDownloadStrategy def stage # 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 - case f.read(4) - when /^PK\003\004/ # .zip archive - quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @dl - chdir - when /^\037\213/, /^BZh/ # gzip/bz2 compressed - # TODO check if it's really a tar archive - safe_system '/usr/bin/tar', 'xf', @dl - chdir - else - # we are assuming it is not an archive, use original filename - # this behaviour is due to ScriptFileFormula expectations - # So I guess we should cp, but we mv, for this historic reason - # HOWEVER if this breaks some expectation you had we *will* change the - # behaviour, just open an issue at github - FileUtils.mv @dl, File.basename(@url) - end + File.open(@dl) { |f| magic_bytes = f.read(4) } + end + + case magic_bytes + when /^PK\003\004/ # .zip archive + quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @dl + chdir + when /^\037\213/, /^BZh/ # gzip/bz2 compressed + # TODO check if it's really a tar archive + safe_system '/usr/bin/tar', 'xf', @dl + chdir + else + # we are assuming it is not an archive, use original filename + # this behaviour is due to ScriptFileFormula expectations + # So I guess we should cp, but we mv, for this historic reason + # 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 |
