Teach fetch to download patches

This commit is contained in:
Jack Nagel 2014-03-13 19:51:23 -05:00
parent 665b14c4a4
commit 86cdd812a2
3 changed files with 19 additions and 3 deletions

View File

@ -21,9 +21,8 @@ module Homebrew extend self
fetch_formula(f.bottle)
else
fetch_formula(f)
f.resources.each do |r|
fetch_resource(r)
end
f.resources.each { |r| fetch_resource(r) }
f.patchlist.select(&:external?).each { |p| fetch_patch(p) }
end
end
end
@ -51,6 +50,13 @@ module Homebrew extend self
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
def fetch_patch p
fetch_fetchable p
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Patch reports different #{e.hash_type}: #{e.expected}"
end
private
def retry_fetch? f

View File

@ -117,6 +117,10 @@ class Formula
active_spec.clear_cache
end
def patchlist
active_spec.patches
end
# if the dir is there, but it's empty we consider it not installed
def installed?
(dir = installed_prefix).directory? && dir.children.length > 0

View File

@ -1,6 +1,7 @@
require 'resource'
require 'stringio'
require 'erb'
require 'forwardable'
class Patch
def self.create(strip, io=nil, &block)
@ -80,8 +81,13 @@ class IOPatch < Patch
end
class ExternalPatch < Patch
extend Forwardable
attr_reader :resource, :strip
def_delegators :@resource, :fetch, :verify_download_integrity,
:cached_download, :clear_cache
def initialize(strip, &block)
@strip = strip
@resource = Resource.new(&block)