From 1bdb8c7a336ed38bb1ddf6f5fd5ee8c5598b0b5c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 12 Apr 2021 14:48:58 +0100 Subject: [PATCH] More Bintray cleanup Cleanup more files and names related to Bintray to ease their future deletion (when Bintray is shutdown). --- Library/Homebrew/dev-cmd/bottle.rb | 18 ++++++++--- Library/Homebrew/dev-cmd/mirror.rb | 2 +- Library/Homebrew/dev-cmd/pr-upload.rb | 2 ++ Library/Homebrew/software_spec.rb | 9 +++--- Library/Homebrew/test/bintray_spec.rb | 32 ------------------- Library/Homebrew/test/bottle_filename_spec.rb | 8 +++-- docs/Homebrew-on-Linux.md | 6 ---- 7 files changed, 27 insertions(+), 50 deletions(-) delete mode 100644 Library/Homebrew/test/bintray_spec.rb diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index a692cada40..fdf9405709 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -9,6 +9,8 @@ require "formula_versions" require "cli/parser" require "utils/inreplace" require "erb" +require "archive" +require "bintray" BOTTLE_ERB = <<-EOS bottle do @@ -510,7 +512,7 @@ module Homebrew bottle_filename = if bottle.root_url.match?(GitHubPackages::URL_REGEX) filename.github_packages else - filename.bintray + filename.url_encode end 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.write JSON.pretty_generate json end diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index 4e72d82caa..5518ac87cc 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -31,7 +31,7 @@ module Homebrew def mirror 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_repo = args.bintray_repo || "mirror" diff --git a/Library/Homebrew/dev-cmd/pr-upload.rb b/Library/Homebrew/dev-cmd/pr-upload.rb index aee0f0f49a..db330183af 100644 --- a/Library/Homebrew/dev-cmd/pr-upload.rb +++ b/Library/Homebrew/dev-cmd/pr-upload.rb @@ -152,6 +152,8 @@ module Homebrew archive.upload_bottles(bottles_hash, warn_on_error: args.warn_on_upload_failure?) 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 = Bintray.new(org: bintray_org) bintray.upload_bottles(bottles_hash, diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index ad47e310af..89a33703a5 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -277,7 +277,7 @@ class Bottle "#{name}--#{version}.#{tag}.bottle.json" end - def bintray + def url_encode ERB::Util.url_encode("#{name}-#{version}#{extname}") end @@ -437,8 +437,10 @@ class BottleSpecification if var.nil? @root_url ||= if (github_packages_url = GitHubPackages.root_url_if_match(Homebrew::EnvConfig.bottle_domain)) github_packages_url - else + elsif Homebrew::EnvConfig.bottle_domain.match?(Bintray::URL_REGEX) "#{Homebrew::EnvConfig.bottle_domain}/#{Utils::Bottles::Bintray.repository(tap)}" + else + Homebrew::EnvConfig.bottle_domain end else @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}/blobs/sha256:#{checksum}", filename&.github_packages] else - # TODO: this can be removed when we no longer use Bintray - filename&.bintray + filename&.url_encode end end diff --git a/Library/Homebrew/test/bintray_spec.rb b/Library/Homebrew/test/bintray_spec.rb deleted file mode 100644 index be7f3f47ba..0000000000 --- a/Library/Homebrew/test/bintray_spec.rb +++ /dev/null @@ -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 diff --git a/Library/Homebrew/test/bottle_filename_spec.rb b/Library/Homebrew/test/bottle_filename_spec.rb index 7d95739ea9..effebff4b4 100644 --- a/Library/Homebrew/test/bottle_filename_spec.rb +++ b/Library/Homebrew/test/bottle_filename_spec.rb @@ -31,8 +31,12 @@ describe Bottle::Filename do its(:to_str) { is_expected.to eq "foo--1.0.tag.bottle.tar.gz" } end - describe "#bintray" do - its(:bintray) { is_expected.to eq "foo-1.0.tag.bottle.tar.gz" } + describe "#url_encode" do + 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 describe "#json" do diff --git a/docs/Homebrew-on-Linux.md b/docs/Homebrew-on-Linux.md index 68c4459a6d..fd22b35b39 100644 --- a/docs/Homebrew-on-Linux.md +++ b/docs/Homebrew-on-Linux.md @@ -94,9 +94,3 @@ eval $(~/.linuxbrew/bin/brew shellenv) - [@HomebrewOnLinux on Twitter](https://twitter.com/HomebrewOnLinux) - [Homebrew/linuxbrew-core on GitHub](https://github.com/Homebrew/linuxbrew-core) - [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)