Class: BottleSpecification

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
extend/os/linux/software_spec.rb,
software_spec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid



483
484
485
486
487
488
# File 'software_spec.rb', line 483

def initialize
  @rebuild = 0
  @repository = Homebrew::DEFAULT_REPOSITORY
  @collector = Utils::Bottles::Collector.new
  @root_url_specs = {}
end

Instance Attribute Details

#collectorObject (readonly)

Returns the value of attribute collector.



480
481
482
# File 'software_spec.rb', line 480

def collector
  @collector
end

#repositoryObject (readonly)

Returns the value of attribute repository.



480
481
482
# File 'software_spec.rb', line 480

def repository
  @repository
end

#root_url_specsObject (readonly)

Returns the value of attribute root_url_specs.



480
481
482
# File 'software_spec.rb', line 480

def root_url_specs
  @root_url_specs
end

#tapObject

Returns the value of attribute tap.



479
480
481
# File 'software_spec.rb', line 479

def tap
  @tap
end

Instance Method Details

#checksumsObject



570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'software_spec.rb', line 570

def checksums
  tags = collector.tags.sort_by do |tag|
    version = tag.to_macos_version
    # Give arm64 bottles a higher priority so they are first
    priority = tag.arch == :arm64 ? "2" : "1"
    "#{priority}.#{version}_#{tag}"
  rescue MacOSVersionError
    # Sort non-MacOS tags below MacOS tags.
    "0.#{tag}"
  end
  tags.reverse.map do |tag|
    spec = collector.specification_for(tag)
    {
      "tag"    => spec.tag.to_sym,
      "digest" => spec.checksum,
      "cellar" => spec.cellar,
    }
  end
end

#compatible_locations?(tag: Utils::Bottles.tag) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'software_spec.rb', line 508

def compatible_locations?(tag: Utils::Bottles.tag)
  spec = collector.specification_for(tag)
  cellar = if spec.present?
    spec.cellar
  else
    tag.default_cellar
  end

  return true if [:any, :any_skip_relocation].include?(cellar)

  prefix = Pathname(cellar).parent.to_s

  compatible_cellar = cellar == HOMEBREW_CELLAR.to_s
  compatible_prefix = prefix == HOMEBREW_PREFIX.to_s

  compatible_cellar && compatible_prefix
end

#root_url(var = nil, specs = {}) ⇒ Object



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'software_spec.rb', line 490

def root_url(var = nil, specs = {})
  if var.nil?
    @root_url ||= if (github_packages_url = GitHubPackages.root_url_if_match(Homebrew::EnvConfig.bottle_domain))
      github_packages_url
    else
      Homebrew::EnvConfig.bottle_domain
    end
  else
    @root_url = if (github_packages_url = GitHubPackages.root_url_if_match(var))
      github_packages_url
    else
      var
    end
    @root_url_specs.merge!(specs)
  end
end

#sha256(hash) ⇒ Object

Checksum methods in the DSL’s bottle block take a Hash, which indicates the platform the checksum applies on. Example bottle block syntax: bottle do sha256 cellar: :any_skip_relocation, big_sur: “69489ae397e4645…” sha256 cellar: :any, catalina: “449de5ea35d0e94…” end



545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'software_spec.rb', line 545

def sha256(hash)
  sha256_regex = /^[a-f0-9]{64}$/i

  # find new `sha256 big_sur: "69489ae397e4645..."` format
  tag, digest = hash.find do |key, value|
    key.is_a?(Symbol) && value.is_a?(String) && value.match?(sha256_regex)
  end

  cellar = hash[:cellar] if digest && tag

  tag = Utils::Bottles::Tag.from_symbol(tag)

  cellar ||= tag.default_cellar

  collector.add(tag, checksum: Checksum.new(digest), cellar: cellar)
end

#skip_relocation?(tag: Utils::Bottles.tag) ⇒ Boolean

Does the Bottle this BottleSpecification belongs to need to be relocated?

Parameters:

Returns:

  • (Boolean)


8
9
10
# File 'extend/os/linux/software_spec.rb', line 8

def skip_relocation?(tag: Utils::Bottles.tag)
  false
end

#tag?(tag, no_older_versions: false) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


534
535
536
# File 'software_spec.rb', line 534

def tag?(tag, no_older_versions: false)
  collector.tag?(tag, no_older_versions: no_older_versions)
end

#tag_specification_for(tag, no_older_versions: false) ⇒ Utils::Bottles::TagSpecification?

Parameters:

Returns:



566
567
568
# File 'software_spec.rb', line 566

def tag_specification_for(tag, no_older_versions: false)
  collector.specification_for(tag, no_older_versions: no_older_versions)
end