Class: Homebrew::DevCmd::Bottle Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::Bottle
- Includes:
- FileUtils, OS::Linux::DevCmd::Bottle, OS::Mac::DevCmd::Bottle
- Defined in:
- dev-cmd/bottle.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/bottle.rbi
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.
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.
T.let(<<-EOS.freeze, String) 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.
T.let([ %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Homebrew/os/(?:mac|linux)/pkgconfig}, ].freeze, T::Array[Regexp])
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::Bottle::Args private
-
#binary_relocation_diagnostic_string(match, relative_path, offset) ⇒ String
private
strings -uses locale-dependentisprint(), so a match can contain invalid UTF-8. - #bottle_output(bottle, root_url_using) ⇒ String private
- #generate_sha256_line(tag, digest, cellar, tag_column, digest_column) ⇒ String private
- #merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash) ⇒ Array<(Array<String>, Array<Hash{Symbol => String, Symbol}>)> private
- #merge_json_files(json_files) ⇒ Hash{String => T.untyped} private
- #parse_json_files(filenames) ⇒ Array<Hash{String => T.untyped}> private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
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.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/bottle.rbi', line 10 def args; end |
#binary_relocation_diagnostic_string(match, relative_path, offset) ⇒ 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.
strings - uses locale-dependent isprint(), so a match can contain invalid
UTF-8. Scrub it instead of dropping it, or a build prefix could go undetected.
237 238 239 240 241 242 243 |
# File 'dev-cmd/bottle.rb', line 237 def binary_relocation_diagnostic_string(match, relative_path, offset) utf8_match = match.dup.force_encoding(Encoding::UTF_8) return utf8_match if utf8_match.valid_encoding? opoo "Scrubbing string with invalid encoding in #{relative_path} at offset 0x#{offset}" utf8_match.scrub end |
#bottle_output(bottle, root_url_using) ⇒ 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.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'dev-cmd/bottle.rb', line 138 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) ⇒ 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.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'dev-cmd/bottle.rb', line 122 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 |
#merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash) ⇒ Array<(Array<String>, Array<Hash{Symbol => String, Symbol}>)>
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.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'dev-cmd/bottle.rb', line 192 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.public_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) odie "Specification for tag #{tag} is nil" if old_tag_spec.nil? 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) ⇒ Hash{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.
174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'dev-cmd/bottle.rb', line 174 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) ⇒ Array<Hash{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.
167 168 169 170 171 |
# File 'dev-cmd/bottle.rb', line 167 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.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'dev-cmd/bottle.rb', line 103 def run if args.merge? Utils::GemSetup.install_bundler_gems!(groups: ["ast"]) return merge end Utils::GemSetup.install_bundler_gems!(groups: ["bottle"]) gnu_tar_formula_ensure_installed_if_needed! if args.only_json_tab? args.named.to_resolved_formulae(uniq: false).each do |formula| bottle_formula formula end end |