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.
This commit is contained in:
Mike McQuaid 2020-07-02 11:57:11 +01:00
parent 9c4c6e7ae9
commit 7596108bd2
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
2 changed files with 24 additions and 7 deletions

View File

@ -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

View File

@ -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