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?
|
elsif args.dependents?
|
||||||
formulae = all_formulae = Formula.to_a
|
formulae = all_formulae = Formula.to_a
|
||||||
|
|
||||||
@sort = " (sorted by installs in the last 90 days)"
|
@sort = " (sorted by number of dependents)"
|
||||||
else
|
else
|
||||||
formula_installs = {}
|
formula_installs = {}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ module Homebrew
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end.compact
|
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
|
all_formulae = Formula
|
||||||
end
|
end
|
||||||
@ -154,20 +154,51 @@ module Homebrew
|
|||||||
|
|
||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
name = f.name.downcase
|
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
|
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: already bottled" if any_named_args
|
||||||
next
|
next
|
||||||
end
|
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 @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
|
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires macOS" if any_named_args
|
||||||
next
|
next
|
||||||
end
|
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
|
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires Linux" if any_named_args
|
||||||
next
|
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
|
end
|
||||||
|
|
||||||
if f.bottle_unneeded? || f.bottle_disabled?
|
if f.bottle_unneeded? || f.bottle_disabled?
|
||||||
@ -181,7 +212,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
deps = Array(deps_hash[f.name]).reject do |dep|
|
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
|
end
|
||||||
|
|
||||||
if deps.blank?
|
if deps.blank?
|
||||||
|
@ -20,10 +20,10 @@ module Utils
|
|||||||
|
|
||||||
alias generic_find_matching_tag find_matching_tag
|
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.
|
# Used primarily by developers testing beta macOS releases.
|
||||||
if OS::Mac.prerelease? && Homebrew::EnvConfig.developer? &&
|
if exact || (OS::Mac.prerelease? && Homebrew::EnvConfig.developer? &&
|
||||||
Homebrew::EnvConfig.skip_or_later_bottles?
|
Homebrew::EnvConfig.skip_or_later_bottles?)
|
||||||
generic_find_matching_tag(tag)
|
generic_find_matching_tag(tag)
|
||||||
else
|
else
|
||||||
generic_find_matching_tag(tag) ||
|
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
|
# Bump these when a new version is available from the App Store and our
|
||||||
# CI systems have been updated.
|
# CI systems have been updated.
|
||||||
# This may be a beta version for a beta macOS.
|
# This may be a beta version for a beta macOS.
|
||||||
sig { returns(String) }
|
sig { params(macos: MacOS::Version).returns(String) }
|
||||||
def latest_version
|
def latest_version(macos: MacOS.version)
|
||||||
latest_stable = "12.4"
|
latest_stable = "12.4"
|
||||||
case MacOS.version
|
case macos
|
||||||
when "11" then latest_stable
|
when "11" then latest_stable
|
||||||
when "10.15" then "12.4"
|
when "10.15" then "12.4"
|
||||||
when "10.14" then "11.3.1"
|
when "10.14" then "11.3.1"
|
||||||
|
@ -402,9 +402,9 @@ class BottleSpecification
|
|||||||
cellar == :any_skip_relocation
|
cellar == :any_skip_relocation
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(tag: Symbol).returns(T::Boolean) }
|
sig { params(tag: Symbol, exact: T::Boolean).returns(T::Boolean) }
|
||||||
def tag?(tag)
|
def tag?(tag, exact: false)
|
||||||
checksum_for(tag) ? true : false
|
checksum_for(tag, exact: exact) ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checksum methods in the DSL's bottle block take
|
# Checksum methods in the DSL's bottle block take
|
||||||
@ -444,9 +444,9 @@ class BottleSpecification
|
|||||||
collector[tag] = { checksum: Checksum.new(digest), cellar: cellar }
|
collector[tag] = { checksum: Checksum.new(digest), cellar: cellar }
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(tag: Symbol).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) }
|
sig { params(tag: Symbol, exact: T::Boolean).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) }
|
||||||
def checksum_for(tag)
|
def checksum_for(tag, exact: false)
|
||||||
collector.fetch_checksum_for(tag)
|
collector.fetch_checksum_for(tag, exact: exact)
|
||||||
end
|
end
|
||||||
|
|
||||||
def checksums
|
def checksums
|
||||||
|
@ -107,15 +107,15 @@ module Utils
|
|||||||
@checksums = {}
|
@checksums = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(tag: Symbol).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) }
|
sig { params(tag: Symbol, exact: T::Boolean).returns(T.nilable([Checksum, Symbol, T.any(Symbol, String)])) }
|
||||||
def fetch_checksum_for(tag)
|
def fetch_checksum_for(tag, exact: false)
|
||||||
tag = find_matching_tag(tag)
|
tag = find_matching_tag(tag, exact: exact)
|
||||||
return self[tag][:checksum], tag, self[tag][:cellar] if tag
|
return self[tag][:checksum], tag, self[tag][:cellar] if tag
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_matching_tag(tag)
|
def find_matching_tag(tag, exact: false)
|
||||||
tag if key?(tag)
|
tag if key?(tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user