update-report: migrate GCC recursive dependents
When GCC 12 ships (Homebrew/homebrew-core#106755) ships, most (all?) Linux bottles that depend on GCC will break. Let's fix that by using the same trick for handling divergent formula revisions when migrating formulae from linuxbrew-core (#11982). We set the recorded `version_scheme` to -1, which spoofs the formula being outdated. When `brew upgrade` installs GCC 12, the broken formulae will have their bottles reinstalled too. This works because the reinstallation will also rewrite the existing RPATHs to point to the new version of GCC instead (#13631). This should handle most of the breakage.
This commit is contained in:
parent
3b38695efa
commit
7be6b8e6d1
@ -148,6 +148,8 @@ module Homebrew
|
||||
Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"]
|
||||
return if Homebrew::EnvConfig.disable_load_formula?
|
||||
|
||||
migrate_gcc_dependents_if_needed
|
||||
|
||||
hub = ReporterHub.new
|
||||
|
||||
updated_taps = []
|
||||
@ -289,6 +291,34 @@ module Homebrew
|
||||
#{e}
|
||||
EOS
|
||||
end
|
||||
|
||||
def migrate_gcc_dependents_if_needed
|
||||
return if OS.mac?
|
||||
|
||||
# TODO: Remove this block when GCC 12 ships.
|
||||
begin
|
||||
return if Formula["gcc"].version < 12
|
||||
rescue FormulaUnavailableError
|
||||
return if Homebrew::EnvConfig.install_from_api?
|
||||
end
|
||||
|
||||
return if Settings.read("gcc.dependents.migrated") == "true"
|
||||
|
||||
Formula.installed.each do |formula|
|
||||
next unless formula.tap.core_tap?
|
||||
next unless formula.recursive_dependencies.map(&:name).include? "gcc"
|
||||
|
||||
keg = formula.installed_kegs.last
|
||||
tab = Tab.for_keg(keg)
|
||||
# Force reinstallation upon `brew upgrade` to fix the bottle RPATH.
|
||||
tab.source["versions"]["version_scheme"] = -1
|
||||
tab.write
|
||||
rescue TapFormulaUnavailableError
|
||||
nil
|
||||
end
|
||||
|
||||
Settings.write "gcc.dependents.migrated", true
|
||||
end
|
||||
end
|
||||
|
||||
class Reporter
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user