mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Add md5 on 'brew create' if we can figure it out.
This commit is contained in:
parent
ff03763931
commit
6586f89a29
@ -26,6 +26,7 @@ end
|
|||||||
|
|
||||||
def __make url, name
|
def __make url, name
|
||||||
require 'formula'
|
require 'formula'
|
||||||
|
require 'digest'
|
||||||
|
|
||||||
path = Formula.path name
|
path = Formula.path name
|
||||||
raise "#{path} already exists" if path.exist?
|
raise "#{path} already exists" if path.exist?
|
||||||
@ -45,13 +46,26 @@ def __make url, name
|
|||||||
puts "Version detected as #{version}."
|
puts "Version detected as #{version}."
|
||||||
end
|
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
|
template=<<-EOS
|
||||||
require 'formula'
|
require 'formula'
|
||||||
|
|
||||||
class #{Formula.class_s name} <Formula
|
class #{Formula.class_s name} <Formula
|
||||||
url '#{url}'
|
url '#{url}'
|
||||||
homepage ''
|
homepage ''
|
||||||
md5 ''
|
md5 '#{md5}'
|
||||||
|
|
||||||
cmake depends_on 'cmake'
|
cmake depends_on 'cmake'
|
||||||
|
|
||||||
|
@ -287,3 +287,19 @@ class BazaarDownloadStrategy <AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def detect_download_strategy url
|
||||||
|
case url
|
||||||
|
when %r[^cvs://] then CVSDownloadStrategy
|
||||||
|
when %r[^hg://] then MercurialDownloadStrategy
|
||||||
|
when %r[^svn://] then SubversionDownloadStrategy
|
||||||
|
when %r[^svn+http://] then SubversionDownloadStrategy
|
||||||
|
when %r[^git://] then GitDownloadStrategy
|
||||||
|
when %r[^bzr://] then BazaarDownloadStrategy
|
||||||
|
when %r[^https?://(.+?\.)?googlecode\.com/hg] then MercurialDownloadStrategy
|
||||||
|
when %r[^https?://(.+?\.)?googlecode\.com/svn] then SubversionDownloadStrategy
|
||||||
|
when %r[^https?://(.+?\.)?sourceforge\.net/svnroot/] then SubversionDownloadStrategy
|
||||||
|
when %r[^http://svn.apache.org/repos/] then SubversionDownloadStrategy
|
||||||
|
else CurlDownloadStrategy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -134,19 +134,7 @@ class Formula
|
|||||||
|
|
||||||
# reimplement if we don't autodetect the download strategy you require
|
# reimplement if we don't autodetect the download strategy you require
|
||||||
def download_strategy
|
def download_strategy
|
||||||
case url
|
detect_download_strategy url
|
||||||
when %r[^cvs://] then CVSDownloadStrategy
|
|
||||||
when %r[^hg://] then MercurialDownloadStrategy
|
|
||||||
when %r[^svn://] then SubversionDownloadStrategy
|
|
||||||
when %r[^svn+http://] then SubversionDownloadStrategy
|
|
||||||
when %r[^git://] then GitDownloadStrategy
|
|
||||||
when %r[^bzr://] then BazaarDownloadStrategy
|
|
||||||
when %r[^https?://(.+?\.)?googlecode\.com/hg] then MercurialDownloadStrategy
|
|
||||||
when %r[^https?://(.+?\.)?googlecode\.com/svn] then SubversionDownloadStrategy
|
|
||||||
when %r[^https?://(.+?\.)?sourceforge\.net/svnroot/] then SubversionDownloadStrategy
|
|
||||||
when %r[^http://svn.apache.org/repos/] then SubversionDownloadStrategy
|
|
||||||
else CurlDownloadStrategy
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# tell the user about any caveats regarding this package, return a string
|
# tell the user about any caveats regarding this package, return a string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user