Module: Utils::Bottles Private
- Defined in:
- Library/Homebrew/utils/bottles.rb,
Library/Homebrew/extend/os/mac/utils/bottles.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Helper functions for bottles.
Defined Under Namespace
Modules: Bintray Classes: Collector
Class Method Summary collapse
- .built_as?(f) ⇒ Boolean private
- .file_outdated?(f, file) ⇒ Boolean private
- .formula_contents(bottle_file, name: resolve_formula_names(bottle_file)[0]) ⇒ Object private
- .native_regex ⇒ Object private
- .receipt_path(bottle_file) ⇒ Object private
- .resolve_formula_names(bottle_file) ⇒ Object private
- .resolve_version(bottle_file) ⇒ Object private
- .tag ⇒ Object private
Class Method Details
.built_as?(f) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 21 |
# File 'Library/Homebrew/utils/bottles.rb', line 16 def built_as?(f) return false unless f.latest_version_installed? tab = Tab.for_keg(f.latest_installed_prefix) tab.built_as_bottle end |
.file_outdated?(f, file) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 29 30 31 |
# File 'Library/Homebrew/utils/bottles.rb', line 23 def file_outdated?(f, file) filename = file.basename.to_s return unless f.bottle && filename.match(Pathname::BOTTLE_EXTNAME_RX) bottle_ext = filename[native_regex, 1] bottle_url_ext = f.bottle.url[native_regex, 1] bottle_ext && bottle_url_ext && bottle_ext != bottle_url_ext end |
.formula_contents(bottle_file, name: resolve_formula_names(bottle_file)[0]) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 69 70 71 72 73 |
# File 'Library/Homebrew/utils/bottles.rb', line 65 def formula_contents(bottle_file, name: resolve_formula_names(bottle_file)[0]) bottle_version = resolve_version bottle_file formula_path = "#{name}/#{bottle_version}/.brew/#{name}.rb" contents = Utils.popen_read "tar", "-xOzf", bottle_file, formula_path raise BottleFormulaUnavailableError.new(bottle_file, formula_path) unless $CHILD_STATUS.success? contents end |
.native_regex ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'Library/Homebrew/utils/bottles.rb', line 33 def native_regex /(\.#{Regexp.escape(tag.to_s)}\.bottle\.(\d+\.)?tar\.gz)$/o end |
.receipt_path(bottle_file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 44 |
# File 'Library/Homebrew/utils/bottles.rb', line 37 def receipt_path(bottle_file) path = Utils.popen_read("tar", "-tzf", bottle_file).lines.map(&:chomp).find do |line| line =~ %r{.+/.+/INSTALL_RECEIPT.json} end raise "This bottle does not contain the file INSTALL_RECEIPT.json: #{bottle_file}" unless path path end |
.resolve_formula_names(bottle_file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'Library/Homebrew/utils/bottles.rb', line 46 def resolve_formula_names(bottle_file) receipt_file_path = receipt_path bottle_file receipt_file = Utils.popen_read("tar", "-xOzf", bottle_file, receipt_file_path) name = receipt_file_path.split("/").first tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap full_name = if tap.nil? || tap.core_tap? name else "#{tap}/#{name}" end [name, full_name] end |
.resolve_version(bottle_file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'Library/Homebrew/utils/bottles.rb', line 61 def resolve_version(bottle_file) PkgVersion.parse receipt_path(bottle_file).split("/").second end |
.tag ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'Library/Homebrew/utils/bottles.rb', line 12 def tag @tag ||= "#{ENV["HOMEBREW_PROCESSOR"]}_#{ENV["HOMEBREW_SYSTEM"]}".downcase.to_sym end |