From 6586f89a29325d312a660cd80a3ea857c350e38a Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Mon, 22 Mar 2010 21:19:20 -0700 Subject: [PATCH] Add md5 on 'brew create' if we can figure it out. --- Library/Homebrew/brew.h.rb | 16 +++++++++++++++- Library/Homebrew/download_strategy.rb | 16 ++++++++++++++++ Library/Homebrew/formula.rb | 14 +------------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index b5b05ee1e2..ff091fea30 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -26,6 +26,7 @@ end def __make url, name require 'formula' + require 'digest' path = Formula.path name raise "#{path} already exists" if path.exist? @@ -45,13 +46,26 @@ def __make url, name puts "Version detected as #{version}." end + md5 = '' + if ARGV.include? "--cache" and version != nil + strategy = detect_download_strategy url + if strategy == CurlDownloadStrategy + d = strategy.new url, name, version, nil + the_tarball = d.fetch + md5 = Digest::MD5.hexdigest(the_tarball.read) + puts "MD5 is #{md5}" + else + puts "--cache requested, but we can only cache formulas that use Curl." + end + end + template=<<-EOS require 'formula' class #{Formula.class_s name}