2011-03-12 09:40:10 -08:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
# Downloads the tarballs for the given formulae to the Cache
|
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
def fetch
|
2012-02-04 00:01:29 -06:00
|
|
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
|
|
|
|
2011-04-14 14:57:21 -07:00
|
|
|
if ARGV.include? '--deps'
|
|
|
|
bucket = []
|
|
|
|
ARGV.formulae.each do |f|
|
|
|
|
bucket << f
|
|
|
|
bucket << f.recursive_deps
|
|
|
|
end
|
2011-09-11 15:23:41 -07:00
|
|
|
|
2011-04-14 14:57:21 -07:00
|
|
|
bucket = bucket.flatten.uniq
|
|
|
|
else
|
|
|
|
bucket = ARGV.formulae
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "Fetching: #{bucket * ', '}" if bucket.size > 1
|
|
|
|
|
|
|
|
bucket.each do |f|
|
2012-04-02 21:03:34 -05:00
|
|
|
already_downloaded = f.cached_download.exist?
|
2012-04-05 21:11:14 -05:00
|
|
|
f.cached_download.rmtree if already_downloaded and ARGV.force?
|
|
|
|
|
2011-09-11 15:23:41 -07:00
|
|
|
the_tarball, _ = f.fetch
|
2011-03-12 09:40:10 -08:00
|
|
|
next unless the_tarball.kind_of? Pathname
|
|
|
|
|
2012-04-02 21:03:34 -05:00
|
|
|
puts "Downloaded to: #{the_tarball}" unless already_downloaded
|
2011-03-12 09:40:10 -08:00
|
|
|
puts "SHA1: #{the_tarball.sha1}"
|
2012-04-05 21:11:14 -05:00
|
|
|
puts "SHA256: #{the_tarball.sha2}"
|
2011-03-12 09:40:10 -08:00
|
|
|
|
2012-06-26 00:51:02 -05:00
|
|
|
begin
|
|
|
|
f.verify_download_integrity the_tarball
|
|
|
|
rescue ChecksumMismatchError => e
|
2012-09-02 16:26:51 -07:00
|
|
|
Homebrew.failed = true
|
2012-06-26 00:51:02 -05:00
|
|
|
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
|
2011-04-15 00:23:37 +02:00
|
|
|
end
|
2011-03-12 09:40:10 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|