Module: Homebrew::Bundle::Installer Private
- Extended by:
- Utils::Output::Mixin
- Defined in:
- bundle/installer.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: InstallableEntry
Class Method Summary collapse
- .fetchable_formulae_and_casks(entries, no_upgrade:) ⇒ Array<String> private
- .install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, jobs: 1, quiet: false) ⇒ Boolean private
- .reset! ⇒ void private
- .tap_dependencies(entry, entries:, installed_taps:) ⇒ Array<String> private
Methods included from Utils::Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_uninstalled, pretty_upgradable
Class Method Details
.fetchable_formulae_and_casks(entries, no_upgrade:) ⇒ 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.
131 132 133 134 135 136 137 138 139 |
# File 'bundle/installer.rb', line 131 def self.fetchable_formulae_and_casks(entries, no_upgrade:) installed_taps = Tap.installed_taps entries.filter_map do |entry| next if tap_dependencies(entry, entries:, installed_taps:).present? entry.cls.fetchable_name(entry.name, entry., no_upgrade:) end end |
.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, jobs: 1, quiet: 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.
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 |
# File 'bundle/installer.rb', line 53 def self.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, jobs: 1, quiet: false) success = 0 failure = 0 installable_entries = T.let([], T::Array[InstallableEntry]) installable_brewfile_entries = T.let([], T::Array[Dsl::Entry]) entries.each do |entry| next if Homebrew::Bundle::Skipper.skip? entry name = entry.name = entry. type = entry.type cls = Homebrew::Bundle.installable(type) next if cls.nil? || !cls.install_supported? installable_brewfile_entries << entry installable_entries << InstallableEntry.new(name:, options:, verb: cls.install_verb(name, ), cls:) end # Apply `trusted: true` Brewfile options before anything fetches or # loads the entries: the fetch phase and upgrade checks load formulae # and casks, which triggers the tap trust check before the per-entry # install step could grant trust. Homebrew::Bundle::Trust.entries(installable_brewfile_entries).each do |type, name| Homebrew::Trust.trust!(type, name) end if (fetchable_names = fetchable_formulae_and_casks(installable_entries, no_upgrade:).presence) fetchable_names_joined = fetchable_names.join(", ") puts Formatter.success("Fetching #{fetchable_names_joined}") unless quiet unless Bundle.brew("fetch", *fetchable_names, verbose:) $stderr.puts Formatter.error "`brew bundle` failed! Failed to fetch #{fetchable_names_joined}" return false end end if jobs > 1 && installable_entries.size > 1 require "bundle/parallel_installer" parallel = ParallelInstaller.new( installable_entries, jobs:, no_upgrade:, verbose:, force:, quiet: ) parallel_success, parallel_failure = parallel.run! success += parallel_success failure += parallel_failure else installable_entries.each do |entry| if install_entry!(entry, no_upgrade:, verbose:, force:, quiet:) success += 1 else failure += 1 end end end unless failure.zero? require "utils" dependency = Utils.pluralize("dependency", failure) $stderr.puts Formatter.error "`brew bundle` failed! #{failure} Brewfile #{dependency} failed to install" return false end unless quiet require "utils" dependency = Utils.pluralize("dependency", success) puts Formatter.success "`brew bundle` complete! #{success} Brewfile #{dependency} now installed." end true 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.
34 35 36 37 38 |
# File 'bundle/installer.rb', line 34 def self.reset! Homebrew::Bundle.reset! Homebrew::Bundle::Cask.reset! Homebrew::Bundle::Tap.reset! end |
.tap_dependencies(entry, entries:, installed_taps:) ⇒ 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.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'bundle/installer.rb', line 148 def self.tap_dependencies(entry, entries:, installed_taps:) return [] unless [Brew, Cask].include?(entry.cls) if (tap_name = entry.tap_name) return installed_taps.exclude?(tap_name) ? [tap_name] : [] end tap_names = entries.filter_map do |tap_entry| tap_entry.name if tap_entry.cls == Tap && installed_taps.exclude?(tap_entry.name) end return [] if tap_names.empty? return [] unless unavailable_without_tap?(entry) tap_names end |