43 lines
1.1 KiB
Ruby
Raw Normal View History

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
raise FormulaUnspecifiedError if ARGV.named.empty?
if ARGV.include? '--deps'
bucket = []
ARGV.formulae.each do |f|
bucket << f
bucket << f.recursive_dependencies.map(&:to_formula)
end
bucket = bucket.flatten.uniq
else
bucket = ARGV.formulae
end
puts "Fetching: #{bucket * ', '}" if bucket.size > 1
bucket.each do |f|
already_downloaded = f.cached_download.exist?
2012-04-05 21:11:14 -05:00
f.cached_download.rmtree if already_downloaded and ARGV.force?
the_tarball, _ = f.fetch
2011-03-12 09:40:10 -08:00
next unless the_tarball.kind_of? Pathname
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
begin
f.verify_download_integrity the_tarball
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
2011-03-12 09:40:10 -08:00
end
end
end