Module: Homebrew::Bundle Private
- Defined in:
- bundle.rb,
bundle/dsl.rb,
bundle/tap.rb,
bundle/brew.rb,
bundle/cask.rb,
bundle/adder.rb,
bundle/dumper.rb,
bundle/lister.rb,
bundle/checker.rb,
bundle/remover.rb,
bundle/skipper.rb,
bundle/brewfile.rb,
bundle/installer.rb,
bundle/commands/add.rb,
bundle/package_type.rb,
bundle/brew_services.rb,
bundle/commands/dump.rb,
bundle/commands/exec.rb,
bundle/commands/list.rb,
bundle/extensions/go.rb,
bundle/extensions/uv.rb,
bundle/commands/check.rb,
bundle/extensions/npm.rb,
bundle/commands/remove.rb,
bundle/extensions/krew.rb,
bundle/commands/cleanup.rb,
bundle/commands/install.rb,
bundle/extensions/cargo.rb,
bundle/extensions/flatpak.rb,
bundle/parallel_installer.rb,
bundle/extensions/extension.rb,
bundle/extensions/mac_app_store.rb,
bundle/extensions/vscode_extension.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
Modules: Adder, Brewfile, Checker, Commands, Dumper, Installer, Lister, Remover, Skipper Classes: Brew, Cargo, Cask, Dsl, Extension, Flatpak, Go, Krew, MacAppStore, Npm, PackageType, ParallelInstaller, Tap, Uv, VscodeExtension
Constant Summary collapse
- EntryOptionScalar =
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.
T.type_alias { T.nilable(T.any(String, Integer, Symbol, TrueClass, FalseClass)) }
- NestedEntryOptionValue =
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.
T.type_alias { T.any(EntryOptionScalar, T::Array[String]) }
- NestedEntryOptions =
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.
T.type_alias { T::Hash[Symbol, NestedEntryOptionValue] }
- EntryOption =
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.
T.type_alias { T.any(EntryOptionScalar, T::Array[String], NestedEntryOptions) }
- EntryOptions =
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.
T.type_alias { T::Hash[Symbol, EntryOption] }
- EntryInputOptions =
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.
T.type_alias { T::Hash[Symbol, Object] }
- ExtensionTypes =
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.
T.type_alias { T::Hash[Symbol, T::Boolean] }
Class Method Summary collapse
- .brew(*args, verbose: false) ⇒ Boolean private
- .cask_installed? ⇒ Boolean private
- .dump_package_types ⇒ Array<T.class_of(PackageType)> private
- .exchange_uid_if_needed!(&block) ⇒ T.untyped private
- .extension(type) ⇒ T.class_of(Extension)? private
- .extensions ⇒ Array<T.class_of(Extension)> private
- .formula_versions_from_env(formula_name) ⇒ String? private
- .formula_versions_from_env_cache ⇒ Hash{String => String}? private
- .formula_versions_from_env_cache=(formula_versions) ⇒ void private
- .installable(type) ⇒ T.class_of(PackageType)? private
-
.mark_as_installed_on_request!(entries) ⇒ void
private
Marks Brewfile formulae as installed_on_request to prevent autoremove from removing them when their dependents are uninstalled.
- .package_type(type) ⇒ T.class_of(PackageType)? private
- .package_types ⇒ Array<T.class_of(PackageType)> private
- .prepend_pkgconf_path_if_needed! ⇒ void private
- .register_extension(extension) ⇒ void private
- .register_package_type(package_type) ⇒ void private
- .reset! ⇒ void private
- .system(cmd, *args, verbose: false) ⇒ Boolean private
- .upgrade_formulae ⇒ Array<String> private
- .upgrade_formulae=(args_upgrade_formula) ⇒ void private
Class Method Details
.brew(*args, 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.
47 48 49 |
# File 'bundle.rb', line 47 def brew(*args, verbose: false) system(HOMEBREW_BREW_FILE, *args, verbose:) end |
.cask_installed? ⇒ 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.
52 53 54 55 56 |
# File 'bundle.rb', line 52 def cask_installed? @cask_installed ||= File.directory?("#{HOMEBREW_PREFIX}/Caskroom") && (File.directory?("#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask") || !Homebrew::EnvConfig.no_install_from_api?) end |
.dump_package_types ⇒ Array<T.class_of(PackageType)>
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.
199 200 201 202 |
# File 'bundle/package_type.rb', line 199 def dump_package_types core_package_types = [:tap, :brew, :cask].filter_map { |type| package_type(type) } (core_package_types + (package_types - core_package_types)).uniq end |
.exchange_uid_if_needed!(&block) ⇒ 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.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'bundle.rb', line 59 def exchange_uid_if_needed!(&block) euid = Process.euid uid = Process.uid return yield if euid == uid old_euid = euid process_reexchangeable = Process::UID.re_exchangeable? if process_reexchangeable Process::UID.re_exchange else Process::Sys.seteuid(uid) end home = T.must(Etc.getpwuid(Process.uid)).dir return_value = with_env("HOME" => home, &block) if process_reexchangeable Process::UID.re_exchange else Process::Sys.seteuid(old_euid) end return_value end |
.extension(type) ⇒ T.class_of(Extension)?
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.
387 388 389 390 |
# File 'bundle/extensions/extension.rb', line 387 def extension(type) requested_type = type.to_sym extensions.find { |registered| registered.type == requested_type } end |
.extensions ⇒ Array<T.class_of(Extension)>
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.
381 382 383 384 |
# File 'bundle/extensions/extension.rb', line 381 def extensions @extensions ||= T.let([], T.nilable(T::Array[T.class_of(Extension)])) @extensions end |
.formula_versions_from_env(formula_name) ⇒ 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.
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 |
# File 'bundle.rb', line 85 def formula_versions_from_env(formula_name) @formula_versions_from_env ||= begin formula_versions = {} ENV.each do |key, value| match = key.match(/^HOMEBREW_BUNDLE_FORMULA_VERSION_(.+)$/) next if match.blank? env_formula_name = match[1] next if env_formula_name.blank? ENV.delete(key) formula_versions[env_formula_name] = value end formula_versions end # Fix up formula name for a valid environment variable name. formula_env_name = formula_name.upcase .gsub("@", "AT") .tr("+", "X") .tr("-", "_") @formula_versions_from_env[formula_env_name] end |
.formula_versions_from_env_cache ⇒ 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.
113 114 115 |
# File 'bundle.rb', line 113 def formula_versions_from_env_cache @formula_versions_from_env end |
.formula_versions_from_env_cache=(formula_versions) ⇒ 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.
118 119 120 |
# File 'bundle.rb', line 118 def formula_versions_from_env_cache=(formula_versions) @formula_versions_from_env = formula_versions end |
.installable(type) ⇒ T.class_of(PackageType)?
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.
397 398 399 |
# File 'bundle/extensions/extension.rb', line 397 def installable(type) package_type(type) || extension(type) end |
.mark_as_installed_on_request!(entries) ⇒ 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.
Marks Brewfile formulae as installed_on_request to prevent autoremove from removing them when their dependents are uninstalled.
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 169 170 171 172 |
# File 'bundle.rb', line 135 def mark_as_installed_on_request!(entries) return if entries.empty? require "tab" installed_formulae = Formula.installed_formula_names return if installed_formulae.empty? use_brew_tab = T.let(false, T::Boolean) formulae_to_update = entries.filter_map do |entry| next if entry.type != :brew name = entry.name next if installed_formulae.exclude?(name) tab = Tab.for_name(name) tabfile = tab.tabfile next if tabfile.blank? || !tabfile.exist? next if tab.installed_on_request next name if use_brew_tab tab.installed_on_request = true begin tab.write nil rescue Errno::EACCES # Some wrappers might treat `brew bundle` with lower permissions due to its execution of user code. # Running through `brew tab` ensures proper privilege escalation by going through the wrapper again. use_brew_tab = true name end end brew "tab", "--installed-on-request", *formulae_to_update if use_brew_tab end |
.package_type(type) ⇒ T.class_of(PackageType)?
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.
193 194 195 196 |
# File 'bundle/package_type.rb', line 193 def package_type(type) requested_type = type.to_sym package_types.find { |registered| registered.type == requested_type } end |
.package_types ⇒ Array<T.class_of(PackageType)>
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.
187 188 189 190 |
# File 'bundle/package_type.rb', line 187 def package_types @package_types ||= T.let([], T.nilable(T::Array[T.class_of(PackageType)])) @package_types end |
.prepend_pkgconf_path_if_needed! ⇒ 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.
123 |
# File 'bundle.rb', line 123 def prepend_pkgconf_path_if_needed!; end |
.register_extension(extension) ⇒ 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.
374 375 376 377 378 |
# File 'bundle/extensions/extension.rb', line 374 def register_extension(extension) @extensions ||= T.let([], T.nilable(T::Array[T.class_of(Extension)])) @extensions.reject! { |registered| registered.name == extension.name } @extensions << extension end |
.register_package_type(package_type) ⇒ 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.
180 181 182 183 184 |
# File 'bundle/package_type.rb', line 180 def register_package_type(package_type) @package_types ||= T.let([], T.nilable(T::Array[T.class_of(PackageType)])) @package_types.reject! { |registered| registered.name == package_type.name } @package_types << package_type 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.
126 127 128 129 130 |
# File 'bundle.rb', line 126 def reset! @cask_installed = T.let(nil, T.nilable(T::Boolean)) @formula_versions_from_env = T.let(nil, T.nilable(T::Hash[String, String])) @upgrade_formulae = T.let(nil, T.nilable(T::Array[String])) end |
.system(cmd, *args, 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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'bundle.rb', line 20 def system(cmd, *args, verbose: false) return super cmd, *args if verbose env = {} # Make sure node's bin opt path is part of the PATH # This is essential for the npm bundle extension that calls node directly if Npm.package_manager_executable && cmd.to_s == Npm.package_manager_executable.to_s node_bin = "#{HOMEBREW_PREFIX}/opt/node/bin" env["PATH"] = "#{ENV.fetch("PATH")}:#{node_bin}" end logs = [] success = T.let(false, T::Boolean) IO.popen(env, [cmd, *args], err: [:child, :out]) do |pipe| while (buf = pipe.gets) logs << buf end Process.wait(pipe.pid) success = $CHILD_STATUS.success? pipe.close end puts logs.join unless success success end |
.upgrade_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.
15 16 17 |
# File 'bundle.rb', line 15 def upgrade_formulae @upgrade_formulae || [] end |
.upgrade_formulae=(args_upgrade_formula) ⇒ 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.
10 11 12 |
# File 'bundle.rb', line 10 def upgrade_formulae=(args_upgrade_formula) @upgrade_formulae = args_upgrade_formula.to_s.split(",") end |