Class: Homebrew::DevCmd::Bottle Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::Bottle
- Includes:
- FileUtils
- Defined in:
- sorbet/rbi/dsl/homebrew/dev_cmd/bottle.rbi,
extend/os/mac/dev-cmd/bottle.rb,
dev-cmd/bottle.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.
DO NOT EDIT MANUALLY
This is an autogenerated file for dynamic methods in Homebrew::DevCmd::Bottle
.
Please instead update this file by running bin/tapioca dsl Homebrew::DevCmd::Bottle
.
Defined Under Namespace
Classes: Args
Constant Summary collapse
- BOTTLE_ERB =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
<<-EOS.freeze bottle do <% if [HOMEBREW_BOTTLE_DEFAULT_DOMAIN.to_s, "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}/bottles"].exclude?(root_url) %> root_url "<%= root_url %>"<% if root_url_using.present? %>, using: <%= root_url_using %> <% end %> <% end %> <% if rebuild.positive? %> rebuild <%= rebuild %> <% end %> <% sha256_lines.each do |line| %> <%= line %> <% end %> end EOS
- MAXIMUM_STRING_MATCHES =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
100
- ALLOWABLE_HOMEBREW_REPOSITORY_LINKS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
[ %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Homebrew/os/(mac|linux)/pkgconfig}, ].freeze
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::Bottle::Args private
- #bottle_output(bottle, root_url_using) ⇒ Object private
- #generate_sha256_line(tag, digest, cellar, tag_column, digest_column) ⇒ Object private
- #gnu_tar(gnu_tar_formula) ⇒ String private
- #merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash) ⇒ Object private
- #merge_json_files(json_files) ⇒ Object private
- #parse_json_files(filenames) ⇒ Object private
- #run ⇒ void private
- #tar_args ⇒ Array<String> private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::Bottle::Args
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.
9 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/bottle.rbi', line 9 def args; end |
#bottle_output(bottle, root_url_using) ⇒ 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.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'dev-cmd/bottle.rb', line 125 def bottle_output(bottle, root_url_using) cellars = bottle.checksums.filter_map do |checksum| cellar = checksum["cellar"] next unless cellar_parameter_needed? cellar case cellar when String %Q("#{cellar}") when Symbol ":#{cellar}" end end tag_column = cellars.empty? ? 0 : "cellar: #{cellars.max_by(&:length)}, ".length = bottle.checksums.map { |checksum| checksum["tag"] } # Start where the tag ends, add the max length of the tag, add two for the `: ` digest_column = tag_column + .max_by(&:length).length + 2 sha256_lines = bottle.checksums.map do |checksum| generate_sha256_line(checksum["tag"], checksum["digest"], checksum["cellar"], tag_column, digest_column) end erb_binding = bottle.instance_eval { binding } erb_binding.local_variable_set(:sha256_lines, sha256_lines) erb_binding.local_variable_set(:root_url_using, root_url_using) erb = ERB.new BOTTLE_ERB erb.result(erb_binding).gsub(/^\s*$\n/, "") end |
#generate_sha256_line(tag, digest, cellar, tag_column, digest_column) ⇒ 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.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'dev-cmd/bottle.rb', line 110 def generate_sha256_line(tag, digest, cellar, tag_column, digest_column) line = "sha256 " tag_column += line.length digest_column += line.length if cellar.is_a?(Symbol) line += "cellar: :#{cellar}," elsif cellar_parameter_needed?(cellar) line += %Q(cellar: "#{cellar}",) end line += " " * (tag_column - line.length) line += "#{tag}:" line += " " * (digest_column - line.length) %Q(#{line}"#{digest}") end |
#gnu_tar(gnu_tar_formula) ⇒ 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.
21 22 23 |
# File 'extend/os/mac/dev-cmd/bottle.rb', line 21 def gnu_tar(gnu_tar_formula) "#{gnu_tar_formula.opt_bin}/gtar" end |
#merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash) ⇒ 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.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'dev-cmd/bottle.rb', line 172 def merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash) mismatches = [] checksums = [] new_values = { root_url: new_bottle_hash["root_url"], rebuild: new_bottle_hash["rebuild"], } skip_keys = [:sha256, :cellar] old_keys.each do |key| next if skip_keys.include?(key) old_value = old_bottle_spec.send(key).to_s new_value = new_values[key].to_s next if old_value.present? && new_value == old_value mismatches << "#{key}: old: #{old_value.inspect}, new: #{new_value.inspect}" end return [mismatches, checksums] if old_keys.exclude? :sha256 old_bottle_spec.collector.each_tag do |tag| old_tag_spec = old_bottle_spec.collector.specification_for(tag) old_hexdigest = old_tag_spec.checksum.hexdigest old_cellar = old_tag_spec.cellar new_value = new_bottle_hash.dig("tags", tag.to_s) if new_value.present? && new_value["sha256"] != old_hexdigest mismatches << "sha256 #{tag}: old: #{old_hexdigest.inspect}, new: #{new_value["sha256"].inspect}" elsif new_value.present? && new_value["cellar"] != old_cellar.to_s mismatches << "cellar #{tag}: old: #{old_cellar.to_s.inspect}, new: #{new_value["cellar"].inspect}" else checksums << { cellar: old_cellar, tag.to_sym => old_hexdigest } end end [mismatches, checksums] end |
#merge_json_files(json_files) ⇒ 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.
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'dev-cmd/bottle.rb', line 159 def merge_json_files(json_files) json_files.reduce({}) do |hash, json_file| json_file.each_value do |json_hash| json_bottle = json_hash["bottle"] cellar = json_bottle.delete("cellar") json_bottle["tags"].each_value do |json_platform| json_platform["cellar"] ||= cellar end end hash.deep_merge(json_file) end end |
#parse_json_files(filenames) ⇒ 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.
153 154 155 156 157 |
# File 'dev-cmd/bottle.rb', line 153 def parse_json_files(filenames) filenames.map do |filename| JSON.parse(File.read(filename)) end end |
#run ⇒ 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.
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'dev-cmd/bottle.rb', line 97 def run if args.merge? Homebrew.install_bundler_gems!(groups: ["ast"]) return merge end gnu_tar_formula_ensure_installed_if_needed! args.named.to_resolved_formulae(uniq: false).each do |formula| bottle_formula formula end end |
#tar_args ⇒ Array<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.
10 11 12 13 14 15 16 |
# File 'extend/os/mac/dev-cmd/bottle.rb', line 10 def tar_args if MacOS.version >= :catalina ["--no-mac-metadata", "--no-acls", "--no-xattrs"].freeze else [].freeze end end |