From 1e57445eca12e45896010aead6226f0f4c1df473 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Mon, 25 Sep 2017 11:10:36 -0700 Subject: receipt_path: Ensure the bottle contains INSTALL_RECEIPT.json --- Library/Homebrew/utils/bottles.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 927963bc1..73353496a 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -29,9 +29,11 @@ module Utils end def receipt_path(bottle_file) - Utils.popen_read("tar", "-tzf", bottle_file).lines.map(&:chomp).find do |line| + path = Utils.popen_read("tar", "-tzf", bottle_file).lines.map(&:chomp).find do |line| line =~ %r{.+/.+/INSTALL_RECEIPT.json} end + raise "This bottle does not contain the file INSTALL_RECEIPT.json: #{bottle_file}" unless path + path end def resolve_formula_names(bottle_file) -- cgit v1.2.3 From 3ebf282269b62722ceff61df0335b5ee305e9f3c Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Mon, 25 Sep 2017 11:37:07 -0700 Subject: pour_bottle?: Fix when formula.bottle is nil formula.bottle is nil when bottle.compatible_cellar? is false. Use formula.bottle_specification.compatible_cellar? rather than formula.bottle.compatible_cellar?. --- Library/Homebrew/formula_installer.rb | 7 +++---- Library/Homebrew/test/bottle_hooks_spec.rb | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index b4f9db845..4966151a3 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -84,8 +84,7 @@ class FormulaInstaller return false if @pour_failed - bottle = formula.bottle - return false if !bottle && !formula.local_bottle_path + return false if !formula.bottled? && !formula.local_bottle_path return true if force_bottle? return false if build_from_source? || build_bottle? || interactive? return false if ARGV.cc @@ -101,11 +100,11 @@ class FormulaInstaller return false end - unless bottle.compatible_cellar? + unless formula.bottled? if install_bottle_options[:warn] opoo <<-EOS.undent Building #{formula.full_name} from source: - The bottle needs a #{bottle.cellar} Cellar (yours is #{HOMEBREW_CELLAR}). + The bottle needs a #{formula.bottle_specification.cellar} Cellar (yours is #{HOMEBREW_CELLAR}). EOS end return false diff --git a/Library/Homebrew/test/bottle_hooks_spec.rb b/Library/Homebrew/test/bottle_hooks_spec.rb index e70b558a1..eb6617380 100644 --- a/Library/Homebrew/test/bottle_hooks_spec.rb +++ b/Library/Homebrew/test/bottle_hooks_spec.rb @@ -8,7 +8,7 @@ describe Homebrew::Hooks::Bottles do let(:formula) do double( - bottle: nil, + bottled?: false, local_bottle_path: nil, bottle_disabled?: false, some_random_method: true, -- cgit v1.2.3 From 9642ec769e6b187c375964e4206e5ac4014d37fa Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Mon, 25 Sep 2017 11:28:45 -0700 Subject: testball_bottle-0.1: Add the formula to the bottle Update the SHA-256. --- Library/Homebrew/test/formulary_spec.rb | 2 +- .../testball_bottle-0.1.yosemite.bottle.tar.gz | Bin 1379 -> 1731 bytes .../Homebrew/test/support/fixtures/testball_bottle.rb | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb index 234ebc93c..3180ad9a7 100644 --- a/Library/Homebrew/test/formulary_spec.rb +++ b/Library/Homebrew/test/formulary_spec.rb @@ -14,7 +14,7 @@ describe Formulary do bottle do cellar :any_skip_relocation root_url "file://#{bottle_dir}" - sha256 "9abc8ce779067e26556002c4ca6b9427b9874d25f0cafa7028e05b5c5c410cb4" => :#{Utils::Bottles.tag} + sha256 "d48bbbe583dcfbfa608579724fc6f0328b3cd316935c6ea22f134610aaf2952f" => :#{Utils::Bottles.tag} end def install diff --git a/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.yosemite.bottle.tar.gz b/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.yosemite.bottle.tar.gz index d88838a94..62ea6c264 100644 Binary files a/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.yosemite.bottle.tar.gz and b/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.yosemite.bottle.tar.gz differ diff --git a/Library/Homebrew/test/support/fixtures/testball_bottle.rb b/Library/Homebrew/test/support/fixtures/testball_bottle.rb index 9453255e6..5a6be7c5f 100644 --- a/Library/Homebrew/test/support/fixtures/testball_bottle.rb +++ b/Library/Homebrew/test/support/fixtures/testball_bottle.rb @@ -6,7 +6,7 @@ class TestballBottle < Formula stable.bottle do cellar :any_skip_relocation root_url "file://#{TEST_FIXTURE_DIR}/bottles" - sha256 "9abc8ce779067e26556002c4ca6b9427b9874d25f0cafa7028e05b5c5c410cb4" => Utils::Bottles.tag + sha256 "d48bbbe583dcfbfa608579724fc6f0328b3cd316935c6ea22f134610aaf2952f" => Utils::Bottles.tag end cxxstdlib_check :skip end -- cgit v1.2.3 From 3ed832d4f0465aa9d938d3f4867ad12aaf394710 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Tue, 19 Sep 2017 12:22:32 -0700 Subject: BottleLoader: Use the formula stored in the bottle --- Library/Homebrew/exceptions.rb | 10 +++++----- Library/Homebrew/formulary.rb | 10 +++------- Library/Homebrew/test/exceptions_spec.rb | 6 +++--- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 5418f9331..22a7fe023 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -555,12 +555,12 @@ end # raised when a single patch file is not found and apply hasn't been specified class MissingApplyError < RuntimeError; end -class BottleVersionMismatchError < RuntimeError - def initialize(bottle_file, bottle_version, formula, formula_version) +class BottleFormulaUnavailableError < RuntimeError + def initialize(bottle_path, formula_path) super <<-EOS.undent - Bottle version mismatch - Bottle: #{bottle_file} (#{bottle_version}) - Formula: #{formula.full_name} (#{formula_version}) + This bottle does not contain the formula file: + #{bottle_path} + #{formula_path} EOS end end diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index dd67b4f24..c8ab8a922 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -122,14 +122,10 @@ module Formulary super name, Formulary.path(full_name) end - def get_formula(spec, alias_path: nil) - formula = super + def get_formula(spec, **) + 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_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 end end diff --git a/Library/Homebrew/test/exceptions_spec.rb b/Library/Homebrew/test/exceptions_spec.rb index 33547ea32..0a8313355 100644 --- a/Library/Homebrew/test/exceptions_spec.rb +++ b/Library/Homebrew/test/exceptions_spec.rb @@ -181,8 +181,8 @@ describe DuplicateResourceError do its(:to_s) { is_expected.to eq("Resource is defined more than once") } end -describe BottleVersionMismatchError do - subject { described_class.new("/foo.bottle.tar.gz", "1.0", formula, "1.1") } +describe BottleFormulaUnavailableError do + subject { described_class.new("/foo.bottle.tar.gz", "foo/1.0/.brew/foo.rb") } 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 -- cgit v1.2.3 From 2e77de3b58043cb8acc1e28070ae7e24fbf596fb Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Mon, 25 Sep 2017 22:46:51 -0700 Subject: Fix installing a local bottle from source Factor Utils::Bottles.formula_contents out of BottleLoader. --- Library/Homebrew/formula_installer.rb | 7 ++++++- Library/Homebrew/utils/bottles.rb | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 4966151a3..ea4415796 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -308,7 +308,12 @@ class FormulaInstaller clean # Store the formula used to build the keg in the keg. - s = formula.path.read.gsub(/ bottle do.+?end\n\n?/m, "") + formula_contents = if formula.local_bottle_path + Utils::Bottles.formula_contents formula.local_bottle_path, name: formula.name + else + formula.path.read + end + s = formula_contents.gsub(/ bottle do.+?end\n\n?/m, "") brew_prefix = formula.prefix/".brew" brew_prefix.mkdir Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s) diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 73353496a..66b5fb640 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -54,6 +54,15 @@ module Utils def resolve_version(bottle_file) PkgVersion.parse receipt_path(bottle_file).split("/")[1] end + + def formula_contents(bottle_file, + name: resolve_formula_names(bottle_file)[0]) + bottle_version = resolve_version bottle_file + formula_path = "#{name}/#{bottle_version}/.brew/#{name}.rb" + contents = Utils.popen_read "tar", "-xOzf", bottle_file, formula_path + raise BottleFormulaUnavailableError.new(bottle_file, formula_path) unless $CHILD_STATUS.success? + contents + end end class Bintray -- cgit v1.2.3 From c19cc70ac8b87bfe93d2b94e5693584139238e23 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Thu, 28 Sep 2017 11:36:56 -0700 Subject: FormulaInstaller: Warn when tap version is newer Warn if a more recent version of this formula is available in the tap. --- Library/Homebrew/formula_installer.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index ea4415796..845152e24 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -235,6 +235,15 @@ class FormulaInstaller raise CannotInstallFormulaError, message end + # Warn if a more recent version of this formula is available in the tap. + begin + if formula.pkg_version < (v = Formulary.factory(formula.full_name).pkg_version) + opoo "#{formula.full_name} #{v} is available and more recent than version #{formula.pkg_version}." + end + rescue FormulaUnavailableError + nil + end + check_conflicts if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed? -- cgit v1.2.3