BottleLoader: check version mismatch

Closes Homebrew/homebrew#42049.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-07-23 14:09:32 +08:00
parent 602ea66a0f
commit b1fff32055
2 changed files with 15 additions and 0 deletions

View File

@ -301,3 +301,13 @@ class DuplicateResourceError < ArgumentError
super "Resource #{resource.inspect} is defined more than once"
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

View File

@ -90,6 +90,11 @@ class Formulary
def get_formula(spec)
formula = super
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
end
end