Module: Homebrew::Bundle Private
- Defined in:
- bundle.rb,
bundle/dsl.rb,
bundle/tap.rb,
bundle/brew.rb,
bundle/cask.rb,
bundle/adder.rb,
bundle/trust.rb,
bundle/dumper.rb,
bundle/lister.rb,
bundle/checker.rb,
bundle/remover.rb,
bundle/skipper.rb,
bundle/brewfile.rb,
bundle/installer.rb,
bundle/package_type.rb,
bundle/brew_services.rb,
bundle/extensions/go.rb,
bundle/extensions/uv.rb,
bundle/extensions/npm.rb,
bundle/extensions/krew.rb,
bundle/extensions/cargo.rb,
bundle/extensions/winget.rb,
bundle/extensions/flatpak.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, Dumper, Installer, Lister, Remover, Skipper, Trust Classes: Brew, Cargo, Cask, Dsl, Extension, Flatpak, Go, Krew, MacAppStore, Npm, PackageType, Tap, Uv, VscodeExtension, Winget
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.
189 190 191 192 |
# File 'bundle/package_type.rb', line 189 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 83 84 |
# 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 passwd = Etc.getpwuid(uid) raise "Could not find the home directory for UID #{uid}" if passwd.nil? return_value = with_env("HOME" => passwd.dir, &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.
381 382 383 384 |
# File 'bundle/extensions/extension.rb', line 381 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.
375 376 377 378 |
# File 'bundle/extensions/extension.rb', line 375 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.
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 |
# File 'bundle.rb', line 87 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.
115 116 117 |
# File 'bundle.rb', line 115 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.
120 121 122 |
# File 'bundle.rb', line 120 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.
391 392 393 |
# File 'bundle/extensions/extension.rb', line 391 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.
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 173 174 |
# File 'bundle.rb', line 137 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 unless 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.
183 184 185 186 |
# File 'bundle/package_type.rb', line 183 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.
177 178 179 180 |
# File 'bundle/package_type.rb', line 177 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.
125 |
# File 'bundle.rb', line 125 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.
368 369 370 371 372 |
# File 'bundle/extensions/extension.rb', line 368 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.
170 171 172 173 174 |
# File 'bundle/package_type.rb', line 170 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.
128 129 130 131 132 |
# File 'bundle.rb', line 128 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 |