From abb2b26a93b7dad6893403395065a3ee3339ff76 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 3 Mar 2021 00:30:40 +0000 Subject: [PATCH] Add HOMEBREW_SIMULATE_MACOS_ON_LINUX --- Library/Homebrew/env_config.rb | 5 +++++ Library/Homebrew/extend/os/mac/software_spec.rb | 3 ++- Library/Homebrew/extend/os/on_os.rb | 2 +- Library/Homebrew/extend/os/software_spec.rb | 2 +- Library/Homebrew/formula_auditor.rb | 2 +- Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi | 2 ++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 065d8497df..851b2d08df 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -260,6 +260,11 @@ module Homebrew description: "If set, use Pry for the `brew irb` command.", boolean: true, }, + HOMEBREW_SIMULATE_MACOS_ON_LINUX: { + description: "If set, running Homebrew on Linux will simulate certain macOS code paths. This is useful " \ + "when auditing macOS formulae while on Linux.", + boolean: true, + }, HOMEBREW_SKIP_OR_LATER_BOTTLES: { description: "If set along with `HOMEBREW_DEVELOPER`, do not use bottles from older versions " \ "of macOS. This is useful in development on new macOS versions.", diff --git a/Library/Homebrew/extend/os/mac/software_spec.rb b/Library/Homebrew/extend/os/mac/software_spec.rb index 4a4d1377c0..f365951271 100644 --- a/Library/Homebrew/extend/os/mac/software_spec.rb +++ b/Library/Homebrew/extend/os/mac/software_spec.rb @@ -15,7 +15,8 @@ class SoftwareSpec end bounds = bounds.transform_values { |v| MacOS::Version.from_symbol(v) } - if MacOS.version >= bounds[:since] + if MacOS.version >= bounds[:since] || + (Homebrew::EnvConfig.simulate_macos_on_linux? && !bounds.key?(:since)) @uses_from_macos_elements << deps else depends_on deps diff --git a/Library/Homebrew/extend/os/on_os.rb b/Library/Homebrew/extend/os/on_os.rb index 38e1bce2e1..c74ea9d459 100644 --- a/Library/Homebrew/extend/os/on_os.rb +++ b/Library/Homebrew/extend/os/on_os.rb @@ -1,7 +1,7 @@ # typed: strict # frozen_string_literal: true -if OS.mac? +if OS.mac? || Homebrew::EnvConfig.simulate_macos_on_linux? require "extend/os/mac/on_os" elsif OS.linux? require "extend/os/linux/on_os" diff --git a/Library/Homebrew/extend/os/software_spec.rb b/Library/Homebrew/extend/os/software_spec.rb index 9f130f7150..32f46468f7 100644 --- a/Library/Homebrew/extend/os/software_spec.rb +++ b/Library/Homebrew/extend/os/software_spec.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true # This logic will need to be more nuanced if this file includes more than `uses_from_macos`. -if OS.mac? || Homebrew::EnvConfig.force_homebrew_on_linux? +if OS.mac? || Homebrew::EnvConfig.simulate_macos_on_linux? require "extend/os/mac/software_spec" elsif OS.linux? require "extend/os/linux/software_spec" diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index f53a77d003..f044ec817f 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -282,7 +282,7 @@ module Homebrew # The number of conflicts on Linux is absurd. # TODO: remove this and check these there too. - return if OS.linux? && !Homebrew::EnvConfig.force_homebrew_on_linux? + return if OS.linux? && !Homebrew::EnvConfig.simulate_macos_on_linux? recursive_runtime_formulae = formula.runtime_formula_dependencies(undeclared: false) version_hash = {} diff --git a/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi b/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi index 25fb5d6efa..13ff90893a 100644 --- a/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi +++ b/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi @@ -8234,6 +8234,8 @@ module Homebrew::EnvConfig def self.pry?(); end + def self.simulate_macos_on_linux?(); end + def self.skip_or_later_bottles?(); end def self.sorbet_runtime?(); end