Class: Homebrew::DevCmd::Unbottled Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::Unbottled
- Defined in:
- dev-cmd/unbottled.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/unbottled.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Constant Summary collapse
- PORTABLE_FORMULAE =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
%w[ portable-libffi portable-libxcrypt portable-libyaml portable-openssl portable-ruby portable-zlib ].freeze
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::Unbottled::Args private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::Unbottled::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/unbottled.rbi', line 10 def args; end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'dev-cmd/unbottled.rb', line 45 def run Formulary.enable_factory_cache! bottle_tag = if (tag = args.tag) Utils::Bottles::Tag.from_symbol(tag.to_sym) else Utils::Bottles.tag end @bottle_tag = T.let(bottle_tag, T.nilable(Utils::Bottles::Tag)) return unless @bottle_tag if args.lost? if args.named.present? raise UsageError, "`brew unbottled --lost` cannot be used with formula arguments!" elsif !CoreTap.instance.installed? raise UsageError, "`brew unbottled --lost` requires `homebrew/core` to be tapped locally!" else output_lost_bottles return end end os = @bottle_tag.system arch = if Hardware::CPU::INTEL_ARCHS.include?(@bottle_tag.arch) :intel elsif Hardware::CPU::ARM_ARCHS.include?(@bottle_tag.arch) :arm else raise "Unknown arch #{@bottle_tag.arch}." end Homebrew::SimulateSystem.with(os:, arch:) do use_all_formulae = args.named.blank? && (args.total? || args.dependents?) if args.named.blank? ohai "Getting formulae..." end if args.named.present? formulae = all_formulae = args.named.to_formulae elsif args.dependents? formulae = all_formulae = Formula.all @sort = T.let(" (sorted by number of dependents)", T.nilable(String)) elsif use_all_formulae formulae = all_formulae = Formula.all else formula_installs = {} ohai "Getting analytics data..." analytics = Homebrew::API::Analytics.fetch "install", 90 if analytics.blank? raise UsageError, "default sort by analytics data requires " \ "`$HOMEBREW_NO_GITHUB_API` and `$HOMEBREW_NO_ANALYTICS` to be unset." end formulae = analytics["items"].filter_map do |i| f = i["formula"].split.first next if f.include?("/") next if formula_installs[f].present? formula_installs[f] = i["count"] begin Formula[f] rescue FormulaUnavailableError nil end end @sort = T.let(" (sorted by installs in the last 90 days; top 10,000 only)", T.nilable(String)) all_formulae = Formula.all end # Remove deprecated and disabled formulae as we do not care if they are unbottled formulae = Array(formulae).reject { |f| f.deprecated? || f.disabled? } if formulae.present? all_formulae = Array(all_formulae).reject { |f| f.deprecated? || f.disabled? } if all_formulae.present? # Remove portable formulae as they are handled differently formulae = formulae.reject { |f| PORTABLE_FORMULAE.include?(f.name) } if formulae.present? all_formulae = all_formulae.reject { |f| PORTABLE_FORMULAE.include?(f.name) } if all_formulae.present? ohai "Populating dependency tree..." deps_hash = {} uses_hash = {} all_formulae.each do |f| deps = Dependency.(f, cache_key: "unbottled") do |_, dep| next Dependable::PRUNE if dep.optional? end.map(&:to_formula) deps_hash[f.name] = deps deps.each do |dep| uses_hash[dep.name] ||= [] uses_hash[dep.name] << f end end if args.dependents? formula_dependents = {} formulae = formulae.sort_by do |f| dependents = uses_hash[f.name]&.length || 0 formula_dependents[f.name] ||= dependents end.reverse elsif use_all_formulae output_total(formulae) return end noun, hash = if args.named.present? [nil, {}] elsif args.dependents? ["dependents", formula_dependents] else ["installs", formula_installs] end return if hash.nil? output_unbottled(formulae, deps_hash, noun, hash, args.named.present?) end end |