Merge pull request #14548 from Homebrew/revert-14382-deprecate-disable-remove

Revert "Add deprecations and disables"
This commit is contained in:
Mike McQuaid 2023-02-07 19:11:26 +01:00 committed by GitHub
commit 932d2cf3b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 175 additions and 53 deletions

View File

@ -24,10 +24,10 @@ module Cask
attr_accessor :download, :allow_reassignment
def self.all
# TODO: ideally avoid using ARGV by moving to e.g. CLI::Parser
if ARGV.exclude?("--eval-all") && !Homebrew::EnvConfig.eval_all?
odeprecated "Cask::Cask#all without --all or HOMEBREW_EVAL_ALL"
end
# TODO: uncomment for 3.7.0 and ideally avoid using ARGV by moving to e.g. CLI::Parser
# if !ARGV.include?("--eval-all") && !Homebrew::EnvConfig.eval_all?
# odeprecated "Cask::Cask#all without --all or HOMEBREW_EVAL_ALL"
# end
Tap.flat_map(&:cask_files).map do |f|
CaskLoader::FromTapPathLoader.new(f).load(config: nil)

View File

@ -84,8 +84,8 @@ module Homebrew
all = args.eval_all?
if args.all?
unless all
odisabled "brew deps --all",
"brew deps --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew deps --all",
"brew deps --eval-all or HOMEBREW_EVAL_ALL"
end
all = true
end

View File

@ -45,7 +45,7 @@ module Homebrew
args = desc_args.parse
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
odisabled "brew desc", "brew desc --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew desc", "brew desc --eval-all or HOMEBREW_EVAL_ALL"
end
search_type = if args.search?

View File

@ -110,7 +110,7 @@ module Homebrew
elsif args.json
all = args.eval_all?
if !all && args.all? && !Homebrew::EnvConfig.eval_all?
odisabled "brew info --all", "brew info --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew info --all", "brew info --eval-all or HOMEBREW_EVAL_ALL"
all = true
end

View File

@ -38,7 +38,7 @@ module Homebrew
all = args.eval_all?
if args.all?
odisabled "brew info --all", "brew info --eval-all" if !all && !Homebrew::EnvConfig.eval_all?
odeprecated "brew info --all", "brew info --eval-all" if !all && !Homebrew::EnvConfig.eval_all?
all = true
end

View File

@ -46,7 +46,7 @@ module Homebrew
options = { aliases: args.aliases?, no_simulate: args.no_simulate? }
taps = if args.no_named?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
odisabled "brew readall", "brew readall --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew readall", "brew readall --eval-all or HOMEBREW_EVAL_ALL"
end
Tap
else

View File

@ -78,7 +78,7 @@ module Homebrew
if args.desc?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
odisabled "brew search --desc", "brew search --desc --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew search --desc", "brew search --desc --eval-all or HOMEBREW_EVAL_ALL"
end
Search.search_descriptions(string_or_regex, args)
elsif args.pull_request?

View File

@ -109,14 +109,14 @@ module Homebrew
all = args.eval_all?
if args.all?
unless all
odisabled "brew uses --all",
"brew uses --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew uses --all",
"brew uses --eval-all or HOMEBREW_EVAL_ALL"
end
all = true
end
if !args.installed? && !(all || Homebrew::EnvConfig.eval_all?)
odisabled "brew uses", "brew uses --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew uses", "brew uses --eval-all or HOMEBREW_EVAL_ALL"
end
if show_formulae_and_casks || args.formula?
deps += args.installed? ? Formula.installed : Formula.all

View File

