Skip to content

Commit

Permalink
Merge pull request #14548 from Homebrew/revert-14382-deprecate-disabl…
Browse files Browse the repository at this point in the history
…e-remove

Revert "Add deprecations and disables"
  • Loading branch information
MikeMcQuaid authored Feb 7, 2023
2 parents f4e6048 + 6882ac1 commit 932d2cf
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 53 deletions.
8 changes: 4 additions & 4 deletions Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class 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)
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/cmd/deps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def deps
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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/desc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def desc
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?
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def info
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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def options

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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/readall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def readall
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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def search

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?
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/cmd/uses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ def intersection_of_dependents(use_runtime_dependents, used_formulae, args:)
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
Expand Down
13 changes: 7 additions & 6 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ def audit
[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) }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/generate-man-completions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate_man_completions_args
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?)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/livecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def livecheck

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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/typecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def typecheck

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
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/dev-cmd/unbottled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def unbottled
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
Expand Down Expand Up @@ -100,7 +100,7 @@ def formulae_all_installs_from_args(args, all)
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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/update-license-data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def update_license_data_args

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: [
Expand Down
14 changes: 12 additions & 2 deletions Library/Homebrew/extend/os/linux/linkage_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,9 +41,13 @@ def display_deprecated_warning(strict: false)
# 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
Expand All @@ -56,14 +61,19 @@ def display_test_output(puts_output: true, strict: false)
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.
Expand Down
15 changes: 8 additions & 7 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,8 @@ def service_name
# 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

Expand Down Expand Up @@ -1835,10 +1836,10 @@ def self.full_names
# 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)
Expand Down Expand Up @@ -3164,7 +3165,8 @@ def patch(strip = :p1, src = nil, &block)
#
# @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
Expand Down Expand Up @@ -3449,7 +3451,6 @@ def link_overwrite(*paths)

# 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
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,9 @@ def install_service

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
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/rubocops/components_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def check_on_system_block_content(component_precedence_list, on_system_block)
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)
Expand Down
64 changes: 62 additions & 2 deletions Library/Homebrew/test/caveats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ def plist
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"
Expand All @@ -54,6 +65,39 @@ def plist
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"
Expand Down Expand Up @@ -97,20 +141,21 @@ def plist
service do
run [bin/"cmd"]
end
plist_options startup: true
end

allow_any_instance_of(Object).to receive(:which).with("launchctl").and_return(nil)
allow_any_instance_of(Object).to receive(:which).with("systemctl").and_return(nil)
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)
Expand All @@ -131,6 +176,21 @@ def plist
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"
Expand Down
Loading

0 comments on commit 932d2cf

Please sign in to comment.