diff options
| author | Xu Cheng | 2015-07-23 14:09:32 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-07-24 15:59:28 +0800 |
| commit | b1fff3205584e1e42ae750b2af7ca17963929aa9 (patch) | |
| tree | 99b9afbc2a2d71a3a3dbd5a4aa5c06796c7a3f2e /Library/Homebrew | |
| parent | 602ea66a0f6e8933fea00ad558390c50f52848ca (diff) | |
| download | brew-b1fff3205584e1e42ae750b2af7ca17963929aa9.tar.bz2 | |
BottleLoader: check version mismatch
Closes Homebrew/homebrew#42049.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/exceptions.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/formulary.rb | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 59a374535..35dca72ac 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -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 diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index e5b79972d..f1fed506e 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -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 |
