From aff66c3b86e13e4e85277217c67623dff9da0ef5 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Sat, 8 Jun 2013 10:27:47 -0700 Subject: [PATCH] Sniff for non-tarred gzips Don't try to untar non-tarred gzips. --- Library/Homebrew/download_strategy.rb | 16 +++++----------- Library/Homebrew/extend/pathname.rb | 4 ++++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 5bdc7ebd0b..8e3bd81391 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -102,6 +102,8 @@ class CurlDownloadStrategy < AbstractDownloadStrategy when :zip 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 } when :gzip, :bzip2, :compress, :tar # Assume these are also tarred # TODO check if it's really a tar archive @@ -197,17 +199,9 @@ class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy end end -# Normal strategy tries to untar as well -class GzipOnlyDownloadStrategy < CurlDownloadStrategy - def stage - FileUtils.mv @tarball_path, basename - with_system_path { safe_system 'gunzip', '-f', basename_without_params } - end -end - -# This Download Strategy is provided for use with sites that -# only provide HTTPS and also have a broken cert. -# Try not to need this, as we probably won't accept the formula. +# This strategy is provided for use with sites that only provide HTTPS and +# also have a broken cert. Try not to need this, as we probably won't accept +# the formula. class CurlUnsafeDownloadStrategy < CurlDownloadStrategy def _fetch curl @url, '--insecure', '-C', downloaded_size, '-o', @temporary_path diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 25bb1e537f..b6a47d5204 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -177,6 +177,10 @@ class Pathname # OS X installer package return :pkg if self.extname == '.pkg' + # If the filename ends with .gz not preceded by .tar + # then we want to gunzip but not tar + return :gzip_only if self.extname == '.gz' + # Get enough of the file to detect common file types # POSIX tar magic has a 257 byte offset # magic numbers stolen from /usr/share/file/magic/