Support adding root_url specs in bottle output

This commit is contained in:
Chris Wegrzyn 2021-04-27 09:15:53 -04:00
parent 7ba634ccb4
commit 4025dce097
3 changed files with 16 additions and 5 deletions

View File

@ -16,7 +16,9 @@ BOTTLE_ERB = <<-EOS
bottle do bottle do
<% if [HOMEBREW_BOTTLE_DEFAULT_DOMAIN.to_s, <% if [HOMEBREW_BOTTLE_DEFAULT_DOMAIN.to_s,
"#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}/bottles"].exclude?(root_url) %> "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}/bottles"].exclude?(root_url) %>
root_url "<%= root_url %>" root_url "<%= root_url %>"<% unless root_url_specs.blank? %>,
<%= root_url_specs %>
<% end %>
<% end %> <% end %>
<% if rebuild.positive? %> <% if rebuild.positive? %>
rebuild <%= rebuild %> rebuild <%= rebuild %>
@ -75,6 +77,8 @@ module Homebrew
description: "Specify a committer name and email in `git`'s standard author format." description: "Specify a committer name and email in `git`'s standard author format."
flag "--root-url=", flag "--root-url=",
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default." description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
flag "--root-url-specs=",
description: "Append the specified specs to the root_url line in the generated DSL"
conflicts "--no-rebuild", "--keep-old" conflicts "--no-rebuild", "--keep-old"
@ -221,7 +225,7 @@ module Homebrew
%Q(#{line}"#{digest}") %Q(#{line}"#{digest}")
end end
def bottle_output(bottle) def bottle_output(bottle, root_url_specs)
cellars = bottle.checksums.map do |checksum| cellars = bottle.checksums.map do |checksum|
cellar = checksum["cellar"] cellar = checksum["cellar"]
next unless cellar_parameter_needed? cellar next unless cellar_parameter_needed? cellar
@ -244,6 +248,7 @@ module Homebrew
end end
erb_binding = bottle.instance_eval { binding } erb_binding = bottle.instance_eval { binding }
erb_binding.local_variable_set(:sha256_lines, sha256_lines) erb_binding.local_variable_set(:sha256_lines, sha256_lines)
erb_binding.local_variable_set(:root_url_specs, root_url_specs)
erb = ERB.new BOTTLE_ERB erb = ERB.new BOTTLE_ERB
erb.result(erb_binding).gsub(/^\s*$\n/, "") erb.result(erb_binding).gsub(/^\s*$\n/, "")
end end
@ -529,7 +534,7 @@ module Homebrew
end end
end end
output = bottle_output bottle output = bottle_output(bottle, args.root_url_specs)
puts "./#{local_filename}" puts "./#{local_filename}"
puts output puts output
@ -641,7 +646,7 @@ module Homebrew
end end
unless args.write? unless args.write?
puts bottle_output(bottle) puts bottle_output(bottle, args.root_url_specs)
next next
end end
@ -720,7 +725,7 @@ module Homebrew
update_or_add = checksums.nil? ? "add" : "update" update_or_add = checksums.nil? ? "add" : "update"
checksums&.each(&bottle.method(:sha256)) checksums&.each(&bottle.method(:sha256))
output = bottle_output(bottle) output = bottle_output(bottle, args.root_url_specs)
puts output puts output
case update_or_add case update_or_add

View File

@ -61,6 +61,8 @@ module Homebrew
description: "Target tap repository (default: `homebrew/core`)." description: "Target tap repository (default: `homebrew/core`)."
flag "--root-url=", flag "--root-url=",
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default." description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
flag "--root-url-specs=",
description: "Append the specified specs to the root_url line in the generated DSL"
flag "--bintray-mirror=", flag "--bintray-mirror=",
description: "Use the specified Bintray repository to automatically mirror stable URLs "\ description: "Use the specified Bintray repository to automatically mirror stable URLs "\
"defined in the formulae (default: `mirror`)." "defined in the formulae (default: `mirror`)."
@ -443,6 +445,7 @@ module Homebrew
upload_args << "--warn-on-upload-failure" if args.warn_on_upload_failure? upload_args << "--warn-on-upload-failure" if args.warn_on_upload_failure?
upload_args << "--committer=#{args.committer}" if args.committer upload_args << "--committer=#{args.committer}" if args.committer
upload_args << "--root-url=#{args.root_url}" if args.root_url upload_args << "--root-url=#{args.root_url}" if args.root_url
upload_args << "--root-url-specs=#{args.root_url_specs}" if args.root_url_specs
upload_args << if archive_item.present? upload_args << if archive_item.present?
"--archive-item=#{archive_item}" "--archive-item=#{archive_item}"
else else

View File

@ -40,6 +40,8 @@ module Homebrew
description: "Upload to the specified GitHub organisation's GitHub Packages (default: `homebrew`)." description: "Upload to the specified GitHub organisation's GitHub Packages (default: `homebrew`)."
flag "--root-url=", flag "--root-url=",
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default." description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
flag "--root-url-specs=",
description: "Append the specified specs to the root_url line in the generated DSL"
named_args :none named_args :none
end end
@ -114,6 +116,7 @@ module Homebrew
bottle_args << "--root-url=#{args.root_url}" if args.root_url bottle_args << "--root-url=#{args.root_url}" if args.root_url
bottle_args << "--committer=#{args.committer}" if args.committer bottle_args << "--committer=#{args.committer}" if args.committer
bottle_args << "--no-commit" if args.no_commit? bottle_args << "--no-commit" if args.no_commit?
bottle_args << "--root-url-specs=#{args.root_url_specs}" if args.root_url_specs
bottle_args += json_files bottle_args += json_files
if args.dry_run? if args.dry_run?