diff options
| author | Ben Alpert | 2009-09-23 16:22:16 -0600 |
|---|---|---|
| committer | Ben Alpert | 2009-09-24 16:30:40 -0600 |
| commit | ad01b141b7cc884f10d8a2ddf760653787e4cdc9 (patch) | |
| tree | f8702ec2eba4a700637db442c68ce27f5765c64e /Library | |
| parent | e339a2a73ffa0e8e5a8d63ca49089a24ec2835e9 (diff) | |
| download | brew-ad01b141b7cc884f10d8a2ddf760653787e4cdc9.tar.bz2 | |
Don't use file, just check the magic numbers instead
Closes Homebrew/homebrew#58
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 58e5b197b..5d4afcdda 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -49,12 +49,15 @@ class HttpDownloadStrategy <AbstractDownloadStrategy return @dl # thus performs checksum verification end def stage - case `file -b #{@dl}` - when /^Zip archive data/ + # magic numbers stolen from /usr/share/file/magic/ + 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 chdir - when /^(gzip|bzip2) compressed data/ - # TODO do file -z now to see if it is in fact a tar + 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 @@ -64,6 +67,7 @@ class HttpDownloadStrategy <AbstractDownloadStrategy # 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 end end private |
