blob: cb0fd4660e08478c9123d6f3ace62ce35a26df9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
require 'formula'
module Homebrew extend self
def fetch
raise FormulaUnspecifiedError if ARGV.named.empty?
if ARGV.include? '--deps'
bucket = []
ARGV.formulae.each do |f|
bucket << f
bucket.concat f.recursive_dependencies.map(&:to_formula)
end
bucket.uniq!
else
bucket = ARGV.formulae
end
puts "Fetching: #{bucket * ', '}" if bucket.size > 1
bucket.each { |f| fetch_formula(f) }
end
def already_fetched? f
f.cached_download.exist?
end
def fetch_formula f
f.cached_download.rmtree if already_fetched?(f) && ARGV.force?
download, _ = f.fetch
# FIXME why are strategies returning different types?
return unless download.is_a? Pathname
puts "Downloaded to: #{download}" unless already_fetched?(f)
puts Checksum::TYPES.map { |t| "#{t.to_s.upcase}: #{download.send(t)}" }
f.verify_download_integrity(download)
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
end
|