From eb1b244fd2644890d0509bf08761dda58f3db8ca Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 21 Oct 2021 15:01:58 +0100 Subject: [PATCH 1/2] update-report: better handle user set bottle domain, core git remote. Unset these variables and print a warning if they were set to non-default values. --- Library/Homebrew/cmd/update-report.rb | 24 +++++++++++++++++-- .../Homebrew/extend/os/linux/diagnostic.rb | 11 +++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index a5188aa222..4d3360976d 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -44,12 +44,32 @@ module Homebrew # Run `brew update` (again) if we've got a linuxbrew-core CoreTap if CoreTap.instance.linuxbrew_core? && ENV["HOMEBREW_LINUXBREW_CORE_MIGRATION"].blank? + ohai_stdout_or_stderr "Re-running `brew update` for linuxbrew-core migration" + + if ENV["HOMEBREW_CORE_DEFAULT_GIT_REMOTE"] != ENV["HOMEBREW_CORE_GIT_REMOTE"] + opoo <<~EOS + HOMEBREW_CORE_GIT_REMOTE was set. It has been unset for the migration. + You may need to change this from a linuxbrew-core mirror to a homebrew-core one. + + EOS + end + ENV.delete("HOMEBREW_CORE_GIT_REMOTE") + + if ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"] != ENV["HOMEBREW_BOTTLE_DOMAIN"] + opoo <<~EOS + HOMEBREW_BOTTLE_DOMAIN was set. It has been unset for the migration. + You may need to change this Linuxbrew packages to Homebrew packages. + + EOS + end + ENV.delete("HOMEBREW_BOTTLE_DOMAIN") + ENV["HOMEBREW_LINUXBREW_CORE_MIGRATION"] = "1" + FileUtils.rm_f HOMEBREW_LOCKS/"update" + update_args = [] update_args << "--preinstall" if args.preinstall? update_args << "--force" if args.force? - ohai_stdout_or_stderr "Re-running `brew update` for linuxbrew-core migration" - FileUtils.rm_f HOMEBREW_LOCKS/"update" exec HOMEBREW_BREW_FILE, "update", *update_args end diff --git a/Library/Homebrew/extend/os/linux/diagnostic.rb b/Library/Homebrew/extend/os/linux/diagnostic.rb index f100962f86..f9c6afe650 100644 --- a/Library/Homebrew/extend/os/linux/diagnostic.rb +++ b/Library/Homebrew/extend/os/linux/diagnostic.rb @@ -16,6 +16,7 @@ module Homebrew %w[ check_access_directories check_linuxbrew_core + check_linuxbrew_bottle_domain ].freeze end @@ -127,6 +128,16 @@ module Homebrew You must `brew update` to update to homebrew-core. EOS end + + def check_linuxbrew_bottle_domain + return unless Homebrew::EnvConfig.bottle_domain.include?("linuxbrew-core") + + <<~EOS + Your HOMEBREW_BOTTLE_DOMAIN still contains linuxbrew-core. + You must unset it (or adjust it to not contain linuxbrew-core + e.g. by using homebrew-core instead). + EOS + end end end end From 0118e6ec41a4fb2e2638165fee0a4f492f19bf81 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 21 Oct 2021 15:10:17 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Xuehai Pan --- Library/Homebrew/cmd/update-report.rb | 8 +++++--- Library/Homebrew/extend/os/linux/diagnostic.rb | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 4d3360976d..7c0df7ad20 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -48,7 +48,8 @@ module Homebrew if ENV["HOMEBREW_CORE_DEFAULT_GIT_REMOTE"] != ENV["HOMEBREW_CORE_GIT_REMOTE"] opoo <<~EOS - HOMEBREW_CORE_GIT_REMOTE was set. It has been unset for the migration. + HOMEBREW_CORE_GIT_REMOTE was set: #{ENV["HOMEBREW_CORE_GIT_REMOTE"]}. + It has been unset for the migration. You may need to change this from a linuxbrew-core mirror to a homebrew-core one. EOS @@ -57,8 +58,9 @@ module Homebrew if ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"] != ENV["HOMEBREW_BOTTLE_DOMAIN"] opoo <<~EOS - HOMEBREW_BOTTLE_DOMAIN was set. It has been unset for the migration. - You may need to change this Linuxbrew packages to Homebrew packages. + HOMEBREW_BOTTLE_DOMAIN was set: #{ENV["HOMEBREW_BOTTLE_DOMAIN"]}. + It has been unset for the migration. + You may need to change this from a Linuxbrew package mirror to a Homebrew one. EOS end diff --git a/Library/Homebrew/extend/os/linux/diagnostic.rb b/Library/Homebrew/extend/os/linux/diagnostic.rb index f9c6afe650..b85cf756f4 100644 --- a/Library/Homebrew/extend/os/linux/diagnostic.rb +++ b/Library/Homebrew/extend/os/linux/diagnostic.rb @@ -130,12 +130,12 @@ module Homebrew end def check_linuxbrew_bottle_domain - return unless Homebrew::EnvConfig.bottle_domain.include?("linuxbrew-core") + return unless Homebrew::EnvConfig.bottle_domain.include?("linuxbrew") <<~EOS - Your HOMEBREW_BOTTLE_DOMAIN still contains linuxbrew-core. - You must unset it (or adjust it to not contain linuxbrew-core - e.g. by using homebrew-core instead). + Your HOMEBREW_BOTTLE_DOMAIN still contains "linuxbrew". + You must unset it (or adjust it to not contain linuxbrew + e.g. by using homebrew instead). EOS end end