brew-unpack: use extend instead of reopening Formula
This commit is contained in:
parent
d965bbba47
commit
fba5bf85b0
@ -23,24 +23,19 @@ module ScriptDataReader
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Need to tweak the Formula class slightly so that patching is option and `DATA`
|
module UnpackPatch
|
||||||
# patches work correctly.
|
|
||||||
class Formula
|
|
||||||
# Create a reference to the original Formula.patch method and then override
|
|
||||||
# so that paching only happens if the user asks.
|
|
||||||
alias do_patch patch
|
|
||||||
def patch
|
def patch
|
||||||
if ARGV.flag? '--patch'
|
return unless ARGV.flag? "--patch"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
old_verbose = $VERBOSE
|
old_verbose = $VERBOSE
|
||||||
$VERBOSE = nil
|
$VERBOSE = nil
|
||||||
Formula.const_set 'DATA', ScriptDataReader.load(path)
|
Formula.const_set "DATA", ScriptDataReader.load(path)
|
||||||
ensure
|
ensure
|
||||||
$VERBOSE = old_verbose
|
$VERBOSE = old_verbose
|
||||||
end
|
end
|
||||||
|
|
||||||
do_patch
|
super
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -74,6 +69,8 @@ module Homebrew extend self
|
|||||||
raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?
|
raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?
|
||||||
|
|
||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
|
f.extend(UnpackPatch)
|
||||||
|
|
||||||
# Create a nice name for the stage folder.
|
# Create a nice name for the stage folder.
|
||||||
stage_dir = unpack_dir + [f.name, f.version].join('-')
|
stage_dir = unpack_dir + [f.name, f.version].join('-')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user