More Bintray cleanup

Cleanup more files and names related to Bintray to ease their future
deletion (when Bintray is shutdown).
This commit is contained in:
Mike McQuaid 2021-04-12 14:48:58 +01:00
parent ccb05e5e0b
commit 1bdb8c7a33
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
7 changed files with 27 additions and 50 deletions

View File

@ -9,6 +9,8 @@ require "formula_versions"
require "cli/parser" require "cli/parser"
require "utils/inreplace" require "utils/inreplace"
require "erb" require "erb"
require "archive"
require "bintray"
BOTTLE_ERB = <<-EOS BOTTLE_ERB = <<-EOS
bottle do bottle do
@ -510,7 +512,7 @@ module Homebrew
bottle_filename = if bottle.root_url.match?(GitHubPackages::URL_REGEX) bottle_filename = if bottle.root_url.match?(GitHubPackages::URL_REGEX)
filename.github_packages filename.github_packages
else else
filename.bintray filename.url_encode
end end
json = { json = {
@ -546,12 +548,18 @@ module Homebrew
}, },
}, },
}, },
"bintray" => {
"package" => Utils::Bottles::Bintray.package(f.name),
"repository" => Utils::Bottles::Bintray.repository(tap),
},
}, },
} }
if bottle.root_url.match?(::Bintray::URL_REGEX) ||
# TODO: given the naming: ideally the Internet Archive uploader wouldn't use this.
bottle.root_url.start_with?("#{::Archive::URL_PREFIX}/")
json[f.full_name]["bintray"] = {
"package" => Utils::Bottles::Bintray.package(f.name),
"repository" => Utils::Bottles::Bintray.repository(tap),
}
end
File.open(filename.json, "w") do |file| File.open(filename.json, "w") do |file|
file.write JSON.pretty_generate json file.write JSON.pretty_generate json
end end

View File

@ -31,7 +31,7 @@ module Homebrew
def mirror def mirror
args = mirror_args.parse args = mirror_args.parse
odeprecated "brew mirror" odeprecated "brew mirror (Bintray will be shut down on 1st May 2021)"
bintray_org = args.bintray_org || "homebrew" bintray_org = args.bintray_org || "homebrew"
bintray_repo = args.bintray_repo || "mirror" bintray_repo = args.bintray_repo || "mirror"

View File

@ -152,6 +152,8 @@ module Homebrew
archive.upload_bottles(bottles_hash, archive.upload_bottles(bottles_hash,
warn_on_error: args.warn_on_upload_failure?) warn_on_error: args.warn_on_upload_failure?)
elsif bintray?(bottles_hash) elsif bintray?(bottles_hash)
odeprecated "brew pr-upload for Bintray (Bintray will be shut down on 1st May 2021)"
bintray_org = args.bintray_org || "homebrew" bintray_org = args.bintray_org || "homebrew"
bintray = Bintray.new(org: bintray_org) bintray = Bintray.new(org: bintray_org)
bintray.upload_bottles(bottles_hash, bintray.upload_bottles(bottles_hash,

View File

@ -277,7 +277,7 @@ class Bottle
"#{name}--#{version}.#{tag}.bottle.json" "#{name}--#{version}.#{tag}.bottle.json"
end end
def bintray def url_encode
ERB::Util.url_encode("#{name}-#{version}#{extname}") ERB::Util.url_encode("#{name}-#{version}#{extname}")
end end
@ -437,8 +437,10 @@ class BottleSpecification
if var.nil? if var.nil?
@root_url ||= if (github_packages_url = GitHubPackages.root_url_if_match(Homebrew::EnvConfig.bottle_domain)) @root_url ||= if (github_packages_url = GitHubPackages.root_url_if_match(Homebrew::EnvConfig.bottle_domain))
github_packages_url github_packages_url
else elsif Homebrew::EnvConfig.bottle_domain.match?(Bintray::URL_REGEX)
"#{Homebrew::EnvConfig.bottle_domain}/#{Utils::Bottles::Bintray.repository(tap)}" "#{Homebrew::EnvConfig.bottle_domain}/#{Utils::Bottles::Bintray.repository(tap)}"
else
Homebrew::EnvConfig.bottle_domain
end end
else else
@root_url = if (github_packages_url = GitHubPackages.root_url_if_match(var)) @root_url = if (github_packages_url = GitHubPackages.root_url_if_match(var))
@ -455,8 +457,7 @@ class BottleSpecification
image_name = GitHubPackages.image_formula_name(name) image_name = GitHubPackages.image_formula_name(name)
["#{image_name}/blobs/sha256:#{checksum}", filename&.github_packages] ["#{image_name}/blobs/sha256:#{checksum}", filename&.github_packages]
else else
# TODO: this can be removed when we no longer use Bintray filename&.url_encode
filename&.bintray
end end
end end

View File

@ -1,32 +0,0 @@
# typed: false
# frozen_string_literal: true
require "bintray"
describe Bintray, :needs_network do
subject(:bintray) { described_class.new(org: "homebrew") }
before do
ENV["HOMEBREW_BINTRAY_USER"] = "BrewTestBot"
ENV["HOMEBREW_BINTRAY_KEY"] = "deadbeef"
end
describe "::remote_checksum" do
it "detects a published file" do
hash = bintray.remote_checksum(repo: "bottles", remote_file: "hello-2.10.catalina.bottle.tar.gz")
expect(hash).to eq("449de5ea35d0e9431f367f1bb34392e450f6853cdccdc6bd04e6ad6471904ddb")
end
it "fails on a non-existent file" do
hash = bintray.remote_checksum(repo: "bottles", remote_file: "my-fake-bottle-1.0.snow_hyena.tar.gz")
expect(hash).to be nil
end
end
describe "::package_exists?" do
it "detects a package" do
results = bintray.package_exists?(repo: "bottles", package: "hello")
expect(results).to be true
end
end
end

View File

@ -31,8 +31,12 @@ describe Bottle::Filename do
its(:to_str) { is_expected.to eq "foo--1.0.tag.bottle.tar.gz" } its(:to_str) { is_expected.to eq "foo--1.0.tag.bottle.tar.gz" }
end end
describe "#bintray" do describe "#url_encode" do
its(:bintray) { is_expected.to eq "foo-1.0.tag.bottle.tar.gz" } its(:url_encode) { is_expected.to eq "foo-1.0.tag.bottle.tar.gz" }
end
describe "#github_packages" do
its(:github_packages) { is_expected.to eq "foo--1.0.tag.bottle.tar.gz" }
end end
describe "#json" do describe "#json" do

View File

@ -94,9 +94,3 @@ eval $(~/.linuxbrew/bin/brew shellenv)
- [@HomebrewOnLinux on Twitter](https://twitter.com/HomebrewOnLinux) - [@HomebrewOnLinux on Twitter](https://twitter.com/HomebrewOnLinux)
- [Homebrew/linuxbrew-core on GitHub](https://github.com/Homebrew/linuxbrew-core) - [Homebrew/linuxbrew-core on GitHub](https://github.com/Homebrew/linuxbrew-core)
- [Homebrew/discussions (forum)](https://github.com/homebrew/discussions/discussions) - [Homebrew/discussions (forum)](https://github.com/homebrew/discussions/discussions)
## Sponsors
Our binary packages (bottles) are built on [GitHub Actions](https://github.com/features/actions) and hosted by [Bintray](https://bintray.com/linuxbrew).
[![Downloads by Bintray](https://bintray.com/docs/images/downloads_by_bintray_96.png)](https://bintray.com/linuxbrew)