Deprecate, disable, delete code for Homebrew 3.2.0

Do the usual deprecation, disable, delete dance for Homebrew 3.2.0.
This commit is contained in:
Mike McQuaid 2021-06-17 11:34:31 +01:00
parent 7eb3c08d20
commit 30a65342e8
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
26 changed files with 28 additions and 424 deletions

View File

@ -12,7 +12,6 @@ Style/Documentation:
- "global.rb"
- "keg_relocate.rb"
- "os/linux/global.rb"
- "os/mac/architecture_list.rb"
- "os/mac/global.rb"
- "os/mac/keg.rb"
- "reinstall.rb"

View File

@ -100,10 +100,11 @@ module Homebrew
resolve_formula(name)
when :latest_kegs
resolve_latest_keg(name)
when :keg, :default_kegs
# TODO: (3.2) Uncomment the following
# odeprecated "`load_formula_or_cask` with `method: :keg`",
# "`load_formula_or_cask` with `method: :default_kegs`"
when :default_kegs
resolve_default_keg(name)
when :keg
odeprecated "`load_formula_or_cask` with `method: :keg`",
"`load_formula_or_cask` with `method: :default_kegs`"
resolve_default_keg(name)
when :kegs
_, kegs = resolve_kegs(name)

View File

@ -406,18 +406,6 @@ module Homebrew
end
end
def max_named(_count)
odisabled "`max_named`", "`named_args max:`"
end
def min_named(_count_or_type)
odisabled "`min_named`", "`named_args min:`"
end
def named(_count_or_type)
odisabled "`named`", "`named_args`"
end
sig { void }
def hide_from_man_page!
@hide_from_man_page = true

View File

@ -60,8 +60,7 @@ module Homebrew
conflicts "--open", "--closed"
conflicts(*package_manager_switches)
# TODO: (3.2) Add `min: 1` the `named_args` once `brew search --cask` is removed
named_args :text_or_regex
named_args :text_or_regex, min: 1
end
end
@ -74,12 +73,6 @@ module Homebrew
return
end
if args.no_named?
odisabled "`brew search --cask` with no arguments to output casks", "`brew casks`" if args.cask?
raise UsageError, "This command requires at least 1 text or regex argument."
end
query = args.named.join(" ")
string_or_regex = query_regexp(query)

View File

@ -56,17 +56,9 @@ module Homebrew
elsif args.no_named?
puts Tap.names
else
if args.full?
opoo "`brew tap --full` is now a no-op!"
# TODO: (3.2) Uncomment the following line and remove the `opoo` above
# odeprecated "`brew tap --full`"
end
odeprecated "`brew tap --full`" if args.full?
if args.shallow?
opoo "`brew tap --shallow` is now a no-op!"
# TODO: (3.2) Uncomment the following line and remove the `opoo` above
# odeprecated "`brew tap --shallow`"
end
odeprecated "`brew tap --shallow`" if args.shallow?
tap = Tap.fetch(args.named.first)
begin

View File

@ -1,4 +1,2 @@
# typed: strict
# frozen_string_literal: true
require_relative "early/download_strategy"

View File

@ -1,46 +0,0 @@
# typed: false
# frozen_string_literal: true
class AbstractDownloadStrategy
module CompatFetch
def fetch(timeout: nil)
super()
end
end
module Compat_Fetch # rubocop:disable Naming/ClassAndModuleCamelCase
def _fetch(*args, **options)
options[:timeout] = nil unless options.key?(:timeout)
begin
super
rescue ArgumentError => e
raise unless e.message.include?("timeout")
odeprecated "`def _fetch` in a subclass of `CurlDownloadStrategy`"
options.delete(:timeout)
super(*args, **options)
end
end
end
class << self
def method_added(method)
if method == :fetch && instance_method(method).arity.zero?
odisabled "`def fetch` in a subclass of `#{self}`",
"`def fetch(timeout: nil, **options)` and output a warning " \
"when `options` contains new unhandled options"
class_eval do
prepend CompatFetch
end
elsif method == :_fetch
class_eval do
prepend Compat_Fetch
end
end
super
end
end
end

View File

