From d47cf55f68fb1d381cfbdc9de905dc33c7ce5a83 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 18 Mar 2012 15:14:14 +1300 Subject: [PATCH] Use fetch for downloading bottles. Fixes Homebrew/homebrew#10958. --- Library/Homebrew/cmd/fetch.rb | 14 ++++++++------ Library/Homebrew/formula.rb | 12 ++++++++---- Library/Homebrew/formula_installer.rb | 6 ++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index 5d1bec5291..28f51f71aa 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -29,21 +29,23 @@ module Homebrew extend self the_tarball, _ = f.fetch next unless the_tarball.kind_of? Pathname - previous_md5 = f.instance_variable_get(:@md5).to_s.downcase + bottle = install_bottle? f + + previous_md5 = f.instance_variable_get(:@md5).to_s.downcase unless bottle previous_sha1 = f.instance_variable_get(:@sha1).to_s.downcase - previous_sha2 = f.instance_variable_get(:@sha256).to_s.downcase + previous_sha2 = f.instance_variable_get(:@sha256).to_s.downcase unless bottle - puts "MD5: #{the_tarball.md5}" + puts "MD5: #{the_tarball.md5}" unless bottle puts "SHA1: #{the_tarball.sha1}" - puts "SHA256: #{the_tarball.sha2}" + puts "SHA256: #{the_tarball.sha2}" unless bottle - unless previous_md5.nil? or previous_md5.empty? or the_tarball.md5 == previous_md5 + unless previous_md5.nil? or previous_md5.empty? or the_tarball.md5 == previous_md5 or bottle opoo "Formula reports different MD5: #{previous_md5}" end unless previous_sha1.nil? or previous_sha1.empty? or the_tarball.sha1 == previous_sha1 opoo "Formula reports different SHA1: #{previous_sha1}" end - unless previous_sha2.nil? or previous_sha2.empty? or the_tarball.sha2 == previous_sha2 + unless previous_sha2.nil? or previous_sha2.empty? or the_tarball.sha2 == previous_sha2 or bottle opoo "Formula reports different SHA256: #{previous_sha2}" end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 8803166048..c26f0b3190 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -443,10 +443,14 @@ public # For brew-fetch and others. def fetch - downloader = @downloader - # Don't attempt mirrors if this install is not pointed at a "stable" URL. - # This can happen when options like `--HEAD` are invoked. - mirror_list = @spec_to_use == @standard ? mirrors : [] + if install_bottle? self + downloader = CurlBottleDownloadStrategy.new bottle_url, name, version, nil + else + downloader = @downloader + # Don't attempt mirrors if this install is not pointed at a "stable" URL. + # This can happen when options like `--HEAD` are invoked. + mirror_list = @spec_to_use == @standard ? mirrors : [] + end # Ensure the cache exists HOMEBREW_CACHE.mkpath diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 76618ad0c2..cd911b959b 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -253,10 +253,8 @@ class FormulaInstaller end def pour - HOMEBREW_CACHE.mkpath - downloader = CurlBottleDownloadStrategy.new f.bottle_url, f.name, f.version, nil - downloader.fetch - f.verify_download_integrity downloader.tarball_path, f.bottle_sha1, "SHA1" + fetched, downloader = f.fetch + f.verify_download_integrity fetched, f.bottle_sha1, "SHA1" HOMEBREW_CELLAR.cd do downloader.stage end