@ -134,16 +134,17 @@ module Homebrew
[Formula.installed, Cask::Caskroom.casks]
elsif args.no_named?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
odisabled "brew audit",
"brew audit --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew audit",
"brew audit --eval-all or HOMEBREW_EVAL_ALL"
end
no_named_args = true
[Formula.all, Cask::Cask.all]
else
if args.named.any? { |named_arg| named_arg.end_with?(".rb") }
odeprecated "brew audit [path ...]",
"brew audit [name ...]"
end
# TODO: Add deprecation
# if args.named.any? { |named_arg| named_arg.end_with?(".rb") }
# odeprecated "brew audit [path ...]",
# "brew audit [name ...]"
# end
args.named.to_formulae_and_casks
.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) }

View File

@ -30,7 +30,7 @@ module Homebrew
def generate_man_completions
args = generate_man_completions_args.parse
odisabled "brew generate-man-completions --fail-if-not-changed" if args.fail_if_not_changed?
odeprecated "brew generate-man-completions --fail-if-not-changed" if args.fail_if_not_changed?
Commands.rebuild_internal_commands_completion_list
Manpages.regenerate_man_pages(quiet: args.quiet?)

View File

@ -59,7 +59,7 @@ module Homebrew
all = args.eval_all?
if args.all?
odisabled "brew livecheck --all", "brew livecheck --eval-all" if !all && !Homebrew::EnvConfig.eval_all?
odeprecated "brew livecheck --all", "brew livecheck --eval-all" if !all && !Homebrew::EnvConfig.eval_all?
all = true
end

View File