@ -24,13 +24,6 @@ module Homebrew
end
def man
odeprecated "`brew man`", "`brew generate-man-completions`"
args = man_args.parse
cmd = ["generate-man-completions"]
cmd << "--fail-if-not-changed" if args.fail_if_not_changed?
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
system ENV["HOMEBREW_RUBY_PATH"], brew_rb, *cmd
odisabled "`brew man`", "`brew generate-man-completions`"
end
end

View File

@ -1,24 +0,0 @@
# typed: true
# frozen_string_literal: true
require "cli/parser"
module Homebrew
extend T::Sig
module_function
sig { returns(CLI::Parser) }
def mirror_args
Homebrew::CLI::Parser.new do
description <<~EOS
Reupload the stable URL of a formula for use as a mirror.
EOS
hide_from_man_page!
end
end
def mirror
odisabled "`brew mirror` (Bintray was shut down on 1st May 2021)"
end
end

View File

@ -1,37 +0,0 @@
# typed: true
# frozen_string_literal: true
require "cli/parser"
require "release_notes"
module Homebrew
extend T::Sig
module_function
sig { returns(CLI::Parser) }
def release_notes_args
Homebrew::CLI::Parser.new do
usage_banner "`release-notes` [<options>] [<previous_tag>] [<end_ref>]"
description <<~EOS
Print the merged pull requests on Homebrew/brew between two Git refs.
If no <previous_tag> is provided it defaults to the latest tag.
If no <end_ref> is provided it defaults to `origin/master`.
If `--markdown` and a <previous_tag> are passed, an extra line containing
a link to the Homebrew blog will be adding to the output. Additionally,
a warning will be shown if the latest minor release was less than one month ago.
EOS
switch "--markdown",
description: "Print as a Markdown list."
named_args max: 2
hide_from_man_page!
end
end
def release_notes
odisabled "`brew release-notes`", "`brew release`"
end
end

View File

@ -238,19 +238,6 @@ module SharedEnvExtension
end
end
# Snow Leopard defines an NCURSES value the opposite of most distros.
# @see https://bugs.python.org/issue6848
sig { void }
def ncurses_define
odisabled "ENV.ncurses_define"
end
# @private
sig { void }
def userpaths!
odisabled "ENV.userpaths!"
end
sig { void }
def fortran
# Ignore repeated calls to this function as it will misleadingly warn about
@ -328,11 +315,6 @@ module SharedEnvExtension
sig { void }
def permit_arch_flags; end
sig { void }
def permit_weak_imports
odisabled "ENV.permit_weak_imports"
end
# @private
sig { params(cc: T.any(Symbol, String)).returns(T::Boolean) }
def compiler_any_clang?(cc = compiler)

View File

@ -6,7 +6,7 @@ require "macho"
module Hardware
class CPU
class << self
undef type, family, universal_archs, features, sse4?
undef type, family, features, sse4?
# These methods use info spewed out by sysctl.
# Look in <mach/machine.h> for decoding info.
@ -31,16 +31,6 @@ module Hardware
end
end
# Returns an array that's been extended with {ArchitectureListExtension},
# which provides helpers like `#as_arch_flags`.
def universal_archs
# Amazingly, this order (64, then 32) matters. It shouldn't, but it
# does. GCC (some versions? some systems?) can blow up if the other
# order is used.
# https://superuser.com/questions/740563/gcc-4-8-on-macos-fails-depending-on-arch-order
[arch_64_bit, arch_32_bit].extend ArchitectureListExtension
end
# True when running under an Intel-based shell via Rosetta 2 on an
# Apple Silicon Mac. This can be detected via seeing if there's a
# conflict between what `uname` reports and the underlying `sysctl` flags,

View File

