Class: Utils::Bottles::Tag Private

Inherits:
Object show all
Defined in:
utils/bottles.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Denotes the arch and OS of a bottle.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(system:, arch:) ⇒ 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.

Parameters:



180
181
182
183
# File 'utils/bottles.rb', line 180

def initialize(system:, arch:)
  @system = system
  @arch = arch
end

Instance Attribute Details

#archSymbol (readonly)

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.

Returns:



158
159
160
# File 'utils/bottles.rb', line 158

def arch
  @arch
end

#systemSymbol (readonly)

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.

Returns:



158
159
160
# File 'utils/bottles.rb', line 158

def system
  @system
end

Class Method Details

.from_symbol(value) ⇒ T.attached_class

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:

  • (T.attached_class)

Raises:

  • (ArgumentError)


161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'utils/bottles.rb', line 161

def self.from_symbol(value)
  return new(system: :all, arch: :all) if value == :all

  @all_archs_regex ||= T.let(begin
    all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
    /
      ^((?<arch>#{Regexp.union(all_archs)})_)?
      (?<system>[\w.]+)$
    /x
  end, T.nilable(Regexp))
  match = @all_archs_regex.match(value.to_s)
  raise ArgumentError, "Invalid bottle tag symbol" unless match

  system = T.must(match[:system]).to_sym
  arch = match[:arch]&.to_sym || :x86_64
  new(system:, arch:)
end

Instance Method Details

#default_cellarString

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.

Returns:



273
274
275
276
277
278
279
280
281
# File 'utils/bottles.rb', line 273

def default_cellar
  if linux?
    Homebrew::DEFAULT_LINUX_CELLAR
  elsif standardized_arch == :arm64
    Homebrew::DEFAULT_MACOS_ARM_CELLAR
  else
    Homebrew::DEFAULT_MACOS_CELLAR
  end
end

#default_prefixString

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.

Returns:



262
263
264
265
266
267
268
269
270
# File 'utils/bottles.rb', line 262

def default_prefix
  if linux?
    HOMEBREW_LINUX_DEFAULT_PREFIX
  elsif standardized_arch == :arm64
    HOMEBREW_MACOS_ARM_DEFAULT_PREFIX
  else
    HOMEBREW_DEFAULT_PREFIX
  end
end

#linux?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.

Returns:

  • (Boolean)


243
244
245
# File 'utils/bottles.rb', line 243

def linux?
  system == :linux
end

#macos?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.

Returns:

  • (Boolean)


248
249
250
# File 'utils/bottles.rb', line 248

def macos?
  MacOSVersion::SYMBOLS.key?(system)
end

#standardized_archSymbol

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.

Returns:



211
212
213
214
215
216
# File 'utils/bottles.rb', line 211

def standardized_arch
  return :x86_64 if [:x86_64, :intel].include? arch
  return :arm64 if [:arm64, :arm, :aarch64].include? arch

  arch
end

#to_macos_versionMacOSVersion

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.

Returns:



238
239
240
# File 'utils/bottles.rb', line 238

def to_macos_version
  @to_macos_version ||= T.let(MacOSVersion.from_symbol(system), T.nilable(MacOSVersion))
end

#to_symSymbol

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.

Returns:



219
220
221
# File 'utils/bottles.rb', line 219

def to_sym
  arch_to_symbol(standardized_arch)
end

#to_unstandardized_symSymbol

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.

Returns:



229
230
231
232
233
234
235
# File 'utils/bottles.rb', line 229

def to_unstandardized_sym
  # Never allow these generic names
  return to_sym if [:intel, :arm].include? arch

  # Backwards compatibility with older bottle names
  arch_to_symbol(arch)
end

#valid_combination?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.

Returns:

  • (Boolean)


253
254
255
256
257
258
259
# File 'utils/bottles.rb', line 253

def valid_combination?
  return true unless [:arm64, :arm, :aarch64].include? arch
  return true unless macos?

  # Big Sur is the first version of macOS that runs on ARM
  to_macos_version >= :big_sur
end