From cb5da28b5cdf7a76e9e1220e6701b4b905ce04a3 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sun, 6 Apr 2014 11:19:30 -0500 Subject: Handle untarred bzip2 files Fixes Homebrew/homebrew#28187. --- Library/Homebrew/download_strategy.rb | 11 +++++++++++ Library/Homebrew/extend/pathname.rb | 2 ++ 2 files changed, 13 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 479365c98..116d53b79 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -157,6 +157,17 @@ class CurlDownloadStrategy < AbstractDownloadStrategy end end end + when :bzip2_only + with_system_path do + target = File.basename(basename_without_params, ".bz2") + + IO.popen("bunzip2 -f '#{tarball_path}' -c") do |pipe| + File.open(target, "wb") do |f| + buf = "" + f.write(buf) while pipe.read(1024, buf) + end + end + end when :gzip, :bzip2, :compress, :tar # Assume these are also tarred # TODO check if it's really a tar archive diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 337afbfc9..b8868adfe 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -213,6 +213,8 @@ class Pathname # If the filename ends with .gz not preceded by .tar # then we want to gunzip but not tar return :gzip_only + when ".bz2" + return :bzip2_only end # Get enough of the file to detect common file types -- cgit v1.2.3