Skip to content

Commit

Permalink
Merge pull request #14553 from MikeMcQuaid/4.0.0-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid authored Feb 8, 2023
2 parents 2bc0f01 + 6b43630 commit cb1872e
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 210 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ jobs:

- name: Run brew audit --skip-style on all taps
run: brew audit --eval-all --skip-style --except=version --display-failures-only
env:
HOMEBREW_NO_INSTALL_FROM_API: 1

- name: Set up all Homebrew taps
run: |
Expand All @@ -96,6 +98,7 @@ jobs:
brew tap homebrew/cask-fonts
brew tap homebrew/cask-versions
brew tap homebrew/command-not-found
brew tap homebrew/core
brew tap homebrew/formula-analytics
brew tap homebrew/portable-ruby
brew tap homebrew/services
Expand All @@ -109,6 +112,7 @@ jobs:
run: brew audit --skip-style --except=version --tap=homebrew/core
env:
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
HOMEBREW_NO_INSTALL_FROM_API: 1

- name: Run brew style on official taps
run: |
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ auto-update() {

if [[ -z "${HOMEBREW_AUTO_UPDATE_SECS}" ]]
then
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]]
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
then
# 24 hours
HOMEBREW_AUTO_UPDATE_SECS="86400"
Expand Down
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: 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
# 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

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
odeprecated "brew deps --all",
"brew deps --eval-all or HOMEBREW_EVAL_ALL"
odisabled "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?
odeprecated "brew desc", "brew desc --eval-all or HOMEBREW_EVAL_ALL"
odisabled "brew desc", "brew desc --eval-all or HOMEBREW_EVAL_ALL"
end

search_type = if args.search?
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/cmd/formulae.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ homebrew-formulae() {
# HOMEBREW_CACHE is set by brew.sh
# shellcheck disable=SC2154
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" &&
-n "${HOMEBREW_INSTALL_FROM_API}" &&
-f "${HOMEBREW_CACHE}/api/formula.json" ]]
then
local api_formulae
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?
odeprecated "brew info --all", "brew info --eval-all or HOMEBREW_EVAL_ALL"
odisabled "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?
odeprecated "brew info --all", "brew info --eval-all" if !all && !Homebrew::EnvConfig.eval_all?
odisabled "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?
odeprecated "brew readall", "brew readall --eval-all or HOMEBREW_EVAL_ALL"
odisabled "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?
odeprecated "brew search --desc", "brew search --desc --eval-all or HOMEBREW_EVAL_ALL"
odisabled "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
9 changes: 4 additions & 5 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ EOS
fi

if [[ -d "${HOMEBREW_CORE_REPOSITORY}" ]] ||
[[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]]
[[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
then
HOMEBREW_CORE_AVAILABLE="1"
fi
Expand Down Expand Up @@ -566,8 +566,7 @@ EOS

for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
do
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
[[ -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" ]]
then
continue
Expand Down Expand Up @@ -726,7 +725,7 @@ EOS

for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
do
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]] &&
[[ -z "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ||
"${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" ]]
Expand Down Expand Up @@ -768,7 +767,7 @@ EOS
fi
done

if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]]
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
then
mkdir -p "${HOMEBREW_CACHE}/api"

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
odeprecated "brew uses --all",
"brew uses --eval-all or HOMEBREW_EVAL_ALL"
odisabled "brew uses --all",
"brew uses --eval-all or HOMEBREW_EVAL_ALL"
end
all = true
end

if !args.installed? && !(all || Homebrew::EnvConfig.eval_all?)
odeprecated "brew uses", "brew uses --eval-all or HOMEBREW_EVAL_ALL"
odisabled "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: 6 additions & 7 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,16 @@ def audit
[Formula.installed, Cask::Caskroom.casks]
elsif args.no_named?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
odeprecated "brew audit",
"brew audit --eval-all or HOMEBREW_EVAL_ALL"
odisabled "brew audit",
"brew audit --eval-all or HOMEBREW_EVAL_ALL"
end
no_named_args = true
[Formula.all, Cask::Cask.all]
else
# TODO: Add deprecation
# if args.named.any? { |named_arg| named_arg.end_with?(".rb") }
# odeprecated "brew audit [path ...]",
# "brew audit [name ...]"
# end
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

odeprecated "brew generate-man-completions --fail-if-not-changed" if args.fail_if_not_changed?
odisabled "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?
odeprecated "brew livecheck --all", "brew livecheck --eval-all" if !all && !Homebrew::EnvConfig.eval_all?
odisabled "brew livecheck --all", "brew livecheck --eval-all" if !all && !Homebrew::EnvConfig.eval_all?
all = true
end

Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/dev-cmd/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def setup_environment!(args)
ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online?
ENV["HOMEBREW_SORBET_RUNTIME"] = "1"

# TODO: remove this and fix tests when possible.
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"

ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp

