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.
This commit is contained in:
parent
953f6c1ead
commit
69573ba7a2
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user