Class: BottleSpecification
- Defined in:
- extend/os/linux/software_spec.rb,
software_spec.rb
Constant Summary collapse
- RELOCATABLE_CELLARS =
[:any, :any_skip_relocation].freeze
Instance Attribute Summary collapse
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#root_url_specs ⇒ Object
readonly
Returns the value of attribute root_url_specs.
-
#tap ⇒ Object
Returns the value of attribute tap.
Instance Method Summary collapse
-
#checksums ⇒ Object
-
#compatible_locations?(tag: Utils::Bottles.tag) ⇒ Boolean
-
#initialize ⇒ void
constructor
-
#root_url(var = nil, specs = {}) ⇒ Object
-
#sha256(hash) ⇒ Object
Checksum methods in the DSL’s bottle block take a Hash, which indicates the platform the checksum applies on.
-
#skip_relocation?(tag: Utils::Bottles.tag) ⇒ Boolean
Does the Bottle this BottleSpecification belongs to need to be relocated?.
-
#tag?(tag, no_older_versions: false) ⇒ Boolean
-
#tag_specification_for(tag, no_older_versions: false) ⇒ Utils::Bottles::TagSpecification?
-
#tag_to_cellar(tag = Utils::Bottles.tag) ⇒ Symbol, String
Constructor Details
Instance Attribute Details
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
511 512 513 |
# File 'software_spec.rb', line 511 def collector @collector end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
511 512 513 |
# File 'software_spec.rb', line 511 def repository @repository end |
#root_url_specs ⇒ Object (readonly)
Returns the value of attribute root_url_specs.
511 512 513 |
# File 'software_spec.rb', line 511 def root_url_specs @root_url_specs end |
#tap ⇒ Object
Returns the value of attribute tap.
510 511 512 |
# File 'software_spec.rb', line 510 def tap @tap end |
Instance Method Details
#checksums ⇒ Object
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
# File 'software_spec.rb', line 609 def checksums = collector..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 MacOSVersion::Error # Sort non-MacOS tags below MacOS tags. "0.#{tag}" end .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
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'software_spec.rb', line 549 def compatible_locations?(tag: Utils::Bottles.tag) cellar = tag_to_cellar(tag) return true if RELOCATABLE_CELLARS.include?(cellar) prefix = Pathname(cellar).parent.to_s cellar_relocatable = cellar.size >= HOMEBREW_CELLAR.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"].present? prefix_relocatable = prefix.size >= HOMEBREW_PREFIX.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"].present? compatible_cellar = cellar == HOMEBREW_CELLAR.to_s || cellar_relocatable compatible_prefix = prefix == HOMEBREW_PREFIX.to_s || prefix_relocatable compatible_cellar && compatible_prefix end |
#root_url(var = nil, specs = {}) ⇒ Object
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'software_spec.rb', line 521 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
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
# File 'software_spec.rb', line 584 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?
6 7 8 |
# File 'extend/os/linux/software_spec.rb', line 6 def skip_relocation?(tag: Utils::Bottles.tag) false end |
#tag?(tag, no_older_versions: false) ⇒ Boolean
573 574 575 |
# File 'software_spec.rb', line 573 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?
605 606 607 |
# File 'software_spec.rb', line 605 def tag_specification_for(tag, no_older_versions: false) collector.specification_for(tag, no_older_versions: no_older_versions) end |