From 4836ea0ba2119619697af87edf5fdb2280e90238 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Fri, 29 Oct 2021 16:02:48 +0100 Subject: [PATCH] Remove XQuartz handling --- Library/Homebrew/cask/exceptions.rb | 18 --- Library/Homebrew/extend/ENV/super.rb | 8 +- Library/Homebrew/extend/os/mac/diagnostic.rb | 11 -- .../extend/os/mac/extend/ENV/super.rb | 30 +--- .../Homebrew/extend/os/mac/system_config.rb | 5 - Library/Homebrew/os/mac.rb | 1 - Library/Homebrew/os/mac/xquartz.rb | 129 ------------------ Library/Homebrew/rubocops/lines.rb | 1 - Library/Homebrew/test/cask/dsl_spec.rb | 10 -- Library/Homebrew/test/cask/installer_spec.rb | 2 +- .../invalid/invalid-depends-on-x11-value.rb | 11 -- 11 files changed, 5 insertions(+), 221 deletions(-) delete mode 100644 Library/Homebrew/os/mac/xquartz.rb delete mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb diff --git a/Library/Homebrew/cask/exceptions.rb b/Library/Homebrew/cask/exceptions.rb index 8a2214e3c4..31916b42dc 100644 --- a/Library/Homebrew/cask/exceptions.rb +++ b/Library/Homebrew/cask/exceptions.rb @@ -153,24 +153,6 @@ module Cask end end - # Error when a cask depends on X11. - # - # @api private - class CaskX11DependencyError < AbstractCaskErrorWithToken - extend T::Sig - - sig { returns(String) } - def to_s - <<~EOS - Cask '#{token}' requires XQuartz/X11, which can be installed using Homebrew Cask by running: - #{Formatter.identifier("brew install --cask xquartz")} - - or manually, by downloading the package from: - #{Formatter.url("https://www.xquartz.org/")} - EOS - end - end - # Error when there is a cyclic cask dependency. # # @api private diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 40ef42a4b4..73f7f9c9c5 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -20,7 +20,7 @@ module Superenv include SharedEnvExtension # @private - attr_accessor :keg_only_deps, :deps, :run_time_deps, :x11 + attr_accessor :keg_only_deps, :deps, :run_time_deps sig { params(base: Superenv).void } def self.extended(base) @@ -168,17 +168,11 @@ module Superenv ).existing end - sig { returns(T::Array[Pathname]) } - def homebrew_extra_aclocal_paths - [] - end - sig { returns(T.nilable(PATH)) } def determine_aclocal_path PATH.new( keg_only_deps.map { |d| d.opt_share/"aclocal" }, HOMEBREW_PREFIX/"share/aclocal", - homebrew_extra_aclocal_paths, ).existing end diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 5c7c69e4d7..c34addae8c 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -268,17 +268,6 @@ module Homebrew EOS end - def check_xquartz_up_to_date - return unless MacOS::XQuartz.outdated? - - <<~EOS - Your XQuartz (#{MacOS::XQuartz.version}) is outdated. - Please install XQuartz #{MacOS::XQuartz.latest_version} (or delete the current version). - XQuartz can be updated using Homebrew Cask by running: - brew reinstall xquartz - EOS - end - def check_filesystem_case_sensitive dirs_to_check = [ HOMEBREW_PREFIX, diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb index e1f64d1d41..f4920216b7 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb @@ -21,34 +21,16 @@ module Superenv end end - alias x11? x11 - - undef homebrew_extra_paths, - homebrew_extra_pkg_config_paths, homebrew_extra_aclocal_paths, + undef homebrew_extra_pkg_config_paths, homebrew_extra_isystem_paths, homebrew_extra_library_paths, homebrew_extra_cmake_include_paths, homebrew_extra_cmake_library_paths, homebrew_extra_cmake_frameworks_paths, determine_cccfg - def homebrew_extra_paths - paths = [] - paths << MacOS::XQuartz.bin if x11? - paths - end - # @private def homebrew_extra_pkg_config_paths - paths = \ - ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] - paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11? - paths - end - - def homebrew_extra_aclocal_paths - paths = [] - paths << "#{MacOS::XQuartz.share}/aclocal" if x11? - paths + ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] end # @private @@ -64,7 +46,6 @@ module Superenv paths = [] paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? - paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" paths end @@ -75,7 +56,6 @@ module Superenv paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib" paths << Formula["llvm"].opt_lib.to_s end - paths << MacOS::XQuartz.lib.to_s if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" paths end @@ -84,16 +64,12 @@ module Superenv paths = [] paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? - paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" paths end def homebrew_extra_cmake_library_paths - paths = [] - paths << MacOS::XQuartz.lib.to_s if x11? - paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" - paths + ["#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"] end def homebrew_extra_cmake_frameworks_paths diff --git a/Library/Homebrew/extend/os/mac/system_config.rb b/Library/Homebrew/extend/os/mac/system_config.rb index 1e22d916ea..552a58266e 100644 --- a/Library/Homebrew/extend/os/mac/system_config.rb +++ b/Library/Homebrew/extend/os/mac/system_config.rb @@ -38,16 +38,11 @@ module SystemConfig @clt ||= MacOS::CLT.version if MacOS::CLT.installed? end - def xquartz - @xquartz ||= "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" if MacOS::XQuartz.installed? - end - def dump_verbose_config(f = $stdout) dump_generic_verbose_config(f) f.puts "macOS: #{MacOS.full_version}-#{kernel}" f.puts "CLT: #{clt || "N/A"}" f.puts "Xcode: #{xcode || "N/A"}" - f.puts "XQuartz: #{xquartz}" if xquartz f.puts "Rosetta 2: #{Hardware::CPU.in_rosetta2?}" if Hardware::CPU.physical_cpu_arm64? end end diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index d6d11f6974..116d69ed8e 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -3,7 +3,6 @@ require "os/mac/version" require "os/mac/xcode" -require "os/mac/xquartz" require "os/mac/sdk" require "os/mac/keg" diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb deleted file mode 100644 index 794022a6a1..0000000000 --- a/Library/Homebrew/os/mac/xquartz.rb +++ /dev/null @@ -1,129 +0,0 @@ -# typed: true -# frozen_string_literal: true - -module OS - module Mac - # Helper module for querying XQuartz information. - # - # @api private - module XQuartz - extend T::Sig - - module_function - - DEFAULT_BUNDLE_PATH = Pathname("/Applications/Utilities/XQuartz.app").freeze - NEW_BUNDLE_PKG_ID = "org.xquartz.X11" - FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11" - FORGE_PKG_ID = "org.macosforge.xquartz.pkg" - - PKGINFO_VERSION_MAP = { - "2.6.34" => "2.6.3", - "2.7.4" => "2.7.0", - "2.7.14" => "2.7.1", - "2.7.28" => "2.7.2", - "2.7.32" => "2.7.3", - "2.7.43" => "2.7.4", - "2.7.50" => "2.7.5_rc1", - "2.7.51" => "2.7.5_rc2", - "2.7.52" => "2.7.5_rc3", - "2.7.53" => "2.7.5_rc4", - "2.7.54" => "2.7.5", - "2.7.61" => "2.7.6", - "2.7.73" => "2.7.7", - "2.7.86" => "2.7.8", - "2.7.94" => "2.7.9", - "2.7.108" => "2.7.10", - "2.7.112" => "2.7.11", - }.freeze - - # This returns the version number of XQuartz, not of the upstream X.org. - # The X11.app distributed by Apple is also XQuartz, and therefore covered - # by this method. - def version - if @version ||= detect_version - ::Version.new @version - else - ::Version::NULL - end - end - - def detect_version - if (path = bundle_path) && path.exist? && (version = version_from_mdls(path)) - version - else - version_from_pkgutil - end - end - - sig { returns(String) } - def minimum_version - # Update this a little later than latest_version to give people - # time to upgrade. - "2.7.11" - end - - # @see https://www.xquartz.org/releases/index.html - sig { returns(String) } - def latest_version - "2.7.11" - end - - def bundle_path - # Use the default location if it exists. - return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist? - - # Ask Spotlight where XQuartz is. If the user didn't install XQuartz - # in the conventional place, this is our only option. - MacOS.app_with_bundle_id(NEW_BUNDLE_PKG_ID, FORGE_BUNDLE_ID) - end - - def version_from_mdls(path) - version = Utils.popen_read( - "/usr/bin/mdls", "-raw", "-nullMarker", "", "-name", "kMDItemVersion", path.to_s - ).strip - version unless version.empty? - end - - # Upstream XQuartz *does* have a pkg-info entry, so if we can't get it - # from mdls, we can try pkgutil. This is very slow. - def version_from_pkgutil - [NEW_BUNDLE_PKG_ID, FORGE_PKG_ID].each do |id| - str = MacOS.pkgutil_info(id)[/version: (\d\.\d\.\d+)$/, 1] - return PKGINFO_VERSION_MAP.fetch(str, str) if str - end - - nil - end - - def prefix - @prefix ||= Pathname.new("/opt/X11") if Pathname.new("/opt/X11/lib/libpng.dylib").exist? - end - - def installed? - !version.null? && !prefix.nil? - end - - def outdated? - return false unless installed? - - version < latest_version - end - - def bin - prefix/"bin" - end - - def include - prefix/"include" - end - - def lib - prefix/"lib" - end - - def share - prefix/"share" - end - end - end -end diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index a59eaa094b..08b52b056b 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -55,7 +55,6 @@ module RuboCop "# if this fails, try separate make/make install steps", "# The URL of the archive", "## Naming --", - "# if your formula requires any X11/XQuartz components", "# if your formula fails when building in parallel", "# Remove unrecognized options if warned by configure", '# system "cmake', diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index ad93c252c3..97e6caf5c0 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -409,16 +409,6 @@ describe Cask::DSL, :cask do end end - describe "depends_on x11" do - context "with invalid depends_on x11 value" do - let(:token) { "invalid/invalid-depends-on-x11-value" } - - it "refuses to load" do - expect { cask }.to raise_error(Cask::CaskInvalidError) - end - end - end - describe "conflicts_with stanza" do context "when valid" do let(:token) { "with-conflicts-with" } diff --git a/Library/Homebrew/test/cask/installer_spec.rb b/Library/Homebrew/test/cask/installer_spec.rb index 6a9bbf9e14..3b9a3acfc1 100644 --- a/Library/Homebrew/test/cask/installer_spec.rb +++ b/Library/Homebrew/test/cask/installer_spec.rb @@ -4,7 +4,7 @@ describe Cask::Installer, :cask do describe "install" do let(:empty_depends_on_stub) { - double(formula: [], cask: [], macos: nil, arch: nil, x11: nil) + double(formula: [], cask: [], macos: nil, arch: nil) } it "downloads and installs a nice fresh Cask" do diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb deleted file mode 100644 index 780b00135d..0000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb +++ /dev/null @@ -1,11 +0,0 @@ -cask "invalid-depends-on-x11-value" do - version "1.2.3" - sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage "https://brew.sh/invalid-depends-on-x11-value" - - depends_on x11: :no_such_value - - app "Caffeine.app" -end