dev-cmd/unbottled: various improvements
* Ignore bottles for older macOS versions * Ignore disabled formulae * Ignore formulae which can't build on the chosen macOS * Improve/fix sort description
This commit is contained in:
parent
787e6cb75f
commit
fb8b247db3
@ -78,7 +78,7 @@ module Homebrew
|
||||
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 @@ module Homebrew
|
||||
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 @@ module Homebrew
|
||||
|
||||
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 @@ module Homebrew
|
||||
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?
|
||||
|
@ -20,10 +20,10 @@ module Utils
|
||||
|
||||
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) ||
|
||||
|
@ -18,10 +18,10 @@ module OS
|
||||
# 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"
|
||||
|
@ -402,9 +402,9 @@ class BottleSpecification
|
||||
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 @@ class BottleSpecification
|
||||
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
|
||||
|
@ -107,15 +107,15 @@ module Utils
|
||||
@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
|
||||
|
Loading…
x
Reference in New Issue
Block a user