From ecfb175cdccec867c918e44e5f4e0fb3731566d1 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Thu, 27 Jun 2013 12:23:35 -0500 Subject: [PATCH] Fix :gzip_only extraction gunzip can only extract files in-place, so just shelling out to gunzip was actually leaving the uncompressed file in Homebrew's cache, not in the temporary directory. (It also destroyed the original compressed file.) --- Library/Homebrew/download_strategy.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index c7d6aeefb6..2d2fe1c289 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -103,7 +103,15 @@ class CurlDownloadStrategy < AbstractDownloadStrategy with_system_path { quiet_safe_system 'unzip', {:quiet_flag => '-qq'}, @tarball_path } chdir when :gzip_only - with_system_path { safe_system 'gunzip', '-f', @tarball_path } + # gunzip writes the compressed data in the location of the original, + # regardless of the current working directory; the only way to + # write elsewhere is to use the stdout + with_system_path do + data = `gunzip -f "#{@tarball_path}" -c` + File.open(File.basename(basename_without_params, '.gz'), 'w') do |f| + f.write data + end + end when :gzip, :bzip2, :compress, :tar # Assume these are also tarred # TODO check if it's really a tar archive