@ -2973,22 +2973,18 @@ class Formula
@pour_bottle_check.instance_eval(&block)
end
# Deprecates a {Formula} (on a given date, if provided) so a warning is
# Deprecates a {Formula} (on the given date) so a warning is
# shown on each installation. If the date has not yet passed the formula
# will not be deprecated.
# <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre>
# <pre>deprecate! date: "2020-08-27", because: "has been replaced by foo"</pre>
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
# @see DeprecateDisable::DEPRECATE_DISABLE_REASONS
def deprecate!(date: nil, because: nil)
odisabled "`deprecate!` without a reason", "`deprecate! because: \"reason\"`" if because.blank?
odisabled "`deprecate!` without a date", "`deprecate! date: \"#{Date.today}\"`" if date.blank?
def deprecate!(date:, because:)
@deprecation_date = Date.parse(date)
return if @deprecation_date > Date.today
@deprecation_date = Date.parse(date) if date.present?
return if date.present? && Date.parse(date) > Date.today
@deprecation_reason = because if because.present?
@deprecation_reason = because
@deprecated = true
end
@ -3012,26 +3008,23 @@ class Formula
# @see .deprecate!
attr_reader :deprecation_reason
# Disables a {Formula} (on a given date, if provided) so it cannot be
# Disables a {Formula} (on the given date) so it cannot be
# installed. If the date has not yet passed the formula
# will be deprecated instead of disabled.
# <pre>disable! date: "2020-08-27", because: :does_not_build</pre>
# <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre>
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
# @see DeprecateDisable::DEPRECATE_DISABLE_REASONS
def disable!(date: nil, because: nil)
odisabled "`disable!` without a reason", "`disable! because: \"reason\"`" if because.blank?
odisabled "`disable!` without a date", "`disable! date: \"#{Date.today}\"`" if date.blank?
def disable!(date:, because:)
@disable_date = Date.parse(date)
@disable_date = Date.parse(date) if date.present?
if @disable_date && @disable_date > Date.today
@deprecation_reason = because if because.present?
if @disable_date > Date.today
@deprecation_reason = because
@deprecated = true
return
end
@disable_reason = because if because.present?
@disable_reason = because
@disabled = true
end

View File

@ -42,18 +42,18 @@ module Homebrew
assert_not_same: :refute_same,
}.each do |old_method, new_method|
define_method(old_method) do |*args|
odeprecated old_method, new_method
odisabled old_method, new_method
send(new_method, *args)
end
end
def assert_true(act, msg = nil)
odeprecated "assert_true", "assert(...) or assert_equal(true, ...)"
odisabled "assert_true", "assert(...) or assert_equal(true, ...)"
assert_equal(true, act, msg)
end
def assert_false(act, msg = nil)
odeprecated "assert_false", "assert(!...) or assert_equal(false, ...)"
odisabled "assert_false", "assert(!...) or assert_equal(false, ...)"
assert_equal(false, act, msg)
end

View File

@ -81,10 +81,6 @@ module Hardware
end
end
def universal_archs
odisabled "Hardware::CPU.universal_archs"
end
sig { returns(Symbol) }
def type
case RUBY_PLATFORM

View File

@ -533,7 +533,7 @@ module Homebrew
rescue ArgumentError => e
raise unless e.message.include?("unknown keyword: cask")
odeprecated "`def self.find_versions` in `#{strategy}` without a `cask` parameter"
odisabled "`def self.find_versions` in `#{strategy}` without a `cask` parameter"
end
match_version_map = strategy_data[:matches]
regex = strategy_data[:regex]

View File

@ -1,25 +0,0 @@
# typed: false
# frozen_string_literal: true
# TODO: (3.2) remove this module when the linked deprecated functions are removed.
require "hardware"
module ArchitectureListExtension
# @private
def universal?
intersects_all?(Hardware::CPU::INTEL_32BIT_ARCHS, Hardware::CPU::INTEL_64BIT_ARCHS)
end
def as_arch_flags
map { |a| "-arch #{a}" }.join(" ")
end
protected
def intersects_all?(*set)
set.all? do |archset|
archset.any? { |a| include? a }
end
end
end

View File

@ -2,7 +2,6 @@
# frozen_string_literal: true
require "macho"
require "os/mac/architecture_list"
# {Pathname} extension for dealing with Mach-O files.
#
@ -65,8 +64,7 @@ module MachOShim
end
def archs
# TODO: (3.2) remove ArchitectureListExtension
mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension)
mach_data.map { |m| m.fetch :arch }
end
def arch

View File

