Fix Keg.bottle_dependencies including unneeded build dependencies

This commit is contained in:
Bo Anderson 2022-06-30 04:11:15 +01:00
parent 2ddce84225
commit 01d1f1ecb6
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 24 additions and 16 deletions

View File

@ -87,8 +87,7 @@ class Keg
gcc = Formulary.factory(CompilerSelector.preferred_gcc)
if !Homebrew::EnvConfig.simulate_macos_on_linux? &&
DevelopmentTools.non_apple_gcc_version("gcc") < gcc.version.to_i
formulae += gcc.recursive_dependencies.map(&:name)
formulae << gcc.name
formulae << gcc
end
formulae
end

View File

@ -577,9 +577,8 @@ class FormulaInstaller
unsatisfied_reqs
end
def expand_dependencies
inherited_options = Hash.new { |hash, key| hash[key] = Options.new }
pour_bottle = pour_bottle?
def expand_dependencies_for_formula(formula, inherited_options)
any_bottle_used = false
# Cache for this expansion only. FormulaInstaller has a lot of inputs which can alter expansion.
cache_key = "FormulaInstaller-#{formula.full_name}-#{Time.now.to_f}"
@ -600,24 +599,34 @@ class FormulaInstaller
elsif dep.satisfied?(inherited_options[dep.name])
Dependency.skip
else
pour_bottle ||= install_bottle_for?(dep.to_formula, build)
any_bottle_used ||= install_bottle_for?(dep.to_formula, build)
end
end
[expanded_deps, any_bottle_used]
end
def expand_dependencies
inherited_options = Hash.new { |hash, key| hash[key] = Options.new }
any_bottle_used = pour_bottle?
expanded_deps, any_dep_bottle_used = expand_dependencies_for_formula(formula, inherited_options)
any_bottle_used ||= any_dep_bottle_used
# We require some dependencies (glibc, GCC 5, etc.) if binaries were built.
# Native binaries shouldn't exist in cross-platform `all` bottles.
if pour_bottle && !formula.bottled?(:all) && !Keg.bottle_dependencies.empty?
bottle_deps = if Keg.bottle_dependencies.exclude?(formula.name)
Keg.bottle_dependencies
else
[]
if any_bottle_used && !formula.bottled?(:all) && !Keg.bottle_dependencies.empty?
all_bottle_deps = Keg.bottle_dependencies.flat_map do |bottle_dep|
bottle_dep.recursive_dependencies.map(&:name) + [bottle_dep.name]
end
bottle_deps = bottle_deps.map { |formula| Dependency.new(formula) }
.reject do |dep|
inherited_options[dep.name] |= inherited_options_for(dep)
dep.satisfied? inherited_options[dep.name]
if all_bottle_deps.exclude?(formula.name)
bottle_deps = Keg.bottle_dependencies.flat_map do |bottle_dep|
expanded_bottle_deps, = expand_dependencies_for_formula(bottle_dep, inherited_options)
expanded_bottle_deps
end
expanded_deps = Dependency.merge_repeats(bottle_deps + expanded_deps)
end
expanded_deps = Dependency.merge_repeats(bottle_deps + expanded_deps)
end
expanded_deps.map { |dep| [dep, inherited_options[dep.name]] }