aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2011-03-12 09:40:10 -0800
committerAdam Vandenberg2011-03-12 11:55:11 -0800
commitfb85fbc6b61f5fdbf2807334fcdee1f3f2447471 (patch)
tree42dd750c4d38da65583493ec0ba0bb4637c73f8c /Library
parent8ef1c35db1f33011ea9f303ad27c5f7864216a77 (diff)
downloadhomebrew-fb85fbc6b61f5fdbf2807334fcdee1f3f2447471.tar.bz2
'brew fetch' now an official command
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/examples/brew-fetch.rb27
-rw-r--r--Library/Homebrew/cmd/fetch.rb30
2 files changed, 30 insertions, 27 deletions
diff --git a/Library/Contributions/examples/brew-fetch.rb b/Library/Contributions/examples/brew-fetch.rb
deleted file mode 100755
index 336dc839f..000000000
--- a/Library/Contributions/examples/brew-fetch.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# Downloads the tarballs for the given formulae to the Cache
-
-require 'formula'
-require 'fileutils'
-
-ARGV.formulae.each do |f|
- if ARGV.include? "--force" or ARGV.include? "-f"
- where_to = `brew --cache #{f.name}`.strip
- FileUtils.rm_rf where_to unless where_to.empty?
- end
-
- the_tarball = f.downloader.fetch
- next unless the_tarball.kind_of? Pathname
-
- previous_md5 = f.instance_variable_get(:@md5)
- previous_sha1 = f.instance_variable_get(:@sha1)
-
- puts "MD5: #{the_tarball.md5}"
- puts "SHA1: #{the_tarball.sha1}"
-
- unless previous_md5.nil? or the_tarball.md5 == previous_md5
- opoo "Formula reports different MD5: #{previous_md5}"
- end
- unless previous_sha1.nil? or the_tarball.sha1 == previous_sha1
- opoo "Formula reports different SHA1: #{previous_sha1}"
- end
-end
diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb
new file mode 100644
index 000000000..8ad3c7f7d
--- /dev/null
+++ b/Library/Homebrew/cmd/fetch.rb
@@ -0,0 +1,30 @@
+require 'formula'
+
+# Downloads the tarballs for the given formulae to the Cache
+
+module Homebrew extend self
+ def fetch
+ ARGV.formulae.each do |f|
+ if ARGV.include? "--force" or ARGV.include? "-f"
+ where_to = `brew --cache #{f.name}`.strip
+ FileUtils.rm_rf where_to unless where_to.empty?
+ end
+
+ the_tarball = f.downloader.fetch
+ next unless the_tarball.kind_of? Pathname
+
+ previous_md5 = f.instance_variable_get(:@md5)
+ previous_sha1 = f.instance_variable_get(:@sha1)
+
+ puts "MD5: #{the_tarball.md5}"
+ puts "SHA1: #{the_tarball.sha1}"
+
+ unless previous_md5.nil? or previous_md5.empty? or the_tarball.md5 == previous_md5
+ opoo "Formula reports different MD5: #{previous_md5}"
+ end
+ unless previous_sha1.nil? or previous_sha1.empty? or the_tarball.sha1 == previous_sha1
+ opoo "Formula reports different SHA1: #{previous_sha1}"
+ end
+ end
+ end
+end