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:



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

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

Instance Attribute Details

#arch ⇒ Symbol (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:



200
201
202
# File 'utils/bottles.rb', line 200

def arch
  @arch
end

#system ⇒ Symbol (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:



200
201
202
# File 'utils/bottles.rb', line 200

def system
  @system
end

Class Method Details

.from_arg(arg, os:, arch:) ⇒ 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)


222
223
224
225
226
227
228
# File 'utils/bottles.rb', line 222

def self.from_arg(arg, os:, arch:)
  if arg
    from_symbol(arg)
  else
    new(system: os, arch:)
  end
end

.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)


203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'utils/bottles.rb', line 203

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

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

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

Instance Method Details

#default_cellar ⇒ 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.

Returns:



318
319
320
321
322
323
324
325
326
# File 'utils/bottles.rb', line 318

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_prefix ⇒ 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.

Returns:



304
305
306
307
308
309
310
311
312
313
314
315
# File 'utils/bottles.rb', line 304

def default_prefix
  prefix = if linux?
    HOMEBREW_LINUX_DEFAULT_PREFIX
  elsif standardized_arch == :arm64
    HOMEBREW_MACOS_ARM_DEFAULT_PREFIX
  else
    HOMEBREW_DEFAULT_PREFIX
  end
  raise "No default prefix is known for #{self}: HOMEBREW_*_DEFAULT_PREFIX is unset" if prefix.nil?

  prefix
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)


294
295
296
# File 'utils/bottles.rb', line 294

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)


299
300
301
# File 'utils/bottles.rb', line 299

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

#padded_prefix ⇒ 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.

Returns:



329
330
331
332
333
334
335
336
337
338
# File 'utils/bottles.rb', line 329

def padded_prefix
  if linux?
    case standardized_arch
    when :arm64 then Homebrew::LINUX_ARM64_BOTTLE_PREFIX
    when :x86_64 then Homebrew::LINUX_X86_64_BOTTLE_PREFIX
    end
  elsif macos? && standardized_arch == :arm64
    Homebrew::MACOS_ARM64_BOTTLE_PREFIX
  end
end

#standardized_arch ⇒ Symbol

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
# File 'utils/bottles.rb', line 262

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

  arch
end

#to_macos_version ⇒ MacOSVersion

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:



289
290
291
# File 'utils/bottles.rb', line 289

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

#to_sym ⇒ Symbol

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:



270
271
272
# File 'utils/bottles.rb', line 270

def to_sym
  arch_to_symbol(standardized_arch)
end

#to_unstandardized_sym ⇒ Symbol

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:



280
281
282
283
284
285
286
# File 'utils/bottles.rb', line 280

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