--download-strategy instead of --root-url-spec
This commit is contained in:
parent
02987c2649
commit
3f60c95425
@ -16,8 +16,8 @@ BOTTLE_ERB = <<-EOS
|
||||
bottle do
|
||||
<% if [HOMEBREW_BOTTLE_DEFAULT_DOMAIN.to_s,
|
||||
"#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}/bottles"].exclude?(root_url) %>
|
||||
root_url "<%= root_url %>"<% unless root_url_specs.blank? %>,
|
||||
<%= root_url_specs %>
|
||||
root_url "<%= root_url %>"<% unless download_strategy.blank? %>,
|
||||
using: <%= download_strategy %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if rebuild.positive? %>
|
||||
@ -77,8 +77,8 @@ module Homebrew
|
||||
description: "Specify a committer name and email in `git`'s standard author format."
|
||||
flag "--root-url=",
|
||||
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 "--download-strategy=",
|
||||
description: "Use the specified download strategy for the root_url in the generated DSL"
|
||||
|
||||
conflicts "--no-rebuild", "--keep-old"
|
||||
|
||||
@ -225,7 +225,7 @@ module Homebrew
|
||||
%Q(#{line}"#{digest}")
|
||||
end
|
||||
|
||||
def bottle_output(bottle, root_url_specs)
|
||||
def bottle_output(bottle, download_strategy)
|
||||
cellars = bottle.checksums.map do |checksum|
|
||||
cellar = checksum["cellar"]
|
||||
next unless cellar_parameter_needed? cellar
|
||||
@ -248,7 +248,7 @@ module Homebrew
|
||||
end
|
||||
erb_binding = bottle.instance_eval { binding }
|
||||
erb_binding.local_variable_set(:sha256_lines, sha256_lines)
|
||||
erb_binding.local_variable_set(:root_url_specs, root_url_specs)
|
||||
erb_binding.local_variable_set(:download_strategy, download_strategy)
|
||||
erb = ERB.new BOTTLE_ERB
|
||||
erb.result(erb_binding).gsub(/^\s*$\n/, "")
|
||||
end
|
||||
@ -534,7 +534,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
output = bottle_output(bottle, args.root_url_specs)
|
||||
output = bottle_output(bottle, args.download_strategy)
|
||||
|
||||
puts "./#{local_filename}"
|
||||
puts output
|
||||
@ -646,7 +646,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
unless args.write?
|
||||
puts bottle_output(bottle, args.root_url_specs)
|
||||
puts bottle_output(bottle, args.download_strategy)
|
||||
next
|
||||
end
|
||||
|
||||
@ -725,7 +725,7 @@ module Homebrew
|
||||
update_or_add = checksums.nil? ? "add" : "update"
|
||||
|
||||
checksums&.each(&bottle.method(:sha256))
|
||||
output = bottle_output(bottle, args.root_url_specs)
|
||||
output = bottle_output(bottle, args.download_strategy)
|
||||
puts output
|
||||
|
||||
case update_or_add
|
||||
|
@ -61,8 +61,8 @@ module Homebrew
|
||||
description: "Target tap repository (default: `homebrew/core`)."
|
||||
flag "--root-url=",
|
||||
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 "--download-strategy=",
|
||||
description: "Use the specified download strategy for the root_url in the generated DSL"
|
||||
flag "--bintray-mirror=",
|
||||
description: "Use the specified Bintray repository to automatically mirror stable URLs "\
|
||||
"defined in the formulae (default: `mirror`)."
|
||||
@ -445,7 +445,7 @@ module Homebrew
|
||||
upload_args << "--warn-on-upload-failure" if args.warn_on_upload_failure?
|
||||
upload_args << "--committer=#{args.committer}" if args.committer
|
||||
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 << "--download-strategy=#{args.download_strategy}" if args.download_strategy
|
||||
upload_args << if archive_item.present?
|
||||
"--archive-item=#{archive_item}"
|
||||
else
|
||||
|
@ -40,8 +40,8 @@ module Homebrew
|
||||
description: "Upload to the specified GitHub organisation's GitHub Packages (default: `homebrew`)."
|
||||
flag "--root-url=",
|
||||
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 "--download-strategy=",
|
||||
description: "Use the specified download strategy for the root_url in the generated DSL"
|
||||
|
||||
named_args :none
|
||||
end
|
||||
@ -116,7 +116,7 @@ module Homebrew
|
||||
bottle_args << "--root-url=#{args.root_url}" if args.root_url
|
||||
bottle_args << "--committer=#{args.committer}" if args.committer
|
||||
bottle_args << "--no-commit" if args.no_commit?
|
||||
bottle_args << "--root-url-specs=#{args.root_url_specs}" if args.root_url_specs
|
||||
bottle_args << "--download-strategy=#{args.download_strategy}" if args.download_strategy
|
||||
bottle_args += json_files
|
||||
|
||||
if args.dry_run?
|
||||
|
@ -396,90 +396,6 @@ describe "brew bottle" do
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
describe "--merge with --root-url-specs", :integration_test do
|
||||
let(:core_tap) { CoreTap.new }
|
||||
let(:tarball) do
|
||||
if OS.linux?
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz"
|
||||
else
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz"
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
Pathname("#{TEST_TMPDIR}/testball-1.0.arm64_big_sur.bottle.json").write stub_hash(
|
||||
name: "testball",
|
||||
version: "1.0",
|
||||
path: "#{core_tap.path}/Formula/testball.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "arm64_big_sur",
|
||||
filename: "testball-1.0.arm64_big_sur.bottle.tar.gz",
|
||||
local_filename: "testball--1.0.arm64_big_sur.bottle.tar.gz",
|
||||
root_url: "https://example.com/",
|
||||
sha256: "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149",
|
||||
)
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.rm_f "#{TEST_TMPDIR}/testball-1.0.arm64_big_sur.bottle.json"
|
||||
end
|
||||
|
||||
it "adds a formula block with a custom root_url spec" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"--root-url-specs=using: MyCustomStrategy",
|
||||
"#{TEST_TMPDIR}/testball-1.0.arm64_big_sur.bottle.json"
|
||||
}.to output(<<~EOS).to_stdout
|
||||
==> testball
|
||||
bottle do
|
||||
root_url "https://example.com/",
|
||||
using: MyCustomStrategy
|
||||
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
|
||||
end
|
||||
EOS
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||
class Testball < Formula
|
||||
desc "Some test"
|
||||
homepage "https://brew.sh/testball"
|
||||
url "file://#{tarball}"
|
||||
sha256 "#{tarball.sha256}"
|
||||
|
||||
bottle do
|
||||
root_url "https://example.com/",
|
||||
using: MyCustomStrategy
|
||||
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
|
||||
end
|
||||
|
||||
option "with-foo", "Build with foo"
|
||||
|
||||
def install
|
||||
(prefix/"foo"/"test").write("test") if build.with? "foo"
|
||||
prefix.install Dir["*"]
|
||||
(buildpath/"test.c").write \
|
||||
"#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}"
|
||||
bin.mkpath
|
||||
system ENV.cc, "test.c", "-o", bin/"test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
@ -708,6 +624,39 @@ describe "brew bottle" do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "::bottle_output" do
|
||||
it "includes a custom root_url" do
|
||||
bottle = BottleSpecification.new
|
||||
bottle.root_url("https://example.com")
|
||||
bottle.sha256(catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e")
|
||||
|
||||
expect(homebrew.bottle_output(bottle, nil)).to eq(
|
||||
<<~RUBY.indent(2),
|
||||
bottle do
|
||||
root_url "https://example.com"
|
||||
sha256 catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e"
|
||||
end
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
|
||||
it "includes download strategy for custom root_url" do
|
||||
bottle = BottleSpecification.new
|
||||
bottle.root_url("https://example.com")
|
||||
bottle.sha256(catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e")
|
||||
|
||||
expect(homebrew.bottle_output(bottle, "ExampleStrategy")).to eq(
|
||||
<<~RUBY.indent(2),
|
||||
bottle do
|
||||
root_url "https://example.com",
|
||||
using: ExampleStrategy
|
||||
sha256 catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e"
|
||||
end
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user