Allow resource fetching

Closes Homebrew/homebrew#20047.
This commit is contained in:
Adam Vandenberg 2013-08-06 19:53:43 -07:00
parent d4cf3ef212
commit 809fc87da0

View File

@ -16,14 +16,36 @@ module Homebrew extend self
end end
puts "Fetching: #{bucket * ', '}" if bucket.size > 1 puts "Fetching: #{bucket * ', '}" if bucket.size > 1
bucket.each { |f| fetch_formula(f) } bucket.each do |f|
fetch_formula(f)
f.resources.each do |r|
fetch_resource(r)
end
end
end end
def already_fetched? f def already_fetched? f
f.cached_download.exist? f.cached_download.exist?
end end
def fetch_resource r
puts "Resource: #{r.name}"
fetch_fetchable r
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}"
end
def fetch_formula f def fetch_formula f
fetch_fetchable f
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
private
def fetch_fetchable f
f.cached_download.rmtree if already_fetched?(f) && ARGV.force? f.cached_download.rmtree if already_fetched?(f) && ARGV.force?
download = f.fetch download = f.fetch
@ -33,8 +55,5 @@ module Homebrew extend self
puts Checksum::TYPES.map { |t| "#{t.to_s.upcase}: #{download.send(t)}" } puts Checksum::TYPES.map { |t| "#{t.to_s.upcase}: #{download.send(t)}" }
f.verify_download_integrity(download) f.verify_download_integrity(download)
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end end
end end