aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Contributions/cmd
diff options
context:
space:
mode:
authorCharlie Sharpsteen2014-04-29 10:35:49 -0700
committerCharlie Sharpsteen2014-04-29 10:46:02 -0700
commitb12444ba6e1ac1d596a70ff4c777d9386d0791ac (patch)
tree0b56372ff47bed89e5fb6ea30143845393871d67 /Library/Contributions/cmd
parent041a3ed9a9d62151d070adc410bec6247cb7a58f (diff)
downloadhomebrew-b12444ba6e1ac1d596a70ff4c777d9386d0791ac.tar.bz2
brew-unpack: Handle new style :DATA patches
Instances of `IOPatch` created by `patch :DATA` are not affected by re-setting the `DATA` constant of the `Formula` instance. For these patches, we iterate through the `patchlist` and use `instance_variable_set` to attach data. A bit hacky, but `patchlist` has no write accessors so there isn't a clean way to modify patch contents.
Diffstat (limited to 'Library/Contributions/cmd')
-rwxr-xr-xLibrary/Contributions/cmd/brew-unpack.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/Library/Contributions/cmd/brew-unpack.rb b/Library/Contributions/cmd/brew-unpack.rb
index c1ca26474..b5023f1a2 100755
--- a/Library/Contributions/cmd/brew-unpack.rb
+++ b/Library/Contributions/cmd/brew-unpack.rb
@@ -28,6 +28,7 @@ module UnpackPatch
return unless ARGV.flag? "--patch"
begin
+ # Silence complaints about re-setting constants.
old_verbose = $VERBOSE
$VERBOSE = nil
Formula.const_set "DATA", ScriptDataReader.load(path)
@@ -35,6 +36,14 @@ module UnpackPatch
$VERBOSE = old_verbose
end
+ # Legacy patches are fixed by setting Formula::DATA.
+ # Now, handle instances of IOPatch.
+ patchlist.select{|p| p.is_a? IOPatch}.each do |patch|
+ if patch.instance_variable_get(:@io) == :DATA
+ patch.instance_variable_set :@io, ScriptDataReader.load(path)
+ end
+ end
+
super
end
end