@ -491,7 +491,7 @@ class BottleSpecification
def cellar(val = nil)
if val.present?
odeprecated(
odisabled(
"`cellar` in a bottle block",
"`brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument",
)
@ -552,7 +552,7 @@ class BottleSpecification
end
if digest && tag
odeprecated(
odisabled(
'`sha256 "digest" => :tag` in a bottle block',
'`brew style --fix` on the formula to update the style or use `sha256 tag: "digest"`',
)

View File

@ -140,70 +140,6 @@ describe "brew bottle" do
# something here
end
EOS
end
it "replaces the bottle block in a formula that already has a bottle block in the old format" do
core_tap.path.cd do
system "git", "init"
setup_test_formula "testball", bottle_block: <<~EOS
bottle do
cellar :any_skip_relocation
sha256 "6b276491297d4052538bd2fd22d5129389f27d90a98f831987236a5b90511b98" => :big_sur
sha256 "c3c650d75f5188f5d6edd351dd3215e141b73b8ec1cf9144f30e39cbc45de72e" => :arm64_big_sur
sha256 "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72" => :catalina
end
EOS
system "git", "add", "--all"
system "git", "commit", "-m", "testball 0.1"
end
expect {
brew "bottle",
"--merge",
"--write",
"#{TEST_TMPDIR}/testball-1.0.arm64_big_sur.bottle.json",
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
}.to output(<<~EOS).to_stdout
==> testball
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
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}"
option "with-foo", "Build with foo"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
end
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
@ -267,71 +203,6 @@ describe "brew bottle" do
# something here
end
EOS
end
it "updates the bottle block in a formula that already has a bottle block (old format) when using --keep-old" do
core_tap.path.cd do
system "git", "init"
setup_test_formula "testball", bottle_block: <<~EOS
bottle do
cellar :any
sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra
end
EOS
system "git", "add", "--all"
system "git", "commit", "-m", "testball 0.1"
end
expect {
brew "bottle",
"--merge",
"--write",
"--keep-old",
"#{TEST_TMPDIR}/testball-1.0.arm64_big_sur.bottle.json",
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
}.to output(<<~EOS).to_stdout
==> testball
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
sha256 cellar: :any, high_sierra: "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059"
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}"
option "with-foo", "Build with foo"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
sha256 cellar: :any, high_sierra: "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059"
end
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

View File

@ -1,8 +0,0 @@
# typed: false
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "brew man" do
it_behaves_like "parseable arguments"
end

View File

@ -1,8 +0,0 @@
# typed: false
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "brew mirror" do
it_behaves_like "parseable arguments"
end

View File

@ -1,8 +0,0 @@
# typed: false
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "brew release-notes" do
it_behaves_like "parseable arguments"
end

View File

@ -109,26 +109,6 @@ describe "Mach-O" do
end
end
describe ArchitectureListExtension do
let(:archs) { [:i386, :x86_64, :ppc7400, :ppc64].extend(described_class) }
specify "universal checks" do
expect(archs).to be_universal
non_universal = [:i386].extend(described_class)
expect(non_universal).not_to be_universal
intel_only = [:i386, :x86_64].extend(described_class)
expect(intel_only).to be_universal
end
specify "architecture flags" do
pn = dylib_path("fat")
expect(pn.archs).to be_universal
expect(pn.archs.as_arch_flags).to eq("-arch x86_64 -arch i386")
end
end
describe "text executables" do
let(:pn) { HOMEBREW_PREFIX/"an_executable" }

View File

@ -402,14 +402,6 @@ module Kernel
end
end
# Returns array of architectures that the given command or library is built for.
def archs_for_command(cmd)
odisabled "archs_for_command"
cmd = which(cmd) unless Pathname.new(cmd).absolute?
Pathname.new(cmd).archs
end
def ignore_interrupts(_opt = nil)
# rubocop:disable Style/GlobalVars
$ignore_interrupts_nesting_level = 0 unless defined?($ignore_interrupts_nesting_level)

View File

@ -13,12 +13,6 @@ module GitHub
module_function
def open_api(url, data: nil, data_binary_path: nil, request_method: nil, scopes: [].freeze, parse_json: true)
odisabled "GitHub.open_api", "GitHub::API.open_rest"
API.open_rest(url, data: data, data_binary_path: data_binary_path, request_method: request_method,
scopes: scopes, parse_json: parse_json)
end
def check_runs(repo: nil, commit: nil, pr: nil)
if pr
repo = pr.fetch("base").fetch("repo").fetch("full_name")