Fix namespacing
This commit is contained in:
parent
7cd329c116
commit
bb80f063dc
@ -60,7 +60,7 @@ module Homebrew
|
||||
return false if Homebrew::EnvConfig.no_verify_attestations?
|
||||
return true if Homebrew::EnvConfig.verify_attestations?
|
||||
return false if ENV.fetch("CI", false)
|
||||
return false if OS.unsupported_configuration?
|
||||
return false if ::OS.unsupported_configuration?
|
||||
|
||||
# Always check credentials last to avoid unnecessary credential extraction.
|
||||
(Homebrew::EnvConfig.developer? || Homebrew::EnvConfig.devcmdrun?) && GitHub::API.credentials.present?
|
||||
|
||||
@ -394,10 +394,10 @@ module Homebrew
|
||||
# On Linux, GCC installation can be moved so long as the whole directory tree is moved together:
|
||||
# https://gcc-help.gcc.gnu.narkive.com/GnwuCA7l/moving-gcc-from-the-installation-path-is-it-allowed.
|
||||
when Version.formula_optionally_versioned_regex(:gcc)
|
||||
Regexp.union(%r{#{cellar_regex}/gcc}, %r{#{prefix_regex}/opt/gcc}) if OS.linux?
|
||||
Regexp.union(%r{#{cellar_regex}/gcc}, %r{#{prefix_regex}/opt/gcc}) if ::OS.linux?
|
||||
# binutils is relocatable for the same reason: https://github.com/Homebrew/brew/pull/11899#issuecomment-906804451.
|
||||
when Version.formula_optionally_versioned_regex(:binutils)
|
||||
%r{#{cellar_regex}/binutils} if OS.linux?
|
||||
%r{#{cellar_regex}/binutils} if ::OS.linux?
|
||||
end
|
||||
# rubocop:enable Homebrew/MoveToExtendOS
|
||||
|
||||
|
||||
@ -116,12 +116,12 @@ module Homebrew
|
||||
|
||||
# TODO: Refactor and move to extend/os
|
||||
# rubocop:disable Homebrew/MoveToExtendOS
|
||||
unless OS.mac?
|
||||
unless ::OS.mac?
|
||||
bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask"
|
||||
files = files.grep_v(%r{^test/(os/mac|cask)(/.*|_spec\.rb)$})
|
||||
end
|
||||
|
||||
unless OS.linux?
|
||||
unless ::OS.linux?
|
||||
bundle_args << "--tag" << "~needs_linux"
|
||||
files = files.grep_v(%r{^test/os/linux(/.*|_spec\.rb)$})
|
||||
end
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
module CleanupLinux
|
||||
module OS
|
||||
module Linux
|
||||
module Cleanup
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { Cleanup }
|
||||
requires_ancestor { Homebrew::Cleanup }
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def use_system_ruby?
|
||||
@ -22,6 +24,8 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::Cleanup.prepend(Homebrew::CleanupLinux)
|
||||
Homebrew::Cleanup.prepend(Homebrew::OS::Linux::Cleanup)
|
||||
|
||||
33
Library/Homebrew/extend/os/linux/cli/parser.rb
Normal file
33
Library/Homebrew/extend/os/linux/cli/parser.rb
Normal file
@ -0,0 +1,33 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
module OS
|
||||
module Linux
|
||||
module CLI
|
||||
module Parser
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { Homebrew::CLI::Parser }
|
||||
|
||||
sig { void }
|
||||
def set_default_options
|
||||
args["formula?"] = true if args.respond_to?(:formula?)
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def validate_options
|
||||
return unless args.respond_to?(:cask?)
|
||||
return unless args.cask?
|
||||
|
||||
# NOTE: We don't raise an error here because we don't want
|
||||
# to print the help page or a stack trace.
|
||||
odie "Invalid `--cask` usage: Casks do not work on Linux"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::CLI::Parser.prepend(Homebrew::OS::Linux::CLI::Parser)
|
||||
@ -95,11 +95,11 @@ module Homebrew
|
||||
end
|
||||
|
||||
def check_glibc_minimum_version
|
||||
return unless OS::Linux::Glibc.below_minimum_version?
|
||||
return unless ::OS::Linux::Glibc.below_minimum_version?
|
||||
|
||||
<<~EOS
|
||||
Your system glibc #{OS::Linux::Glibc.system_version} is too old.
|
||||
We only support glibc #{OS::Linux::Glibc.minimum_version} or later.
|
||||
Your system glibc #{::OS::Linux::Glibc.system_version} is too old.
|
||||
We only support glibc #{::OS::Linux::Glibc.minimum_version} or later.
|
||||
#{please_create_pull_requests}
|
||||
We recommend updating to a newer version via your distribution's
|
||||
package manager, upgrading your distribution to the latest version,
|
||||
@ -108,11 +108,11 @@ module Homebrew
|
||||
end
|
||||
|
||||
def check_kernel_minimum_version
|
||||
return unless OS::Linux::Kernel.below_minimum_version?
|
||||
return unless ::OS::Linux::Kernel.below_minimum_version?
|
||||
|
||||
<<~EOS
|
||||
Your Linux kernel #{OS.kernel_version} is too old.
|
||||
We only support kernel #{OS::Linux::Kernel.minimum_version} or later.
|
||||
Your Linux kernel #{::OS.kernel_version} is too old.
|
||||
We only support kernel #{::OS::Linux::Kernel.minimum_version} or later.
|
||||
You will be unable to use binary packages (bottles).
|
||||
#{please_create_pull_requests}
|
||||
We recommend updating to a newer version via your distribution's
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
# typed: true # rubocop:disable Sorbet/StrictSigil
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FormulaLinux
|
||||
module Homebrew
|
||||
module OS
|
||||
module Linux
|
||||
module Formula
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { Formula }
|
||||
requires_ancestor { ::Formula }
|
||||
|
||||
sig { params(name: String, version: T.nilable(T.any(String, Integer))).returns(String) }
|
||||
def shared_library(name, version = nil)
|
||||
@ -47,6 +50,9 @@ module FormulaLinux
|
||||
def valid_platform?
|
||||
requirements.none?(MacOSRequirement)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Formula.prepend(FormulaLinux)
|
||||
Formula.prepend(Homebrew::OS::Linux::Formula)
|
||||
|
||||
@ -78,7 +78,7 @@ module Homebrew
|
||||
private_class_method :symlink_ld_so
|
||||
|
||||
def self.setup_preferred_gcc_libs
|
||||
gcc_opt_prefix = HOMEBREW_PREFIX/"opt/#{OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA}"
|
||||
gcc_opt_prefix = HOMEBREW_PREFIX/"opt/#{::OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA}"
|
||||
glibc_installed = (HOMEBREW_PREFIX/"opt/glibc/bin/ld.so").readable?
|
||||
|
||||
return unless gcc_opt_prefix.readable?
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
module CLI
|
||||
module ParserLinux
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { Homebrew::CLI::Parser }
|
||||
|
||||
sig { void }
|
||||
def set_default_options
|
||||
args["formula?"] = true if args.respond_to?(:formula?)
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def validate_options
|
||||
return unless args.respond_to?(:cask?)
|
||||
return unless args.cask?
|
||||
|
||||
# NOTE: We don't raise an error here because we don't want
|
||||
# to print the help page or a stack trace.
|
||||
odie "Invalid `--cask` usage: Casks do not work on Linux"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::CLI::Parser.prepend(Homebrew::CLI::ParserLinux)
|
||||
@ -1,13 +1,19 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module CleanerMac
|
||||
module Homebrew
|
||||
module OS
|
||||
module MacOS
|
||||
module Cleaner
|
||||
private
|
||||
|
||||
sig { params(path: Pathname).returns(T::Boolean) }
|
||||
def executable_path?(path)
|
||||
path.mach_o_executable? || path.text_executable?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Cleaner.prepend(CleanerMac)
|
||||
Cleaner.prepend(Homebrew::OS::MacOS::Cleaner)
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
module CleanupMac
|
||||
module OS
|
||||
module MacOS
|
||||
module Cleanup
|
||||
sig { returns(T::Boolean) }
|
||||
def use_system_ruby?
|
||||
return false if Homebrew::EnvConfig.force_vendor_ruby?
|
||||
@ -10,6 +12,8 @@ module Homebrew
|
||||
Homebrew::EnvConfig.developer? && ENV["HOMEBREW_USE_RUBY_FROM_PATH"].present?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::Cleanup.prepend(Homebrew::CleanupMac)
|
||||
Homebrew::Cleanup.prepend(Homebrew::OS::MacOS::Cleanup)
|
||||
|
||||
@ -2,11 +2,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
module OS
|
||||
module MacOS
|
||||
module DevCmd
|
||||
module BottleMac
|
||||
module Bottle
|
||||
sig { returns(T::Array[String]) }
|
||||
def tar_args
|
||||
if MacOS.version >= :catalina
|
||||
if ::MacOS.version >= :catalina
|
||||
["--no-mac-metadata", "--no-acls", "--no-xattrs"].freeze
|
||||
else
|
||||
[].freeze
|
||||
@ -19,6 +21,8 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::DevCmd::Bottle.prepend(Homebrew::DevCmd::BottleMac)
|
||||
Homebrew::DevCmd::Bottle.prepend(Homebrew::OS::MacOS::DevCmd::Bottle)
|
||||
|
||||
@ -110,9 +110,9 @@ module Homebrew
|
||||
return if ENV["HOMEBREW_INTEGRATION_TEST"]
|
||||
|
||||
who = +"We"
|
||||
what = if OS::Mac.version.prerelease?
|
||||
what = if ::OS::Mac.version.prerelease?
|
||||
"pre-release version"
|
||||
elsif OS::Mac.version.outdated_release?
|
||||
elsif ::OS::Mac.version.outdated_release?
|
||||
who << " (and Apple)"
|
||||
"old version"
|
||||
end
|
||||
@ -149,7 +149,7 @@ module Homebrew
|
||||
#{MacOS::Xcode.update_instructions}
|
||||
EOS
|
||||
|
||||
if OS::Mac.version.prerelease?
|
||||
if ::OS::Mac.version.prerelease?
|
||||
current_path = Utils.popen_read("/usr/bin/xcode-select", "-p")
|
||||
message += <<~EOS
|
||||
If #{MacOS::Xcode.latest_version} is installed, you may need to:
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FormulaMac
|
||||
module Homebrew
|
||||
module OS
|
||||
module MacOS
|
||||
module Formula
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { Formula }
|
||||
requires_ancestor { ::Formula }
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def valid_platform?
|
||||
@ -19,18 +22,20 @@ module FormulaMac
|
||||
).returns(T::Array[String])
|
||||
}
|
||||
def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework: "LAST")
|
||||
args = generic_std_cmake_args(install_prefix:, install_libdir:,
|
||||
find_framework:)
|
||||
args = generic_std_cmake_args(install_prefix:, install_libdir:, find_framework:)
|
||||
|
||||
# Avoid false positives for clock_gettime support on 10.11.
|
||||
# CMake cache entries for other weak symbols may be added here as needed.
|
||||
args << "-DHAVE_CLOCK_GETTIME:INTERNAL=0" if MacOS.version == "10.11" && MacOS::Xcode.version >= "8.0"
|
||||
args << "-DHAVE_CLOCK_GETTIME:INTERNAL=0" if ::MacOS.version == "10.11" && ::MacOS::Xcode.version >= "8.0"
|
||||
|
||||
# Ensure CMake is using the same SDK we are using.
|
||||
args << "-DCMAKE_OSX_SYSROOT=#{MacOS.sdk_for_formula(self).path}" if MacOS.sdk_root_needed?
|
||||
args << "-DCMAKE_OSX_SYSROOT=#{::MacOS.sdk_for_formula(self).path}" if ::MacOS.sdk_root_needed?
|
||||
|
||||
args
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Formula.prepend(FormulaMac)
|
||||
Formula.prepend(Homebrew::OS::MacOS::Formula)
|
||||
|
||||
@ -1,16 +1,22 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FormulaInstallerMac
|
||||
module Homebrew
|
||||
module OS
|
||||
module MacOS
|
||||
module FormulaInstaller
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { FormulaInstaller }
|
||||
requires_ancestor { ::FormulaInstaller }
|
||||
|
||||
sig { params(formula: Formula).returns(T.nilable(T::Boolean)) }
|
||||
def fresh_install?(formula)
|
||||
!Homebrew::EnvConfig.developer? && !OS::Mac.version.outdated_release? &&
|
||||
!Homebrew::EnvConfig.developer? && !::OS::Mac.version.outdated_release? &&
|
||||
(!installed_as_dependency? || !formula.any_version_installed?)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
FormulaInstaller.prepend(FormulaInstallerMac)
|
||||
FormulaInstaller.prepend(Homebrew::OS::MacOS::FormulaInstaller)
|
||||
|
||||
@ -1,14 +1,20 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module LinkageCheckerMac
|
||||
module Homebrew
|
||||
module OS
|
||||
module MacOS
|
||||
module LinkageChecker
|
||||
private
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def system_libraries_exist_in_cache?
|
||||
# In macOS Big Sur and later, system libraries do not exist on-disk and instead exist in a cache.
|
||||
MacOS.version >= :big_sur
|
||||
::MacOS.version >= :big_sur
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
LinkageChecker.prepend(LinkageCheckerMac)
|
||||
LinkageChecker.prepend(Homebrew::OS::MacOS::LinkageChecker)
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ReadallMac
|
||||
module Homebrew
|
||||
module OS
|
||||
module MacOS
|
||||
module Readall
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { Kernel }
|
||||
@ -13,7 +16,7 @@ module ReadallMac
|
||||
current_macos_version = if os_name.is_a?(Symbol)
|
||||
MacOSVersion.from_symbol(os_name)
|
||||
else
|
||||
MacOS.version
|
||||
::MacOS.version
|
||||
end
|
||||
|
||||
success = T.let(true, T::Boolean)
|
||||
@ -37,6 +40,9 @@ module ReadallMac
|
||||
end
|
||||
success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Readall.singleton_class.prepend(ReadallMac)
|
||||
Readall.singleton_class.prepend(Homebrew::OS::MacOS::Readall)
|
||||
|
||||
@ -2,17 +2,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
module SimulateSystemMac
|
||||
module OS
|
||||
module MacOS
|
||||
module SimulateSystem
|
||||
sig { returns(T::Boolean) }
|
||||
def simulating_or_running_on_macos?
|
||||
SimulateSystem.os.blank? || [:macos, *MacOSVersion::SYMBOLS.keys].include?(SimulateSystem.os)
|
||||
Homebrew::SimulateSystem.os.blank? || [:macos,
|
||||
*MacOSVersion::SYMBOLS.keys].include?(Homebrew::SimulateSystem.os)
|
||||
end
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def current_os
|
||||
SimulateSystem.os || MacOS.version.to_sym
|
||||
Homebrew::SimulateSystem.os || ::MacOS.version.to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::SimulateSystem.singleton_class.prepend(Homebrew::SimulateSystemMac)
|
||||
Homebrew::SimulateSystem.singleton_class.prepend(Homebrew::OS::MacOS::SimulateSystem)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "extend/os/linux/parser" if OS.linux?
|
||||
require "extend/os/linux/cli/parser" if OS.linux?
|
||||
|
||||
@ -504,9 +504,9 @@ module Homebrew
|
||||
return unless @core_tap
|
||||
return if formula.name != "glibc"
|
||||
# Also allow LINUX_GLIBC_NEXT_CI_VERSION for when we're upgrading.
|
||||
return if [OS::LINUX_GLIBC_CI_VERSION, OS::LINUX_GLIBC_NEXT_CI_VERSION].include?(formula.version.to_s)
|
||||
return if [::OS::LINUX_GLIBC_CI_VERSION, ::OS::LINUX_GLIBC_NEXT_CI_VERSION].include?(formula.version.to_s)
|
||||
|
||||
problem "The glibc version must be #{OS::LINUX_GLIBC_CI_VERSION}, as needed by our CI on Linux. " \
|
||||
problem "The glibc version must be #{::OS::LINUX_GLIBC_CI_VERSION}, as needed by our CI on Linux. " \
|
||||
"The glibc formula is for users who have a system glibc with a lower version, " \
|
||||
"which allows them to use our Linux bottles, which were compiled against system glibc on CI."
|
||||
end
|
||||
|
||||
@ -9,7 +9,7 @@ module RuboCop
|
||||
MSG = "Move `OS.linux?` and `OS.mac?` calls to `extend/os`."
|
||||
|
||||
def_node_matcher :os_check?, <<~PATTERN
|
||||
(send (const nil? :OS) {:mac? | :linux?})
|
||||
(send (const {nil? cbase} :OS) {:mac? | :linux?})
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
|
||||
@ -18,4 +18,18 @@ RSpec.describe RuboCop::Cop::Homebrew::MoveToExtendOS do
|
||||
^^^^^^^ Homebrew/MoveToExtendOS: Move `OS.linux?` and `OS.mac?` calls to `extend/os`.
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "registers an offense when using `::OS.linux?`" do
|
||||
expect_offense(<<~RUBY)
|
||||
::OS.linux?
|
||||
^^^^^^^^^^^ Homebrew/MoveToExtendOS: Move `OS.linux?` and `OS.mac?` calls to `extend/os`.
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "registers an offense when using `::OS.mac?`" do
|
||||
expect_offense(<<~RUBY)
|
||||
::OS.mac?
|
||||
^^^^^^^^^ Homebrew/MoveToExtendOS: Move `OS.linux?` and `OS.mac?` calls to `extend/os`.
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user