aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/patch.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/patch.rb')
-rw-r--r--Library/Homebrew/patch.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/Library/Homebrew/patch.rb b/Library/Homebrew/patch.rb
index a4616eee6..64325e78d 100644
--- a/Library/Homebrew/patch.rb
+++ b/Library/Homebrew/patch.rb
@@ -1,5 +1,6 @@
require 'resource'
require 'stringio'
+require 'erb'
class Patch
def self.create(strip, io=nil, &block)
@@ -22,6 +23,32 @@ class Patch
end
end
+ def self.normalize_legacy_patches(list)
+ patches = []
+
+ case list
+ when Hash
+ list
+ when Array, String, IO, StringIO
+ { :p1 => list }
+ else
+ {}
+ end.each_pair do |strip, urls|
+ urls = [urls] unless Array === urls
+ urls.each do |url|
+ case url
+ when IO, StringIO
+ patch = IOPatch.new(url, strip)
+ else
+ patch = LegacyPatch.new(strip, url)
+ end
+ patches << patch
+ end
+ end
+
+ patches
+ end
+
attr_reader :whence
def external?
@@ -80,3 +107,31 @@ class ExternalPatch < Patch
end
end
end
+
+# Legacy patches have no checksum and are not cached
+class LegacyPatch < ExternalPatch
+ def initialize(strip, url)
+ super(strip)
+ resource.url = url
+ end
+
+ def owner= owner
+ super
+ resource.name = "patch-#{ERB::Util.url_encode(resource.url)}"
+ end
+
+ def fetch
+ resource.clear_cache
+ super
+ end
+
+ def verify_download_integrity(fn)
+ # no-op
+ end
+
+ def apply
+ super
+ ensure
+ resource.clear_cache
+ end
+end