diff options
| author | Jack Nagel | 2014-03-13 19:51:23 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-03-13 21:35:41 -0500 | 
| commit | bf6c6b233eb4b9c884b39e4adee20fb88c919bfb (patch) | |
| tree | 2b0b7444a0239b3c7cd96d81923075ec525acb25 | |
| parent | df6fc206559060b72a29462b674279231a12509c (diff) | |
| download | homebrew-bf6c6b233eb4b9c884b39e4adee20fb88c919bfb.tar.bz2 | |
Teach fetch to download patches
| -rw-r--r-- | Library/Homebrew/cmd/fetch.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/patch.rb | 6 | 
3 files changed, 19 insertions, 3 deletions
| diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index 9b3a88a15..9f485e667 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 3031da721..1f9c645d5 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/patch.rb b/Library/Homebrew/patch.rb index 64325e78d..27ce2d9c3 100644 --- a/Library/Homebrew/patch.rb +++ b/Library/Homebrew/patch.rb @@ -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) | 
