BottleLoader: Use the formula stored in the bottle

This commit is contained in:
Shaun Jackman 2017-09-19 12:22:32 -07:00
parent 9642ec769e
commit 3ed832d4f0
3 changed files with 11 additions and 15 deletions

View File

@ -555,12 +555,12 @@ end
# raised when a single patch file is not found and apply hasn't been specified # raised when a single patch file is not found and apply hasn't been specified
class MissingApplyError < RuntimeError; end class MissingApplyError < RuntimeError; end
class BottleVersionMismatchError < RuntimeError class BottleFormulaUnavailableError < RuntimeError
def initialize(bottle_file, bottle_version, formula, formula_version) def initialize(bottle_path, formula_path)
super <<-EOS.undent super <<-EOS.undent
Bottle version mismatch This bottle does not contain the formula file:
Bottle: #{bottle_file} (#{bottle_version}) #{bottle_path}
Formula: #{formula.full_name} (#{formula_version}) #{formula_path}
EOS EOS
end end
end end

View File

@ -122,14 +122,10 @@ module Formulary
super name, Formulary.path(full_name) super name, Formulary.path(full_name)
end end
def get_formula(spec, alias_path: nil) def get_formula(spec, **)
formula = super contents = Utils::Bottles.formula_contents @bottle_filename, name: name
formula = Formulary.from_contents name, @bottle_filename, contents, spec
formula.local_bottle_path = @bottle_filename formula.local_bottle_path = @bottle_filename
formula_version = formula.pkg_version
bottle_version = Utils::Bottles.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

View File

@ -181,8 +181,8 @@ describe DuplicateResourceError do
its(:to_s) { is_expected.to eq("Resource <resource foo> is defined more than once") } its(:to_s) { is_expected.to eq("Resource <resource foo> is defined more than once") }
end end
describe BottleVersionMismatchError do describe BottleFormulaUnavailableError do
subject { described_class.new("/foo.bottle.tar.gz", "1.0", formula, "1.1") } subject { described_class.new("/foo.bottle.tar.gz", "foo/1.0/.brew/foo.rb") }
let(:formula) { double(Formula, full_name: "foo") } let(:formula) { double(Formula, full_name: "foo") }
its(:to_s) { is_expected.to match(/Bottle version mismatch/) } its(:to_s) { is_expected.to match(/This bottle does not contain the formula file/) }
end end