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" - "global.rb"
- "keg_relocate.rb" - "keg_relocate.rb"
- "os/linux/global.rb" - "os/linux/global.rb"
- "os/mac/architecture_list.rb"
- "os/mac/global.rb" - "os/mac/global.rb"
- "os/mac/keg.rb" - "os/mac/keg.rb"
- "reinstall.rb" - "reinstall.rb"

View File

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

View File

@ -406,18 +406,6 @@ module Homebrew
end end
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 } sig { void }
def hide_from_man_page! def hide_from_man_page!
@hide_from_man_page = true @hide_from_man_page = true

View File

@ -60,8 +60,7 @@ module Homebrew
conflicts "--open", "--closed" conflicts "--open", "--closed"
conflicts(*package_manager_switches) conflicts(*package_manager_switches)
# TODO: (3.2) Add `min: 1` the `named_args` once `brew search --cask` is removed named_args :text_or_regex, min: 1
named_args :text_or_regex
end end
end end
@ -74,12 +73,6 @@ module Homebrew
return return
end 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(" ") query = args.named.join(" ")
string_or_regex = query_regexp(query) string_or_regex = query_regexp(query)

View File

@ -56,17 +56,9 @@ module Homebrew
elsif args.no_named? elsif args.no_named?
puts Tap.names puts Tap.names
else else
if args.full? odeprecated "`brew tap --full`" 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
if args.shallow? odeprecated "`brew tap --shallow`" 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
tap = Tap.fetch(args.named.first) tap = Tap.fetch(args.named.first)
begin begin

View File

@ -1,4 +1,2 @@
# typed: strict # typed: strict
# frozen_string_literal: true # 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 end
def man def man
odeprecated "`brew man`", "`brew generate-man-completions`" odisabled "`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
end end
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
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 } sig { void }
def fortran def fortran
# Ignore repeated calls to this function as it will misleadingly warn about # Ignore repeated calls to this function as it will misleadingly warn about
@ -328,11 +315,6 @@ module SharedEnvExtension
sig { void } sig { void }
def permit_arch_flags; end def permit_arch_flags; end
sig { void }
def permit_weak_imports
odisabled "ENV.permit_weak_imports"
end
# @private # @private
sig { params(cc: T.any(Symbol, String)).returns(T::Boolean) } sig { params(cc: T.any(Symbol, String)).returns(T::Boolean) }
def compiler_any_clang?(cc = compiler) def compiler_any_clang?(cc = compiler)

View File

@ -6,7 +6,7 @@ require "macho"
module Hardware module Hardware
class CPU class CPU
class << self class << self
undef type, family, universal_archs, features, sse4? undef type, family, features, sse4?
# These methods use info spewed out by sysctl. # These methods use info spewed out by sysctl.
# Look in <mach/machine.h> for decoding info. # Look in <mach/machine.h> for decoding info.
@ -31,16 +31,6 @@ module Hardware
end end
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 # 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 # Apple Silicon Mac. This can be detected via seeing if there's a
# conflict between what `uname` reports and the underlying `sysctl` flags, # conflict between what `uname` reports and the underlying `sysctl` flags,

View File

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

View File

@ -42,18 +42,18 @@ module Homebrew
assert_not_same: :refute_same, assert_not_same: :refute_same,
}.each do |old_method, new_method| }.each do |old_method, new_method|
define_method(old_method) do |*args| define_method(old_method) do |*args|
odeprecated old_method, new_method odisabled old_method, new_method
send(new_method, *args) send(new_method, *args)
end end
end end
def assert_true(act, msg = nil) 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) assert_equal(true, act, msg)
end end
def assert_false(act, msg = nil) 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) assert_equal(false, act, msg)
end end

View File

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

View File

@ -533,7 +533,7 @@ module Homebrew
rescue ArgumentError => e rescue ArgumentError => e
raise unless e.message.include?("unknown keyword: cask") 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 end
match_version_map = strategy_data[:matches] match_version_map = strategy_data[:matches]
regex = strategy_data[:regex] 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 # frozen_string_literal: true
require "macho" require "macho"
require "os/mac/architecture_list"
# {Pathname} extension for dealing with Mach-O files. # {Pathname} extension for dealing with Mach-O files.
# #
@ -65,8 +64,7 @@ module MachOShim
end end
def archs def archs
# TODO: (3.2) remove ArchitectureListExtension mach_data.map { |m| m.fetch :arch }
mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension)
end end
def arch def arch

View File

@ -491,7 +491,7 @@ class BottleSpecification
def cellar(val = nil) def cellar(val = nil)
if val.present? if val.present?
odeprecated( odisabled(
"`cellar` in a bottle block", "`cellar` in a bottle block",
"`brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument", "`brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument",
) )
@ -552,7 +552,7 @@ class BottleSpecification
end end
if digest && tag if digest && tag
odeprecated( odisabled(
'`sha256 "digest" => :tag` in a bottle block', '`sha256 "digest" => :tag` in a bottle block',
'`brew style --fix` on the formula to update the style or use `sha256 tag: "digest"`', '`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 # something here
end 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 # something here
end 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
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 describe "text executables" do
let(:pn) { HOMEBREW_PREFIX/"an_executable" } let(:pn) { HOMEBREW_PREFIX/"an_executable" }

View File

@ -402,14 +402,6 @@ module Kernel
end end
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) def ignore_interrupts(_opt = nil)
# rubocop:disable Style/GlobalVars # rubocop:disable Style/GlobalVars
$ignore_interrupts_nesting_level = 0 unless defined?($ignore_interrupts_nesting_level) $ignore_interrupts_nesting_level = 0 unless defined?($ignore_interrupts_nesting_level)

View File

@ -13,12 +13,6 @@ module GitHub
module_function 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) def check_runs(repo: nil, commit: nil, pr: nil)
if pr if pr
repo = pr.fetch("base").fetch("repo").fetch("full_name") repo = pr.fetch("base").fetch("repo").fetch("full_name")