Class: Homebrew::Bundle::Brew Private
- Inherits:
-
PackageType
- Object
- PackageType
- Homebrew::Bundle::Brew
- Extended by:
- Utils::Output::Mixin
- Defined in:
- bundle/brew.rb,
bundle/brew_services.rb
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.
Direct Known Subclasses
Defined Under Namespace
Class Attribute Summary collapse
Class Method Summary collapse
- .check_label ⇒ String private
- .dump(describe: false, no_restart: false) ⇒ String private
- .dump_output(describe: false, no_restart: false) ⇒ String private
- .expected_link_status?(link, keg_only:) ⇒ Boolean private
- .find_formula(name) ⇒ Hash{Symbol => T.untyped}? private
- .formula_aliases ⇒ Hash{String => String} private
- .formula_dump_link_status(formula) ⇒ Boolean? private
- .formula_in_array?(formula, array) ⇒ Boolean private
- .formula_installed?(formula) ⇒ Boolean private
- .formula_installed_and_up_to_date?(formula, no_upgrade: false) ⇒ Boolean private
-
.formula_names_with_dependencies(formulae) ⇒ Array<String>
private
Returns formula names and all declared dependencies, including optional dependencies.
- .formula_oldnames ⇒ Hash{String => String} private
- .formula_pinned?(formula) ⇒ Boolean private
- .formula_tap_changed?(formula) ⇒ Boolean private
- .formula_upgradable?(formula) ⇒ Boolean private
- .formulae ⇒ Array<Hash{Symbol => T.untyped}> private
-
.formulae_by_full_name(name = nil) ⇒ Hash{Symbol => T.untyped}, ...
private
Returns the full
@formulae_by_full_namemap when called without a name, or a single formula's attribute hash when called with a name. - .inherited(subclass) ⇒ void private
- .install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options) ⇒ Boolean private
- .install_verb(name, options = {}) ⇒ Object private
- .installed_formula(name) ⇒ Formula private
- .installed_formulae ⇒ Array<String> private
- .link_status_to_check(formula, options) ⇒ Boolean? private
- .no_upgrade_with_args?(no_upgrade, formula_name) ⇒ Boolean private
- .outdated_formulae ⇒ Array<String> private
- .pinned_formulae ⇒ Array<String> private
- .preinstall!(name, no_upgrade: false, verbose: false, **options) ⇒ Boolean private
- .reset! ⇒ void private
- .type ⇒ Symbol private
- .upgradable_formulae ⇒ Array<String> private
Instance Method Summary collapse
- #changed? ⇒ Boolean private
- #failure_reason(name, no_upgrade:) ⇒ String private
- #find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Array<String> private
- #initialize(name = "", options = {}) ⇒ void constructor private
- #install!(preinstall: true, no_upgrade: false, verbose: false, force: false) ⇒ Boolean private
- #install_change_state!(no_upgrade:, verbose:, force:) ⇒ Boolean private
- #installed_and_up_to_date?(formula, no_upgrade: false) ⇒ Boolean private
- #link_change_state!(verbose: false) ⇒ Boolean private
- #pin_change_state!(verbose:) ⇒ Boolean private
- #pin_needed? ⇒ Boolean private
- #postinstall_change_state!(verbose:) ⇒ Boolean private
- #preinstall!(no_upgrade: false, verbose: false) ⇒ Boolean private
- #restart_service? ⇒ Boolean private
- #restart_service_needed? ⇒ Boolean private
- #service_change_state!(verbose:) ⇒ Boolean private
- #start_service? ⇒ Boolean private
- #start_service_needed? ⇒ Boolean private
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
Methods inherited from PackageType
batch_installable?, check, #checkable_entries, dump_supported?, #exit_early_check, #format_checkable, #full_check, install_batch!, install_supported?
Constructor Details
#initialize(name = "", options = {}) ⇒ 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.
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'bundle/brew.rb', line 490 def initialize(name = "", = {}) @conflicts_with = T.let(nil, T.nilable(T::Array[String])) super() @full_name = name @name = T.let(Utils.name_from_full_name(name), String) args = .fetch(:args, []).map { |arg| "--#{arg}" } @args = T.let(args, T::Array[String]) @conflicts_with_arg = T.let(.fetch(:conflicts_with, []), T::Array[String]) @restart_service = T.let([:restart_service], T.nilable(T.any(Symbol, T::Boolean))) @start_service = T.let(.fetch(:start_service, @restart_service), T.nilable(T.any(Symbol, T::Boolean))) @link = T.let(.fetch(:link, nil), T.nilable(T.any(Symbol, T::Boolean))) @postinstall = T.let(.fetch(:postinstall, nil), T.nilable(String)) @version_file = T.let(.fetch(:version_file, nil), T.nilable(String)) @trusted = T.let(.fetch(:trusted, false), T::Boolean) pin = [:pin] == true @pin = T.let(pin, T::Boolean) @changed = T.let(nil, T.nilable(T::Boolean)) end |
Class Attribute Details
.formulae_by_name(name) ⇒ Hash{Symbol => T.untyped}?
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.
280 281 282 |
# File 'bundle/brew.rb', line 280 def formulae_by_name(name) T.cast(formulae_by_full_name(name), T.nilable(T::Hash[Symbol, T.untyped])) || @formulae_by_name&.[](name) end |
Class Method Details
.check_label ⇒ String
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.
22 |
# File 'bundle/brew.rb', line 22 def check_label = "Formula" |
.dump(describe: false, no_restart: false) ⇒ String
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.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'bundle/brew.rb', line 285 def dump(describe: false, no_restart: false) require "bundle/brew_services" requested_formula = formulae.select do |f| f[:installed_on_request?] end trusted_formulae = Homebrew::Trust.trusted_entries(:formula) requested_formula.map do |f| brewline = if describe && f[:desc].present? f[:desc].split("\n").map { |s| "# #{s}\n" }.join else "" end brewline += "brew \"#{f[:full_name]}\"" args = f[:args].map { |arg| "\"#{arg}\"" }.sort.join(", ") brewline += ", args: [#{args}]" unless f[:args].empty? brewline += ", restart_service: :changed" if !no_restart && Services.started?(f[:full_name]) brewline += ", link: #{f[:link?]}" unless f[:link?].nil? brewline += ", pin: true" if f[:pinned?] brewline += ", trusted: true" if trusted_formulae.include?(f[:full_name]) brewline end.join("\n") end |
.dump_output(describe: false, no_restart: false) ⇒ String
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.
311 312 313 |
# File 'bundle/brew.rb', line 311 def dump_output(describe: false, no_restart: false) dump(describe:, no_restart:) end |
.expected_link_status?(link, keg_only:) ⇒ Boolean
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.
118 119 120 121 122 123 124 125 126 127 |
# File 'bundle/brew.rb', line 118 def expected_link_status?(link, keg_only:) case link when :overwrite, true true when false false else !keg_only end end |
.find_formula(name) ⇒ Hash{Symbol => T.untyped}?
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.
227 228 229 230 |
# File 'bundle/brew.rb', line 227 def find_formula(name) formula = T.cast(formulae_by_full_name(name), T.nilable(T::Hash[Symbol, T.untyped])) formula.presence || formulae_by_name(name) end |
.formula_aliases ⇒ Hash{String => String}
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.
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'bundle/brew.rb', line 316 def formula_aliases return @formula_aliases if @formula_aliases @formula_aliases = {} formulae.each do |f| aliases = f[:aliases] next if aliases.blank? aliases.each do |a| @formula_aliases[a] = f[:full_name] if (tap_name = Utils.tap_from_full_name(f[:full_name])) @formula_aliases["#{tap_name}/#{a}"] = f[:full_name] end end end @formula_aliases end |
.formula_dump_link_status(formula) ⇒ Boolean?
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.
130 131 132 133 134 135 |
# File 'bundle/brew.rb', line 130 def formula_dump_link_status(formula) ( @formulae_by_full_name&.[](formula) || @formulae_by_name&.[](Utils.name_from_full_name(formula)) )&.fetch(:link?) end |
.formula_in_array?(formula, array) ⇒ Boolean
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.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'bundle/brew.rb', line 143 def formula_in_array?(formula, array) return true if array.include?(formula) return true if array.include?(Utils.name_from_full_name(formula)) old_name = formula_oldnames[formula] old_name ||= formula_oldnames[Utils.name_from_full_name(formula)] return true if old_name && array.include?(old_name) resolved_full_name = formula_aliases[formula] return false unless resolved_full_name return true if array.include?(resolved_full_name) return true if array.include?(Utils.name_from_full_name(resolved_full_name)) false end |
.formula_installed?(formula) ⇒ Boolean
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.
160 161 162 163 164 165 166 |
# File 'bundle/brew.rb', line 160 def formula_installed?(formula) # Fully qualified tap formulae can be checked by their Cellar rack name # without loading the formula from an untrusted tap. return installed_formulae.include?(Utils.name_from_full_name(formula)) if Utils.full_name?(formula) formula_in_array?(formula, installed_formulae) end |
.formula_installed_and_up_to_date?(formula, no_upgrade: false) ⇒ Boolean
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.
84 85 86 87 88 89 90 |
# File 'bundle/brew.rb', line 84 def formula_installed_and_up_to_date?(formula, no_upgrade: false) return false if formula_tap_changed?(formula) return false unless formula_installed?(formula) return true if no_upgrade_with_args?(no_upgrade, formula) !formula_upgradable?(formula) end |
.formula_names_with_dependencies(formulae) ⇒ Array<String>
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.
Returns formula names and all declared dependencies, including optional dependencies.
243 244 245 246 247 |
# File 'bundle/brew.rb', line 243 def formula_names_with_dependencies(formulae) formulae.flat_map do |formula| formula.recursive_dependencies { nil }.map(&:name).prepend(formula.full_name) end.uniq end |
.formula_oldnames ⇒ Hash{String => String}
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.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'bundle/brew.rb', line 335 def formula_oldnames return @formula_oldnames if @formula_oldnames @formula_oldnames = {} formulae.each do |f| oldnames = f[:oldnames] next if oldnames.blank? oldnames.each do |oldname| @formula_oldnames[oldname] = f[:full_name] if (tap_name = Utils.tap_from_full_name(f[:full_name])) @formula_oldnames["#{tap_name}/#{oldname}"] = f[:full_name] end end end @formula_oldnames end |
.formula_pinned?(formula) ⇒ Boolean
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.
222 223 224 |
# File 'bundle/brew.rb', line 222 def formula_pinned?(formula) formula_in_array?(formula, pinned_formulae) end |
.formula_tap_changed?(formula) ⇒ Boolean
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.
169 170 171 172 173 174 175 176 177 178 179 |
# File 'bundle/brew.rb', line 169 def formula_tap_changed?(formula) return false unless Utils.full_name?(formula) require "formulary" return false unless (name_tap_type = Formulary.tap_formula_name_type(formula, warn: false)) name, tap, = name_tap_type return false unless (keg = Keg.from_rack(HOMEBREW_CELLAR/name)) keg.tab.tap != tap end |
.formula_upgradable?(formula) ⇒ Boolean
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.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'bundle/brew.rb', line 182 def formula_upgradable?(formula) return false unless formula_installed?(formula) # Reading the formula is needed for authoritative outdated state, so # report trust problems before the upgrade check tries to load it. if Utils.full_name?(formula) && Homebrew::EnvConfig.require_tap_trust? require "trust" unless Homebrew::Trust.trusted?(:formula, formula) opoo "Cannot check whether #{formula} is outdated because its tap is not trusted. " \ "Run `brew trust --formula #{formula}` to trust it." return true end end # Check local cache first and then authoritative Homebrew source. (formula_in_array?(formula, upgradable_formulae) && Formula[formula].outdated?) || false end |
.formulae ⇒ Array<Hash{Symbol => T.untyped}>
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.
233 234 235 236 237 238 239 |
# File 'bundle/brew.rb', line 233 def formulae return @formulae if @formulae formulae_by_full_name # formulae_by_full_name sets @formulae as a side effect of calling sort! T.cast(@formulae, T::Array[T::Hash[Symbol, T.untyped]]) end |
.formulae_by_full_name(name = nil) ⇒ Hash{Symbol => T.untyped}, ...
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.
Returns the full @formulae_by_full_name map when called without a name,
or a single formula's attribute hash when called with a name.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'bundle/brew.rb', line 256 def formulae_by_full_name(name = nil) return @formulae_by_full_name[name] if name.present? && @formulae_by_full_name&.key?(name) require "formula" require "formulary" Formulary.enable_factory_cache! @formulae_by_name ||= {} @formulae_by_full_name ||= {} if name.nil? formulae = Formula.installed.map { add_formula(it) } sort!(formulae) return @formulae_by_full_name end formula = Formula[name] add_formula(formula) rescue FormulaUnavailableError => e opoo "'#{name}' formula is unreadable: #{e}" {} end |
.inherited(subclass) ⇒ 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.
25 26 27 28 29 |
# File 'bundle/brew.rb', line 25 def inherited(subclass) return if subclass.name == "Homebrew::Bundle::Brew::Services" super end |
.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options) ⇒ Boolean
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.
65 66 67 |
# File 'bundle/brew.rb', line 65 def install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **) new(name, ).install!(preinstall:, no_upgrade:, verbose:, force:) end |
.install_verb(name, options = {}) ⇒ Object
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.
75 76 77 78 79 80 81 |
# File 'bundle/brew.rb', line 75 def install_verb(name, = {}) return "Reinstalling" if formula_tap_changed?(name) return "Pinning" if [:pin] == true && formula_installed?(name) && !formula_pinned?(name) return "Installing" unless formula_upgradable?(name) "Upgrading" end |
.installed_formula(name) ⇒ Formula
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.
107 108 109 110 111 112 113 114 115 |
# File 'bundle/brew.rb', line 107 def installed_formula(name) Formula[name] rescue FormulaUnavailableError # A formula that was deleted from its tap is loaded from its keg. keg = Keg.from_rack(HOMEBREW_CELLAR/Utils.name_from_full_name(name)) raise if keg.nil? || formula_tap_changed?(name) Formulary.from_path(keg/".brew/#{keg.name}.rb") end |
.installed_formulae ⇒ Array<String>
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.
202 203 204 |
# File 'bundle/brew.rb', line 202 def installed_formulae @installed_formulae ||= Formula.installed_formula_names end |
.link_status_to_check(formula, options) ⇒ Boolean?
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.
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'bundle/brew.rb', line 93 def link_status_to_check(formula, ) unless .key?(:link) return case formula_dump_link_status(formula) when true false when false true end end expected_link_status?([:link], keg_only: installed_formula(formula).keg_only?) end |
.no_upgrade_with_args?(no_upgrade, formula_name) ⇒ Boolean
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.
138 139 140 |
# File 'bundle/brew.rb', line 138 def no_upgrade_with_args?(no_upgrade, formula_name) no_upgrade && Bundle.upgrade_formulae.exclude?(formula_name) end |
.outdated_formulae ⇒ Array<String>
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.
212 213 214 |
# File 'bundle/brew.rb', line 212 def outdated_formulae @outdated_formulae ||= formulae.filter_map { |f| f[:name] if f[:outdated?] } end |
.pinned_formulae ⇒ Array<String>
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.
217 218 219 |
# File 'bundle/brew.rb', line 217 def pinned_formulae @pinned_formulae ||= formulae.filter_map { |f| f[:name] if f[:pinned?] } end |
.preinstall!(name, no_upgrade: false, verbose: false, **options) ⇒ Boolean
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.
57 58 59 |
# File 'bundle/brew.rb', line 57 def preinstall!(name, no_upgrade: false, verbose: false, **) new(name, ).preinstall!(no_upgrade:, verbose:) end |
.reset! ⇒ 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'bundle/brew.rb', line 32 def reset! require "bundle/brew_services" Homebrew::Bundle::Brew::Services.reset! @installed_formulae = T.let(nil, T.nilable(T::Array[String])) @outdated_formulae = T.let(nil, T.nilable(T::Array[String])) @pinned_formulae = T.let(nil, T.nilable(T::Array[String])) @formulae = T.let(nil, T.nilable(T::Array[T::Hash[Symbol, T.untyped]])) @formulae_by_full_name = T.let(nil, T.nilable(T::Hash[String, T::Hash[Symbol, T.untyped]])) @formulae_by_name = T.let(nil, T.nilable(T::Hash[String, T::Hash[Symbol, T.untyped]])) @formula_aliases = T.let(nil, T.nilable(T::Hash[String, String])) @formula_oldnames = T.let(nil, T.nilable(T::Hash[String, String])) end |
.type ⇒ Symbol
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.
19 |
# File 'bundle/brew.rb', line 19 def type = :brew |
.upgradable_formulae ⇒ Array<String>
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.
207 208 209 |
# File 'bundle/brew.rb', line 207 def upgradable_formulae outdated_formulae - pinned_formulae end |
Instance Method Details
#changed? ⇒ Boolean
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.
674 675 676 |
# File 'bundle/brew.rb', line 674 def changed? @changed.present? end |
#failure_reason(name, no_upgrade:) ⇒ String
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.
523 524 525 526 527 528 529 530 531 532 533 |
# File 'bundle/brew.rb', line 523 def failure_reason(name, no_upgrade:) formula = formula_name(name) = (name) return super(formula, no_upgrade:) unless self.class.formula_installed_and_up_to_date?(formula, no_upgrade:) link_status = self.class.link_status_to_check(formula, ) return super(formula, no_upgrade:) if link_status.nil? link_status = link_status ? "linked" : "unlinked" "Formula #{formula} needs to be #{link_status}." end |
#find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Array<String>
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.
543 544 545 546 547 548 549 550 551 |
# File 'bundle/brew.rb', line 543 def find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) requested = instance_of?(Homebrew::Bundle::Brew) ? checkable_entries(entries) : format_checkable(entries) if exit_on_first_error exit_early_check(requested, no_upgrade:) else full_check(requested, no_upgrade:) end end |
#install!(preinstall: true, no_upgrade: false, verbose: false, force: false) ⇒ Boolean
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.
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'bundle/brew.rb', line 570 def install!(preinstall: true, no_upgrade: false, verbose: false, force: false) if preinstall && installed? && self.class.formula_tap_changed?(@full_name) && self.class.formula_pinned?(@full_name) self.class.onoe "#{@name} is pinned. Run `brew unpin --formula #{@name}` before changing taps." return false end # An installed pinned entry only needs its pin unless its requested tap changed. install_result = if preinstall && (!@pin || !installed? || self.class.formula_tap_changed?(@full_name)) install_change_state!(no_upgrade:, verbose:, force:) else true end result = install_result if installed? service_result = service_change_state!(verbose:) result &&= service_result link_result = link_change_state!(verbose:) result &&= link_result pin_result = pin_change_state!(verbose:) result &&= pin_result postinstall_result = postinstall_change_state!(verbose:) result &&= postinstall_result if result && @version_file.present? # Use the version from the environment if it hasn't changed. # Strip the revision number because it's not part of the non-Homebrew version. version = if !changed? && (env_version = Bundle.formula_versions_from_env(@name)) PkgVersion.parse(env_version).version else self.class.installed_formula(@full_name).version end.to_s File.write(@version_file, "#{version}\n") puts "Wrote #{@name} version #{version} to #{@version_file}" if verbose end end result end |
#install_change_state!(no_upgrade:, verbose:, force:) ⇒ Boolean
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.
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
# File 'bundle/brew.rb', line 616 def install_change_state!(no_upgrade:, verbose:, force:) require "tap" # Trust before tapping: installing the tap loads the formula, which # triggers the trust check before any later step could grant trust. # Only fully-qualified names map to a tap, so unqualified names cannot # be meaningfully trusted. Homebrew::Trust.trust!(:formula, @full_name) if @trusted && Utils.full_name?(@full_name) if (tap_with_name = ::Tap.with_formula_name(@full_name)) tap, = tap_with_name tap.ensure_installed! end return false unless resolve_conflicts!(verbose:) if installed? && self.class.formula_tap_changed?(@full_name) reinstall_args = @args.dup reinstall_args << "--force" if force @changed = Bundle.brew("reinstall", "--formula", @full_name, *reinstall_args, verbose:) return false unless @changed Tab.clear_cache Formula.clear_cache self.class.reset! true elsif installed? upgrade_formula!(verbose:, force:) else install_formula!(verbose:, force:) end end |
#installed_and_up_to_date?(formula, no_upgrade: false) ⇒ Boolean
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.
511 512 513 514 515 516 517 518 519 520 |
# File 'bundle/brew.rb', line 511 def installed_and_up_to_date?(formula, no_upgrade: false) name = formula_name(formula) return false unless self.class.formula_installed_and_up_to_date?(name, no_upgrade:) = (formula) link_status = self.class.link_status_to_check(name, ) return true if link_status.nil? self.class.installed_formula(name).linked? == link_status end |
#link_change_state!(verbose: false) ⇒ Boolean
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.
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
# File 'bundle/brew.rb', line 696 def link_change_state!(verbose: false) link_args = [] link_status = self.class.expected_link_status?(@link, keg_only: keg_only?) cmd = if link_status link_args << "--force" if !linked? && keg_only? link_args << "--overwrite" if @link == :overwrite "link" unless linked? elsif linked? "unlink" end if cmd.present? verb = "#{cmd}ing".capitalize with_args = " with #{link_args.join(" ")}" if link_args.present? puts "#{verb} #{@name} formula#{with_args}." if verbose return Bundle.brew(cmd, *link_args, @name, verbose:) end true end |
#pin_change_state!(verbose:) ⇒ Boolean
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.
732 733 734 735 736 737 |
# File 'bundle/brew.rb', line 732 def pin_change_state!(verbose:) return true unless pin_needed? puts "Pinning #{@name} formula." if verbose Bundle.brew("pin", "--formula", @full_name, verbose:) end |
#pin_needed? ⇒ Boolean
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.
727 728 729 |
# File 'bundle/brew.rb', line 727 def pin_needed? @pin && !self.class.formula_pinned?(@full_name) end |
#postinstall_change_state!(verbose:) ⇒ Boolean
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.
718 719 720 721 722 723 724 |
# File 'bundle/brew.rb', line 718 def postinstall_change_state!(verbose:) return true if @postinstall.blank? return true unless changed? puts "Running postinstall for #{@name}: #{@postinstall}" if verbose Kernel.system(@postinstall) || false end |
#preinstall!(no_upgrade: false, verbose: false) ⇒ Boolean
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.
554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'bundle/brew.rb', line 554 def preinstall!(no_upgrade: false, verbose: false) return true if self.class.formula_tap_changed?(@full_name) if installed? && (self.class.no_upgrade_with_args?(no_upgrade, @name) || @pin || !self.class.formula_upgradable?(@full_name)) return true if pin_needed? puts "Skipping install of #{@name} formula. It is already installed." if verbose @changed = nil return false end true end |
#restart_service? ⇒ Boolean
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.
661 662 663 |
# File 'bundle/brew.rb', line 661 def restart_service? @restart_service.present? end |
#restart_service_needed? ⇒ Boolean
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.
666 667 668 669 670 671 |
# File 'bundle/brew.rb', line 666 def restart_service_needed? return false unless restart_service? # Restart if `restart_service: :always`, or if the formula was installed or upgraded @restart_service.to_s == "always" || changed? end |
#service_change_state!(verbose:) ⇒ Boolean
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.
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 |
# File 'bundle/brew.rb', line 679 def service_change_state!(verbose:) require "bundle/brew_services" file = Services.versioned_service_file(@name)&.to_s if restart_service_needed? puts "Restarting #{@name} service." if verbose Services.restart(@full_name, file:, verbose:) elsif start_service_needed? puts "Starting #{@name} service." if verbose Services.start(@full_name, file:, verbose:) else true end end |
#start_service? ⇒ Boolean
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.
650 651 652 |
# File 'bundle/brew.rb', line 650 def start_service? @start_service.present? end |
#start_service_needed? ⇒ Boolean
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.
655 656 657 658 |
# File 'bundle/brew.rb', line 655 def start_service_needed? require "bundle/brew_services" start_service? && !Services.started?(@full_name) end |