41 lines
994 B
Ruby
Raw Normal View History

2011-03-12 09:40:10 -08:00
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
2012-04-05 21:11:14 -05:00
def fetch_formula f
f.cached_download.rmtree if already_fetched?(f) && ARGV.force?
download = f.fetch
2011-03-12 09:40:10 -08:00
return unless download.file?
2011-03-12 09:40:10 -08:00
2013-05-16 14:06:26 -05:00
puts "Downloaded to: #{download}" unless already_fetched?(f)
puts Checksum::TYPES.map { |t| "#{t.to_s.upcase}: #{download.send(t)}" }
2013-05-16 14:06:26 -05:00
f.verify_download_integrity(download)
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
2011-03-12 09:40:10 -08:00
end
end