From 7596108bd249ce3878cc8f6fb35138640be701cd Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 2 Jul 2020 11:57:11 +0100 Subject: [PATCH] Bottle extract and fetch fixes - Make `brew extract` strip out bottle blocks - Make `brew extract` output the path in a readable fashion - Warn about building from source before fetching (not installing) - If fetching a bottle fails, refetch and build from source. --- Library/Homebrew/dev-cmd/extract.rb | 8 ++++++-- Library/Homebrew/formula_installer.rb | 23 ++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index 0d4b20b9e0..d7d11b0233 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -191,7 +191,10 @@ module Homebrew # Remove any existing version suffixes, as a new one will be added later name.sub!(/\b@(.*)\z\b/i, "") versioned_name = Formulary.class_s("#{name}@#{version}") - result.gsub!("class #{class_name} < Formula", "class #{versioned_name} < Formula") + result.sub!("class #{class_name} < Formula", "class #{versioned_name} < Formula") + + # Remove bottle blocks, they won't work. + result.sub!(/ bottle do.+?end\n\n/m, "") if destination_tap != source_tap path = destination_tap.path/"Formula/#{name}@#{version}.rb" if path.exist? @@ -205,7 +208,8 @@ module Homebrew odebug "Overwriting existing formula at #{path}" path.delete end - ohai "Writing formula for #{name} from revision #{rev} to #{path}" + ohai "Writing formula for #{name} from revision #{rev} to:" + puts path path.write result end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 41298db9e3..de51741306 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -292,7 +292,7 @@ class FormulaInstaller self.class.attempted << formula - if pour_bottle?(warn: true) + if pour_bottle? begin pour rescue Exception => e # rubocop:disable Lint/RescueException @@ -983,11 +983,24 @@ class FormulaInstaller return if only_deps? - unless pour_bottle? - formula.fetch_patches - formula.resources.each(&:fetch) - end + if pour_bottle?(warn: true) + begin + downloader.fetch + rescue Exception => e # rubocop:disable Lint/RescueException + raise if Homebrew::EnvConfig.developer? || + Homebrew::EnvConfig.no_bottle_source_fallback? || + e.is_a?(Interrupt) + @pour_failed = true + onoe e.message + opoo "Bottle installation failed: building from source." + fetch_dependencies + end + end + return if pour_bottle? + + formula.fetch_patches + formula.resources.each(&:fetch) downloader.fetch end