From ee354c9e194069d8e7a92df1cd941b857ee01b38 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 13 Mar 2014 19:51:23 -0500 Subject: New patch implementation and DSL This commit introduces a new patch implementation that supports checksums and caching. Patches are declared in blocks: patch do url ... sha1 ... end A strip level of -p1 is assumed. It can be overridden using a symbol argument: patch :p0 do url ... sha1 ... end Patches can be declared in stable, devel, and head blocks. This form is preferred over using conditionals. stable do # ... patch do url ... sha1 ... end end Embedded (__END__) patches are declared like so: patch :DATA patch :p0, :DATA Patches can also be embedded by passing a string. This makes it possible to provide multiple embedded patches while making only some of them conditional. patch :p0, "..." --- Library/Homebrew/software_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/software_spec.rb') diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 43969b2fa..0349dd3dd 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -5,12 +5,13 @@ require 'version' require 'build_options' require 'dependency_collector' require 'bottles' +require 'patch' class SoftwareSpec extend Forwardable - attr_reader :name - attr_reader :build, :resources, :owner + attr_reader :name, :owner + attr_reader :build, :resources, :patches attr_reader :dependency_collector attr_reader :bottle_specification @@ -25,6 +26,7 @@ class SoftwareSpec @build = BuildOptions.new(ARGV.options_only) @dependency_collector = DependencyCollector.new @bottle_specification = BottleSpecification.new + @patches = [] end def owner= owner @@ -35,6 +37,7 @@ class SoftwareSpec r.owner = self r.version ||= version end + patches.each { |p| p.owner = self } end def url val=nil, specs={} @@ -84,6 +87,10 @@ class SoftwareSpec def requirements dependency_collector.requirements end + + def patch strip=:p1, io=nil, &block + patches << Patch.create(strip, io, &block) + end end class HeadSoftwareSpec < SoftwareSpec -- cgit v1.2.3