Class: Resource::BottleManifest Private

Inherits:
Resource
  • Object
show all
Defined in:
resource.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.

A resource for a bottle manifest.

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bottle) ⇒ 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:



400
401
402
403
404
# File 'resource.rb', line 400

def initialize(bottle)
  super("#{bottle.name}_bottle_manifest")
  @bottle = bottle
  @manifest_annotations = T.let(nil, T.nilable(T::Hash[String, String]))
end

Instance Attribute Details

#bottleBottle (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:



394
395
396
# File 'resource.rb', line 394

def bottle
  @bottle
end

#manifest_annotations=(value) ⇒ 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.



397
398
399
# File 'resource.rb', line 397

def manifest_annotations=(value)
  @manifest_annotations = value
end

Instance Method Details

#bottle_sizeInteger?

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:



442
443
444
# File 'resource.rb', line 442

def bottle_size
  manifest_annotations["sh.brew.bottle.size"]&.to_i
end

#clear_cachevoid

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.



407
408
409
410
# File 'resource.rb', line 407

def clear_cache
  super
  @manifest_annotations = nil
end

#download_queue_nameString

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:



480
# File 'resource.rb', line 480

def download_queue_name = "#{bottle.name} (#{bottle.resource.version})"

#download_queue_typeString

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:



477
# File 'resource.rb', line 477

def download_queue_type = "Bottle Manifest"

#downloaded_and_valid?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)


419
420
421
422
423
424
425
426
427
# File 'resource.rb', line 419

def downloaded_and_valid?
  return false unless downloaded?

  with_context(quiet: true) { verify_download_integrity(cached_download) }
  true
rescue Error
  clear_cache
  false
end

#installed_sizeInteger?

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:



447
448
449
# File 'resource.rb', line 447

def installed_size
  manifest_annotations["sh.brew.bottle.installed_size"]&.to_i
end

#path_exec_filesArray<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:



452
453
454
# File 'resource.rb', line 452

def path_exec_files
  manifest_annotations["sh.brew.path_exec_files"]&.split(",")
end

#sbom_supplementHash{String => Object}?

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:



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'resource.rb', line 457

def sbom_supplement
  supplement = manifest_annotations["sh.brew.sbom.supplement"]
  return if supplement.blank?

  parsed_supplement = JSON.parse(supplement)
  return unless parsed_supplement.is_a?(Hash)

  if (tags = parsed_supplement["tags"]).is_a?(Hash)
    tag_supplement = tags[Utils::Bottles.tag.to_s]
    return tag_supplement if tag_supplement.is_a?(Hash)

    return
  end

  parsed_supplement
rescue JSON::ParserError
  nil
end

#tabHash{String => 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.

Returns:

Raises:



430
431
432
433
434
435
436
437
438
439
# File 'resource.rb', line 430

def tab
  tab = manifest_annotations["sh.brew.tab"]
  raise Error, "Couldn't find tab from manifest." if tab.blank?

  begin
    JSON.parse(tab)
  rescue JSON::ParserError
    raise Error, "Couldn't parse tab JSON."
  end
end

#verify_download_integrity(_filename) ⇒ 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.

Parameters:



413
414
415
416
# File 'resource.rb', line 413

def verify_download_integrity(_filename)
  # We don't have a checksum, but we can at least try parsing it.
  tab
end