# Avoid local configuration messing with tests, e.g. git being configured
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?
odeprecated "brew typecheck --update --fail-if-not-changed" if args.fail_if_not_changed?
odisabled "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?
odeprecated "brew unbottled --total", "brew unbottled --total --eval-all or HOMEBREW_EVAL_ALL"
odisabled "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?
odeprecated "brew unbottled --dependents", "brew unbottled --all --dependents or HOMEBREW_EVAL_ALL"
odisabled "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
odeprecated "brew update-license-data --fail-if-not-changed" if args.fail_if_not_changed?
odisabled "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: 3 additions & 11 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module EnvConfig
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
"e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, " \
"disable auto-update entirely with HOMEBREW_NO_AUTO_UPDATE.",
default_text: "300 (5 minutes) or 86400 (24 hours) if HOMEBREW_INSTALL_FROM_API is set.",
default_text: "86400 (24 hours) or 300 (5 minutes) if HOMEBREW_NO_INSTALL_FROM_API is set.",
},
HOMEBREW_AUTOREMOVE: {
description: "If set, calls to `brew cleanup` and `brew uninstall` will automatically " \
Expand Down Expand Up @@ -231,13 +231,6 @@ module EnvConfig
default_text: 'The "Beer Mug" emoji.',
default: "🍺",
},
HOMEBREW_INSTALL_FROM_API: {
description: "If set, install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew's " \
"API instead of needing (large, slow) local checkouts of these repositories. Note, this will " \
"only take effect in supported configurations (i.e. using the default Homebrew prefix and, " \
"if on macOS, on a supported version).",
boolean: true,
},
HOMEBREW_LIVECHECK_WATCHLIST: {
description: "Consult this file for the list of formulae to check by default when no formula argument " \
"is passed to `brew livecheck`.",
Expand Down Expand Up @@ -321,8 +314,7 @@ module EnvConfig
},
HOMEBREW_NO_INSTALL_FROM_API: {
description: "If set, do not install formulae and casks in homebrew/core and homebrew/cask taps using " \
"Homebrew's API even if `HOMEBREW_INSTALL_FROM_API` is set and instead use (large, slow) " \
"local checkouts of these repositories.",
"Homebrew's API and instead use (large, slow) local checkouts of these repositories.",
boolean: true,
},
HOMEBREW_NO_INSTALL_UPGRADE: {
Expand Down Expand Up @@ -496,7 +488,7 @@ def install_from_api?
return false if OS.unsupported_configuration?
return false unless Homebrew.default_prefix?

ENV["HOMEBREW_NO_INSTALL_FROM_API"].blank? && ENV["HOMEBREW_INSTALL_FROM_API"].present?
ENV["HOMEBREW_NO_INSTALL_FROM_API"].blank?
end
end
end
14 changes: 2 additions & 12 deletions Library/Homebrew/extend/os/linux/linkage_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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 @@ -41,13 +40,9 @@ 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

odeprecated "linkage to libnsl.so.1", "libnsl.so.3 in the libnsl formula",
disable: fail_on_libnsl1?(strict: strict),
disable_for_developers: false
odisabled "linkage to libnsl.so.1", "libnsl.so.3 in the libnsl formula"
end

def display_normal_output
Expand All @@ -61,19 +56,14 @@ 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) || (fail_on_libnsl1?(strict: strict) && @libnsl_found)
generic_broken_library_linkage?(test: test, 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: 7 additions & 8 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,7 @@ def service_name
# The generated launchd {.plist} file path.
sig { returns(Pathname) }
def plist_path
# TODO: Add deprecation
# odeprecated "formula.plist_path", "formula.launchd_service_path"
odeprecated "formula.plist_path", "formula.launchd_service_path"
launchd_service_path
end

Expand Down Expand Up @@ -1836,10 +1835,10 @@ def self.full_names
# this should only be used when users specify `--all` to a command
# @private
def self.all
# 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
# 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

files.map do |file|
Formulary.factory(file)
Expand Down Expand Up @@ -3165,8 +3164,7 @@ def patch(strip = :p1, src = nil, &block)
#
# @deprecated Please use {Homebrew::Service.require_root} instead.
def plist_options(options)
# TODO: Deprecate
# odeprecated "plist_options", "service.require_root"
odeprecated "plist_options", "service.require_root"
@plist_startup = options[:startup]
@plist_manual = options[:manual]
end
Expand Down Expand Up @@ -3451,6 +3449,7 @@ 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

plist_path = formula.plist_path
plist_path.atomic_write(service)
plist_path.chmod 0644
launchd_service_path = formula.launchd_service_path
launchd_service_path.atomic_write(service)
launchd_service_path.chmod 0644
log = formula.var/"log"
log.mkpath if service.include? log.to_s
rescue Exception => e # rubocop:disable Lint/RescueException
Expand Down
Loading

0 comments on commit cb1872e

Please sign in to comment.