BottleLoader: check version mismatch
Closes Homebrew/homebrew#42049. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
602ea66a0f
commit
b1fff32055
@ -301,3 +301,13 @@ class DuplicateResourceError < ArgumentError
|
|||||||
super "Resource #{resource.inspect} is defined more than once"
|
super "Resource #{resource.inspect} is defined more than once"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class BottleVersionMismatchError < RuntimeError
|
||||||
|
def initialize bottle_file, bottle_version, formula, formula_version
|
||||||
|
super <<-EOS.undent
|
||||||
|
Bottle version mismatch
|
||||||
|
Bottle: #{bottle_file} (#{bottle_version})
|
||||||
|
Formula: #{formula.full_name} (#{formula_version})
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -90,6 +90,11 @@ class Formulary
|
|||||||
def get_formula(spec)
|
def get_formula(spec)
|
||||||
formula = super
|
formula = super
|
||||||
formula.local_bottle_path = @bottle_filename
|
formula.local_bottle_path = @bottle_filename
|
||||||
|
formula_version = formula.pkg_version
|
||||||
|
bottle_version = bottle_resolve_version(@bottle_filename)
|
||||||
|
unless formula_version == bottle_version
|
||||||
|
raise BottleVersionMismatchError.new(@bottle_filename, bottle_version, formula, formula_version)
|
||||||
|
end
|
||||||
formula
|
formula
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user