diff --git a/Library/Homebrew/dev-cmd/unbottled.rb b/Library/Homebrew/dev-cmd/unbottled.rb index 46b0131457125..2c0f098f5722d 100644 --- a/Library/Homebrew/dev-cmd/unbottled.rb +++ b/Library/Homebrew/dev-cmd/unbottled.rb @@ -78,7 +78,7 @@ def formulae_all_installs_from_args(args) elsif args.dependents? formulae = all_formulae = Formula.to_a - @sort = " (sorted by installs in the last 90 days)" + @sort = " (sorted by number of dependents)" else formula_installs = {} @@ -103,7 +103,7 @@ def formulae_all_installs_from_args(args) nil end end.compact - @sort = " (sorted by installs in the last 90 days)" + @sort = " (sorted by installs in the last 90 days; top 10,000 only)" all_formulae = Formula end @@ -154,20 +154,51 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args) formulae.each do |f| name = f.name.downcase - if f.bottle_specification.tag?(@bottle_tag) + if f.bottle_specification.tag?(@bottle_tag, exact: true) puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: already bottled" if any_named_args next end - requirement_classes = f.recursive_requirements.map(&:class) + if f.disabled? + puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: formula disabled" if any_named_args + next + end + + requirements = f.recursive_requirements if @bottle_tag.to_s.end_with?("_linux") - if requirement_classes.include?(MacOSRequirement) + if requirements.any? { |r| r.is_a?(MacOSRequirement) } puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires macOS" if any_named_args next end - elsif requirement_classes.include?(LinuxRequirement) + elsif requirements.any? { |r| r.is_a?(LinuxRequirement) } puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires Linux" if any_named_args next + else + macos_version = MacOS::Version.from_symbol(@bottle_tag) + macos_satisfied = requirements.all? do |r| + case r + when MacOSRequirement + next true unless r.version_specified? + + macos_version.public_send(r.comparator, r.version) + when XcodeRequirement + next true unless r.version + + Version.new(MacOS::Xcode.latest_version(macos: macos_version)) >= r.version + when ArchRequirement + arch = r.arch + arch = :intel if arch == :x86_64 + arch = :arm64 if arch == :arm + + arch == macos_version.arch + else + true + end + end + unless macos_satisfied + puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: doesn't support this macOS" if any_named_args + next + end end if f.bottle_unneeded? || f.bottle_disabled? @@ -181,7 +212,7 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args) end deps = Array(deps_hash[f.name]).reject do |dep| - dep.bottle_specification.tag?(@bottle_tag) || dep.bottle_unneeded? + dep.bottle_specification.tag?(@bottle_tag, exact: true) || dep.bottle_unneeded? end if deps.blank? diff --git a/Library/Homebrew/extend/os/mac/utils/bottles.rb b/Library/Homebrew/extend/os/mac/utils/bottles.rb index 75023c1473fe6..61141336a1a23 100644 --- a/Library/Homebrew/extend/os/mac/utils/bottles.rb +++ b/Library/Homebrew/extend/os/mac/utils/bottles.rb @@ -20,10 +20,10 @@ class Collector alias generic_find_matching_tag find_matching_tag - def find_matching_tag(tag) + def find_matching_tag(tag, exact: false) # Used primarily by developers testing beta macOS releases. - if OS::Mac.prerelease? && Homebrew::EnvConfig.developer? && - Homebrew::EnvConfig.skip_or_later_bottles? + if exact || (OS::Mac.prerelease? && Homebrew::EnvConfig.developer? && + Homebrew::EnvConfig.skip_or_later_bottles?) generic_find_matching_tag(tag) else generic_find_matching_tag(tag) || diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 7de72b63e3e1a..89b7bb51ba49e 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -18,10 +18,10 @@ module Xcode # Bump these when a new version is available from the App Store and our # CI systems have been updated. # This may be a beta version for a beta macOS. - sig { returns(String) } - def latest_version + sig { params(macos: MacOS::Version).returns(String) } + def latest_version(macos: MacOS.version) latest_stable = "12.4" - case MacOS.version + case macos when "11" then latest_stable when "10.15" then "12.4" when "10.14" then "11.3.1" diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 491eef049c696..13f62a01778eb 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -402,9 +402,9 @@ def skip_relocation? cellar == :any_skip_relocation end - sig { params(tag: Symbol).returns(T::Boolean) } - def tag?(tag) - checksum_for(tag) ? true : false + sig { params(tag: Symbol, exact: T::Boolean).returns(T::Boolean) } + def tag?(tag, exact: false) + checksum_for(tag, exact: exact) ? true : false end # Checksum methods in the DSL's bottle block take @@ -444,9 +444,9 @@ def sha256(hash) collector[tag] = { checksum: Checksum.new(digest), cellar: cellar } end - sig { params(tag: Symbol).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) } - def checksum_for(tag) - collector.fetch_checksum_for(tag) + sig { params(tag: Symbol, exact: T::Boolean).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) } + def checksum_for(tag, exact: false) + collector.fetch_checksum_for(tag, exact: exact) end def checksums diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 1898f68517db1..897d8c4af4967 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -107,15 +107,15 @@ def initialize @checksums = {} end - sig { params(tag: Symbol).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) } - def fetch_checksum_for(tag) - tag = find_matching_tag(tag) + sig { params(tag: Symbol, exact: T::Boolean).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) } + def fetch_checksum_for(tag, exact: false) + tag = find_matching_tag(tag, exact: exact) return self[tag][:checksum], tag, self[tag][:cellar] if tag end private - def find_matching_tag(tag) + def find_matching_tag(tag, exact: false) tag if key?(tag) end end