From 8e09ec4bf4f4c025eb8b9aeadfbe86847442b8b9 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 24 Aug 2022 20:34:43 +0800 Subject: [PATCH] Handle `on_system` blocks. --- Library/Homebrew/formula_auditor.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index f394d01dad..903fcebe73 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -882,18 +882,20 @@ module Homebrew # The formula has no variations, so all OS-version-arch triples depend on GCC. return false if variations.blank? - # FIXME: This returns a false positive for formulae that do, for example: - # ```ruby - # on_system :linux, macos: :catalina_or_newer do - # depends_on "gcc" - # end - # ``` - variations_deps = variations.values - .flat_map { |data| data["dependencies"] } - .compact - .uniq + MacOSVersions::SYMBOLS.each_key do |macos_version| + [:arm, :intel].each do |arch| + bottle_tag = Utils::Bottles::Tag.new(system: macos_version, arch: arch) + next unless bottle_tag.valid_combination? - variations_deps.exclude?("gcc") + variation = variations[bottle_tag.to_sym] + # This variation does not exist, so it must match Linux. + return false if variation.blank? + # We found a non-Linux variation that depends on GCC. + return false if variation["dependencies"]&.include?("gcc") + end + end + + true end end end