Remove XQuartz handling

This commit is contained in:
Bo Anderson 2021-10-29 16:02:48 +01:00
parent a044c5f35b
commit 4836ea0ba2
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
11 changed files with 5 additions and 221 deletions

View File

@ -153,24 +153,6 @@ module Cask
end end
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. # Error when there is a cyclic cask dependency.
# #
# @api private # @api private

View File

@ -20,7 +20,7 @@ module Superenv
include SharedEnvExtension include SharedEnvExtension
# @private # @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 } sig { params(base: Superenv).void }
def self.extended(base) def self.extended(base)
@ -168,17 +168,11 @@ module Superenv
).existing ).existing
end end
sig { returns(T::Array[Pathname]) }
def homebrew_extra_aclocal_paths
[]
end
sig { returns(T.nilable(PATH)) } sig { returns(T.nilable(PATH)) }
def determine_aclocal_path def determine_aclocal_path
PATH.new( PATH.new(
keg_only_deps.map { |d| d.opt_share/"aclocal" }, keg_only_deps.map { |d| d.opt_share/"aclocal" },
HOMEBREW_PREFIX/"share/aclocal", HOMEBREW_PREFIX/"share/aclocal",
homebrew_extra_aclocal_paths,
).existing ).existing
end end

View File

@ -268,17 +268,6 @@ module Homebrew
EOS EOS
end 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 def check_filesystem_case_sensitive
dirs_to_check = [ dirs_to_check = [
HOMEBREW_PREFIX, HOMEBREW_PREFIX,

View File

@ -21,34 +21,16 @@ module Superenv
end end
end end
alias x11? x11 undef homebrew_extra_pkg_config_paths,
undef homebrew_extra_paths,
homebrew_extra_pkg_config_paths, homebrew_extra_aclocal_paths,
homebrew_extra_isystem_paths, homebrew_extra_library_paths, homebrew_extra_isystem_paths, homebrew_extra_library_paths,
homebrew_extra_cmake_include_paths, homebrew_extra_cmake_include_paths,
homebrew_extra_cmake_library_paths, homebrew_extra_cmake_library_paths,
homebrew_extra_cmake_frameworks_paths, homebrew_extra_cmake_frameworks_paths,
determine_cccfg determine_cccfg
def homebrew_extra_paths
paths = []
paths << MacOS::XQuartz.bin if x11?
paths
end
# @private # @private
def homebrew_extra_pkg_config_paths def homebrew_extra_pkg_config_paths
paths = \ ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
["/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
end end
# @private # @private
@ -64,7 +46,6 @@ module Superenv
paths = [] paths = []
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? 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 << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
paths paths
end end
@ -75,7 +56,6 @@ module Superenv
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib" paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib"
paths << Formula["llvm"].opt_lib.to_s paths << Formula["llvm"].opt_lib.to_s
end end
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"
paths paths
end end
@ -84,16 +64,12 @@ module Superenv
paths = [] paths = []
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? 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 << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
paths paths
end end
def homebrew_extra_cmake_library_paths def homebrew_extra_cmake_library_paths
paths = [] ["#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"]
paths << MacOS::XQuartz.lib.to_s if x11?
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
paths
end end
def homebrew_extra_cmake_frameworks_paths def homebrew_extra_cmake_frameworks_paths

View File

@ -38,16 +38,11 @@ module SystemConfig
@clt ||= MacOS::CLT.version if MacOS::CLT.installed? @clt ||= MacOS::CLT.version if MacOS::CLT.installed?
end end
def xquartz
@xquartz ||= "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" if MacOS::XQuartz.installed?
end
def dump_verbose_config(f = $stdout) def dump_verbose_config(f = $stdout)
dump_generic_verbose_config(f) dump_generic_verbose_config(f)
f.puts "macOS: #{MacOS.full_version}-#{kernel}" f.puts "macOS: #{MacOS.full_version}-#{kernel}"
f.puts "CLT: #{clt || "N/A"}" f.puts "CLT: #{clt || "N/A"}"
f.puts "Xcode: #{xcode || "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? f.puts "Rosetta 2: #{Hardware::CPU.in_rosetta2?}" if Hardware::CPU.physical_cpu_arm64?
end end
end end

View File

@ -3,7 +3,6 @@
require "os/mac/version" require "os/mac/version"
require "os/mac/xcode" require "os/mac/xcode"
require "os/mac/xquartz"
require "os/mac/sdk" require "os/mac/sdk"
require "os/mac/keg" require "os/mac/keg"

View File

@ -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

View File

@ -55,7 +55,6 @@ module RuboCop
"# if this fails, try separate make/make install steps", "# if this fails, try separate make/make install steps",
"# The URL of the archive", "# The URL of the archive",
"## Naming --", "## Naming --",
"# if your formula requires any X11/XQuartz components",
"# if your formula fails when building in parallel", "# if your formula fails when building in parallel",
"# Remove unrecognized options if warned by configure", "# Remove unrecognized options if warned by configure",
'# system "cmake', '# system "cmake',

View File

@ -409,16 +409,6 @@ describe Cask::DSL, :cask do
end end
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 describe "conflicts_with stanza" do
context "when valid" do context "when valid" do
let(:token) { "with-conflicts-with" } let(:token) { "with-conflicts-with" }

View File

@ -4,7 +4,7 @@
describe Cask::Installer, :cask do describe Cask::Installer, :cask do
describe "install" do describe "install" do
let(:empty_depends_on_stub) { 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 it "downloads and installs a nice fresh Cask" do

View File

@ -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