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/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, 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
- .check_package_types ⇒ Array<T.class_of(PackageType)> 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
- .which_formula?(name) ⇒ Boolean 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.
38 39 40 |
# File 'bundle.rb', line 38 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.
43 44 45 46 47 |
# File 'bundle.rb', line 43 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 |
.check_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.
205 206 207 208 209 210 211 212 213 214 215 |
# File 'bundle/package_type.rb', line 205 def check_package_types taps = package_type(:tap) casks = package_type(:cask) formulae = package_type(:brew) leading_package_types = [taps, casks].compact trailing_package_types = [formulae].compact leading_package_types + (package_types - leading_package_types - trailing_package_types) + trailing_package_types 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.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'bundle.rb', line 57 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.
363 364 365 366 |
# File 'bundle/extensions/extension.rb', line 363 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.
357 358 359 360 |
# File 'bundle/extensions/extension.rb', line 357 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.
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 |
# File 'bundle.rb', line 83 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.
111 112 113 |
# File 'bundle.rb', line 111 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.
116 117 118 |
# File 'bundle.rb', line 116 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.
373 374 375 |
# File 'bundle/extensions/extension.rb', line 373 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.
133 134 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 |
# File 'bundle.rb', line 133 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) next if tab.tabfile.blank? || !tab.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.
121 |
# File 'bundle.rb', line 121 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.
350 351 352 353 354 |
# File 'bundle/extensions/extension.rb', line 350 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.
124 125 126 127 128 |
# File 'bundle.rb', line 124 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 |
# File 'bundle.rb', line 20 def system(cmd, *args, verbose: false) return super cmd, *args if verbose logs = [] success = T.let(false, T::Boolean) IO.popen([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 |
.which_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.
50 51 52 53 54 |
# File 'bundle.rb', line 50 def which_formula?(name) formula = Formulary.factory(name) ENV["PATH"] = "#{formula.opt_bin}:#{ENV.fetch("PATH", nil)}" if formula.any_version_installed? which(name).present? end |