aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorXu Cheng2015-07-23 14:09:32 +0800
committerXu Cheng2015-07-24 15:59:28 +0800
commitb1fff3205584e1e42ae750b2af7ca17963929aa9 (patch)
tree99b9afbc2a2d71a3a3dbd5a4aa5c06796c7a3f2e /Library/Homebrew
parent602ea66a0f6e8933fea00ad558390c50f52848ca (diff)
downloadbrew-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.rb10
-rw-r--r--Library/Homebrew/formulary.rb5
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