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

Constant Summary collapse

BATCHABLE_OPTION_KEYS =

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.

Options that do not change the brew install command line, so entries carrying only these can share one invocation.

[:full_name, :trusted].freeze

Class Method Summary collapse

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_cannot_install, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning

Class Method Details

.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, 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.

Parameters:

  • entries (Array<Dsl::Entry>)
  • global (Boolean) (defaults to: false)
  • file (String, nil) (defaults to: nil)
  • no_lock (Boolean) (defaults to: false)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)
  • quiet (Boolean) (defaults to: false)

Returns:

  • (Boolean)


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
# File 'bundle/installer.rb', line 58

def self.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false,
                  force: false, 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
    options = entry.options
    type = entry.type
    cls = Homebrew::Bundle.installable(type)
    next if cls.nil? || !cls.install_supported?

    installable_brewfile_entries << entry
    installable_entries << InstallableEntry.new(
      entry:, verb: cls.install_verb(name, options), cls:,
      install_name: T.cast(options.fetch(:full_name, name), String)
    )
  end

  # Apply `trusted: true` Brewfile options before anything loads the entries.
  Homebrew::Bundle::Trust.entries(installable_brewfile_entries).each do |type, name|
    Homebrew::Trust.trust!(type, name)
  end

  # Taps first: later entries can live in them, and `ensure_installed!` below
  # needs the ones the Brewfile itself provides to already be present.
  tap_entries, pending_entries = installable_entries.partition { |entry| entry.cls == Tap }
  tap_entries.each do |entry|
    if install_entry!(entry, no_upgrade:, verbose:, force:, quiet:)
      success += 1
    else
      failure += 1
    end
  end
  ::Tap.clear_cache if tap_entries.present?
  installed_taps = ensure_entry_taps_installed!(pending_entries, tap_entries:)
  prepare_attestation_verification!(pending_entries)

  batchable, remaining = pending_entries.partition do |entry|
    homebrew_batchable?(entry, entries: installable_entries, installed_taps:)
  end

  if batchable.present?
    batch_success, batch_failure = batch_install_homebrew!(batchable, no_upgrade:, verbose:, force:, quiet:)
    success += batch_success
    failure += batch_failure
  end

  native_batches, remaining = remaining.partition do |entry|
    entry.cls.batch_installable?(entry.name, entry.options)
  end
  native_batches.group_by(&:cls).each_value do |batch|
    batch_success, batch_failure = batch_install_package_type!(batch, no_upgrade:, verbose:, force:, quiet:)
    success += batch_success
    failure += batch_failure
  end

  remaining.each do |entry|
    if install_entry!(entry, no_upgrade:, verbose:, force:, quiet:)
      success += 1
    else
      failure += 1
    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.



40
41
42
43
44
# File 'bundle/installer.rb', line 40

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.

Parameters:

Returns:



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'bundle/installer.rb', line 150

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