@ -51,7 +51,7 @@ module Homebrew
HOMEBREW_LIBRARY_PATH.cd do
if args.update? || args.update_all?
odisabled "brew typecheck --update --fail-if-not-changed" if args.fail_if_not_changed?
odeprecated "brew typecheck --update --fail-if-not-changed" if args.fail_if_not_changed?
excluded_gems = [
"did_you_mean", # RBI file is already provided by Sorbet

View File

@ -56,7 +56,7 @@ module Homebrew
all = args.eval_all?
if args.total?
if !all && !Homebrew::EnvConfig.eval_all?
odisabled "brew unbottled --total", "brew unbottled --total --eval-all or HOMEBREW_EVAL_ALL"
odeprecated "brew unbottled --total", "brew unbottled --total --eval-all or HOMEBREW_EVAL_ALL"
end
all = true
end
@ -100,7 +100,7 @@ module Homebrew
formulae = all_formulae = args.named.to_formulae
elsif args.dependents?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
odisabled "brew unbottled --dependents", "brew unbottled --all --dependents or HOMEBREW_EVAL_ALL"
odeprecated "brew unbottled --dependents", "brew unbottled --all --dependents or HOMEBREW_EVAL_ALL"
end
formulae = all_formulae = Formula.all

View File

@ -28,7 +28,7 @@ module Homebrew
def update_license_data
args = update_license_data_args.parse
odisabled "brew update-license-data --fail-if-not-changed" if args.fail_if_not_changed?
odeprecated "brew update-license-data --fail-if-not-changed" if args.fail_if_not_changed?
SPDX.download_latest_license_data!
diff = system_command "git", args: [

View File

@ -14,6 +14,7 @@ class LinkageChecker
libdl.so.2
libm.so.6
libmvec.so.1
libnsl.so.1
libnss_files.so.2
libpthread.so.0
libresolv.so.2
@ -40,9 +41,13 @@ class LinkageChecker
# If there's no library deprecated/disabled handling left:
# - Remove the `display_` overrides here and the associated generic aliases in HOMEBREW_LIBRARY/linkage_checker.rb
odisabled "linkage to libcrypt.so.1", "libcrypt.so.2 in the libxcrypt formula" if @libcrypt_found
return unless @libnsl_found
odisabled "linkage to libnsl.so.1", "libnsl.so.3 in the libnsl formula"
odeprecated "linkage to libnsl.so.1", "libnsl.so.3 in the libnsl formula",
disable: fail_on_libnsl1?(strict: strict),
disable_for_developers: false
end
def display_normal_output
@ -56,14 +61,19 @@ class LinkageChecker
end
def broken_library_linkage?(test: false, strict: false)
generic_broken_library_linkage?(test: test, strict: strict) || @libnsl_found
generic_broken_library_linkage?(test: test, strict: strict) || (fail_on_libnsl1?(strict: strict) && @libnsl_found)
end
private
def fail_on_libnsl1?(strict:)
strict || ENV["HOMEBREW_DISALLOW_LIBNSL1"].present?
end
def check_dylibs(rebuild_cache:)
generic_check_dylibs(rebuild_cache: rebuild_cache)
@libcrypt_found = true if @system_dylibs.any? { |s| File.basename(s) == "libcrypt.so.1" }
@libnsl_found = true if @system_dylibs.any? { |s| File.basename(s) == "libnsl.so.1" }
# glibc and gcc are implicit dependencies.

View File

@ -1017,7 +1017,8 @@ class Formula
# The generated launchd {.plist} file path.
sig { returns(Pathname) }
def plist_path
odeprecated "formula.plist_path", "formula.launchd_service_path"
# TODO: Add deprecation
# odeprecated "formula.plist_path", "formula.launchd_service_path"
launchd_service_path
end
@ -1835,10 +1836,10 @@ class Formula
# this should only be used when users specify `--all` to a command
# @private
def self.all
# TODO: ideally avoid using ARGV by moving to e.g. CLI::Parser
if ARGV.exclude?("--eval-all") && !Homebrew::EnvConfig.eval_all?
odeprecated "Formula#all without --all or HOMEBREW_EVAL_ALL"
end
# TODO: uncomment for 3.7.0 and ideally avoid using ARGV by moving to e.g. CLI::Parser
# if !ARGV.include?("--eval-all") && !Homebrew::EnvConfig.eval_all?
# odeprecated "Formula#all without --all or HOMEBREW_EVAL_ALL"
# end
files.map do |file|
Formulary.factory(file)
@ -3164,7 +3165,8 @@ class Formula
#
# @deprecated Please use {Homebrew::Service.require_root} instead.
def plist_options(options)
odeprecated "plist_options", "service.require_root"
# TODO: Deprecate
# odeprecated "plist_options", "service.require_root"
@plist_startup = options[:startup]
@plist_manual = options[:manual]
end
@ -3449,7 +3451,6 @@ class Formula
# Permit links to certain libraries that don't exist. Available on Linux only.
def ignore_missing_libraries(*libs)
odeprecated "ignore_missing_libraries"
unless Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise FormulaSpecificationError, "#{__method__} is available on Linux only"
end

View File

@ -1051,9 +1051,9 @@ class FormulaInstaller
return unless service
launchd_service_path = formula.launchd_service_path
launchd_service_path.atomic_write(service)
launchd_service_path.chmod 0644
plist_path = formula.plist_path
plist_path.atomic_write(service)
plist_path.chmod 0644
log = formula.var/"log"
log.mkpath if service.include? log.to_s
rescue Exception => e # rubocop:disable Lint/RescueException

View File

@ -131,6 +131,7 @@ module RuboCop
fails_with
resource
patch
ignore_missing_libraries
]
on_system_allowed_methods += on_system_methods.map(&:to_s)
_, offensive_node = check_order(component_precedence_list, on_system_block.body)

View File

@ -44,6 +44,17 @@ describe Caveats do
expect(described_class.new(f).caveats).to include("provides a launchd plist which can only be used on macOS!")
end
it "prints plist startup information when f.plist_startup is not nil" do
f = formula do
url "foo-1.0"
def plist
"plist_test.plist"
end
plist_options startup: true
end
expect(described_class.new(f).caveats).to include("startup")
end
it "prints plist login information when f.plist_startup is nil" do
f = formula do
url "foo-1.0"
@ -54,6 +65,39 @@ describe Caveats do
expect(described_class.new(f).caveats).to include("login")
end
it "gives information about restarting services after upgrade" do
f = formula do
url "foo-1.0"
def plist
"plist_test.plist"
end
plist_options startup: true
end
f_obj = described_class.new(f)
plist_path = mktmpdir/"plist"
FileUtils.touch plist_path
allow(f_obj).to receive(:plist_path).and_return(plist_path)
allow(Homebrew).to receive(:_system).and_return(true)
allow(Homebrew).to receive(:_system).with("/bin/launchctl list #{f.plist_name} &>/dev/null").and_return(true)
allow(plist_path).to receive(:symlink?).and_return(true)
expect(f_obj.caveats).to include("restart #{f.full_name}")
expect(f_obj.caveats).to include("sudo")
end
it "gives information about plist_manual" do
f = formula do
url "foo-1.0"
def plist
"plist_test.plist"
end
plist_options manual: "foo"
end
caveats = described_class.new(f).caveats
expect(caveats).to include("background service")
expect(caveats).to include(f.plist_manual)
end
it "gives information about service" do
f = formula do
url "foo-1.0"
@ -97,6 +141,7 @@ describe Caveats do
service do
run [bin/"cmd"]
end
plist_options startup: true
end
allow_any_instance_of(Object).to receive(:which).with("launchctl").and_return(nil)
@ -104,13 +149,13 @@ describe Caveats do
expect(described_class.new(f).caveats).to include("service which can only be used on macOS or systemd!")
end
it "prints service startup information when service.require_root is true" do
it "prints service startup information when f.plist_startup is not nil" do
f = formula do
url "foo-1.0"
service do
run [bin/"cmd"]
require_root true
end
plist_options startup: true
end
cmd = "#{HOMEBREW_CELLAR}/formula_name/1.0/bin/cmd"
allow(Homebrew).to receive(:_system).and_return(true)
@ -131,6 +176,21 @@ describe Caveats do
expect(described_class.new(f).caveats).to include("login")
end
it "gives information about plist_options restarting services after upgrade" do
f = formula do
url "foo-1.0"
service do
run [bin/"cmd"]
end
plist_options startup: true
end
cmd = "#{HOMEBREW_CELLAR}/formula_name/1.0/bin/cmd"
f_obj = described_class.new(f)
allow(Homebrew).to receive(:_system).and_return(true)
expect(Homebrew).to receive(:_system).with("ps aux | grep #{cmd}").and_return(true)
expect(f_obj.caveats).to include(" sudo brew services restart #{f.full_name}")
end
it "gives information about require_root restarting services after upgrade" do
f = formula do
url "foo-1.0"

View File

@ -203,11 +203,11 @@ describe FormulaInstaller do
describe "#install_service" do
it "works if plist is set" do
formula = Testball.new
path = formula.launchd_service_path
path = formula.plist_path
formula.opt_prefix.mkpath
expect(formula).to receive(:plist).twice.and_return("PLIST")
expect(formula).to receive(:launchd_service_path).and_call_original
expect(formula).to receive(:plist_path).and_call_original
installer = described_class.new(formula)
expect {
@ -219,7 +219,7 @@ describe FormulaInstaller do
it "works if service is set" do
formula = Testball.new
launchd_service_path = formula.launchd_service_path
plist_path = formula.plist_path
service_path = formula.systemd_service_path
service = Homebrew::Service.new(formula)
formula.opt_prefix.mkpath
@ -227,7 +227,7 @@ describe FormulaInstaller do
expect(formula).to receive(:plist).and_return(nil)
expect(formula).to receive(:service?).exactly(3).and_return(true)
expect(formula).to receive(:service).exactly(5).and_return(service)
expect(formula).to receive(:launchd_service_path).and_call_original
expect(formula).to receive(:plist_path).and_call_original
expect(formula).to receive(:systemd_service_path).and_call_original
expect(service).to receive(:timed?).and_return(false)
@ -240,13 +240,13 @@ describe FormulaInstaller do
installer.install_service
}.not_to output(/Error: Failed to install service files/).to_stderr
expect(launchd_service_path).to exist
expect(plist_path).to exist
expect(service_path).to exist
end
it "works if timed service is set" do
formula = Testball.new
launchd_service_path = formula.launchd_service_path
plist_path = formula.plist_path
service_path = formula.systemd_service_path
timer_path = formula.systemd_timer_path
service = Homebrew::Service.new(formula)
@ -255,7 +255,7 @@ describe FormulaInstaller do
expect(formula).to receive(:plist).and_return(nil)
expect(formula).to receive(:service?).exactly(3).and_return(true)
expect(formula).to receive(:service).exactly(6).and_return(service)
expect(formula).to receive(:launchd_service_path).and_call_original
expect(formula).to receive(:plist_path).and_call_original
expect(formula).to receive(:systemd_service_path).and_call_original
expect(formula).to receive(:systemd_timer_path).and_call_original
@ -270,19 +270,19 @@ describe FormulaInstaller do
installer.install_service
}.not_to output(/Error: Failed to install service files/).to_stderr
expect(launchd_service_path).to exist
expect(plist_path).to exist
expect(service_path).to exist
expect(timer_path).to exist
end
it "returns without definition" do
formula = Testball.new
path = formula.launchd_service_path
path = formula.plist_path
formula.opt_prefix.mkpath
expect(formula).to receive(:plist).and_return(nil)
expect(formula).to receive(:service?).exactly(3).and_return(nil)
expect(formula).not_to receive(:launchd_service_path)
expect(formula).not_to receive(:plist_path)
expect(formula).not_to receive(:to_systemd_unit)
installer = described_class.new(formula)
@ -295,13 +295,13 @@ describe FormulaInstaller do
it "errors with duplicate definition" do
formula = Testball.new
path = formula.launchd_service_path
path = formula.plist_path
formula.opt_prefix.mkpath
expect(formula).to receive(:plist).and_return("plist")
expect(formula).to receive(:service?).and_return(true)
expect(formula).not_to receive(:service)
expect(formula).not_to receive(:launchd_service_path)
expect(formula).not_to receive(:plist_path)
installer = described_class.new(formula)
expect {

View File

@ -1845,6 +1845,54 @@ describe Formula do
end
end
describe "#ignore_missing_libraries" do
after do
Homebrew::SimulateSystem.clear
end
it "adds library to allowed_missing_libraries on Linux", :needs_linux do
Homebrew::SimulateSystem.clear
f = formula do
url "foo-1.0"
ignore_missing_libraries "bar.so"
end
expect(f.class.allowed_missing_libraries.to_a).to eq(["bar.so"])
end
it "adds library to allowed_missing_libraries on macOS when simulating Linux", :needs_macos do
Homebrew::SimulateSystem.os = :linux
f = formula do
url "foo-1.0"
ignore_missing_libraries "bar.so"
end
expect(f.class.allowed_missing_libraries.to_a).to eq(["bar.so"])
end
it "raises an error on macOS", :needs_macos do
Homebrew::SimulateSystem.clear
expect {
formula do
url "foo-1.0"
ignore_missing_libraries "bar.so"
end
}.to raise_error("ignore_missing_libraries is available on Linux only")
end
it "raises an error on Linux when simulating macOS", :needs_linux do
Homebrew::SimulateSystem.os = :macos
expect {
formula do
url "foo-1.0"
ignore_missing_libraries "bar.so"
end
}.to raise_error("ignore_missing_libraries is available on Linux only")
end
end
describe "#generate_completions_from_executable" do
let(:f) do
Class.new(Testball) do

View File

@ -398,8 +398,9 @@ module Kernel
end
# GZips the given paths, and returns the gzipped paths.
# TODO: Add deprecation
# odeprecated "Utils.gzip" "Utils::Gzip.compress"
def gzip(*paths)
odeprecated "Utils.gzip", "Utils::Gzip.compress"
Utils::Gzip.compress(*paths)
end