Merge pull request #3603 from MikeMcQuaid/deprecate-some-requirements
Deprecate more requirements.
This commit is contained in:
commit
c2e1b3cccf
@ -1,6 +1,21 @@
|
|||||||
require "dependency_collector"
|
require "dependency_collector"
|
||||||
|
|
||||||
class DependencyCollector
|
class DependencyCollector
|
||||||
|
alias _parse_string_spec parse_string_spec
|
||||||
|
|
||||||
|
# Define the languages that we can handle as external dependencies.
|
||||||
|
LANGUAGE_MODULES = Set[
|
||||||
|
:lua, :lua51, :perl, :python, :python3, :ruby
|
||||||
|
].freeze
|
||||||
|
|
||||||
|
def parse_string_spec(spec, tags)
|
||||||
|
if (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
|
||||||
|
LanguageModuleRequirement.new(tag, spec, tags[1])
|
||||||
|
else
|
||||||
|
_parse_string_spec(spec, tags)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
alias _parse_symbol_spec parse_symbol_spec
|
alias _parse_symbol_spec parse_symbol_spec
|
||||||
|
|
||||||
def parse_symbol_spec(spec, tags)
|
def parse_symbol_spec(spec, tags)
|
||||||
@ -20,6 +35,18 @@ class DependencyCollector
|
|||||||
tags << :run
|
tags << :run
|
||||||
output_deprecation("libtool", tags)
|
output_deprecation("libtool", tags)
|
||||||
Dependency.new("libtool", tags)
|
Dependency.new("libtool", tags)
|
||||||
|
when :mysql
|
||||||
|
# output_deprecation("mysql", tags)
|
||||||
|
MysqlRequirement.new(tags)
|
||||||
|
when :postgresql
|
||||||
|
# output_deprecation("postgresql", tags)
|
||||||
|
PostgresqlRequirement.new(tags)
|
||||||
|
when :gpg
|
||||||
|
# output_deprecation("gnupg", tags)
|
||||||
|
GPG2Requirement.new(tags)
|
||||||
|
when :rbenv
|
||||||
|
# output_deprecation("rbenv", tags)
|
||||||
|
RbenvRequirement.new(tags)
|
||||||
else
|
else
|
||||||
_parse_symbol_spec(spec, tags)
|
_parse_symbol_spec(spec, tags)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,42 @@
|
|||||||
require "requirements"
|
require "requirements"
|
||||||
|
require "compat/requirements/language_module_requirement"
|
||||||
|
require "compat/requirements/tex_requirement"
|
||||||
|
|
||||||
|
class MysqlRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
default_formula "mysql"
|
||||||
|
satisfy { which "mysql_config" }
|
||||||
|
end
|
||||||
|
|
||||||
|
class PostgresqlRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
default_formula "postgresql"
|
||||||
|
satisfy { which "pg_config" }
|
||||||
|
end
|
||||||
|
|
||||||
|
class RbenvRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
default_formula "rbenv"
|
||||||
|
satisfy { which "rbenv" }
|
||||||
|
end
|
||||||
|
|
||||||
|
class CVSRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
default_formula "cvs"
|
||||||
|
satisfy { which "cvs" }
|
||||||
|
end
|
||||||
|
|
||||||
|
class MercurialRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
default_formula "mercurial"
|
||||||
|
satisfy { which "hg" }
|
||||||
|
end
|
||||||
|
|
||||||
|
class GPG2Requirement < Requirement
|
||||||
|
fatal true
|
||||||
|
default_formula "gnupg"
|
||||||
|
satisfy { which "gpg" }
|
||||||
|
end
|
||||||
|
|
||||||
XcodeDependency = XcodeRequirement
|
XcodeDependency = XcodeRequirement
|
||||||
MysqlDependency = MysqlRequirement
|
MysqlDependency = MysqlRequirement
|
||||||
|
|||||||
20
Library/Homebrew/compat/requirements/tex_requirement.rb
Normal file
20
Library/Homebrew/compat/requirements/tex_requirement.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
require "requirement"
|
||||||
|
|
||||||
|
class TeXRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
cask "mactex"
|
||||||
|
download "https://www.tug.org/mactex/"
|
||||||
|
|
||||||
|
satisfy { which("tex") || which("latex") }
|
||||||
|
|
||||||
|
def message
|
||||||
|
s = <<~EOS
|
||||||
|
A LaTeX distribution is required for Homebrew to install this formula.
|
||||||
|
|
||||||
|
Make sure that "/usr/texbin", or the location you installed it to, is in
|
||||||
|
your PATH before proceeding.
|
||||||
|
EOS
|
||||||
|
s += super
|
||||||
|
s
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -19,11 +19,6 @@ require "extend/cachable"
|
|||||||
class DependencyCollector
|
class DependencyCollector
|
||||||
extend Cachable
|
extend Cachable
|
||||||
|
|
||||||
# Define the languages that we can handle as external dependencies.
|
|
||||||
LANGUAGE_MODULES = Set[
|
|
||||||
:lua, :lua51, :perl, :python, :python3, :ruby
|
|
||||||
].freeze
|
|
||||||
|
|
||||||
attr_reader :deps, :requirements
|
attr_reader :deps, :requirements
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@ -58,16 +53,28 @@ class DependencyCollector
|
|||||||
parse_spec(spec, Array(tags))
|
parse_spec(spec, Array(tags))
|
||||||
end
|
end
|
||||||
|
|
||||||
def ant_dep(tags)
|
def ant_dep_if_needed(tags)
|
||||||
Dependency.new("ant", tags)
|
Dependency.new("ant", tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def xz_dep(tags)
|
def cvs_dep_if_needed(tags)
|
||||||
|
Dependency.new("cvs", tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def xz_dep_if_needed(tags)
|
||||||
Dependency.new("xz", tags)
|
Dependency.new("xz", tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expat_dep_if_needed(tags)
|
||||||
|
Dependency.new("expat", tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def ld64_dep_if_needed(*)
|
||||||
|
LD64Dependency.new
|
||||||
|
end
|
||||||
|
|
||||||
def self.tar_needs_xz_dependency?
|
def self.tar_needs_xz_dependency?
|
||||||
!new.xz_dep([]).nil?
|
!new.xz_dep_if_needed([]).nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -94,8 +101,6 @@ class DependencyCollector
|
|||||||
TapDependency.new(spec, tags)
|
TapDependency.new(spec, tags)
|
||||||
elsif tags.empty?
|
elsif tags.empty?
|
||||||
Dependency.new(spec, tags)
|
Dependency.new(spec, tags)
|
||||||
elsif (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
|
|
||||||
LanguageModuleRequirement.new(tag, spec, tags[1])
|
|
||||||
else
|
else
|
||||||
Dependency.new(spec, tags)
|
Dependency.new(spec, tags)
|
||||||
end
|
end
|
||||||
@ -107,30 +112,23 @@ class DependencyCollector
|
|||||||
when :xcode then XcodeRequirement.new(tags)
|
when :xcode then XcodeRequirement.new(tags)
|
||||||
when :linux then LinuxRequirement.new(tags)
|
when :linux then LinuxRequirement.new(tags)
|
||||||
when :macos then MacOSRequirement.new(tags)
|
when :macos then MacOSRequirement.new(tags)
|
||||||
when :mysql then MysqlRequirement.new(tags)
|
|
||||||
when :postgresql then PostgresqlRequirement.new(tags)
|
|
||||||
when :gpg then GPG2Requirement.new(tags)
|
|
||||||
when :fortran then FortranRequirement.new(tags)
|
when :fortran then FortranRequirement.new(tags)
|
||||||
when :mpi then MPIRequirement.new(*tags)
|
when :mpi then MPIRequirement.new(*tags)
|
||||||
when :tex then TeXRequirement.new(tags)
|
when :tex then TeXRequirement.new(tags)
|
||||||
when :arch then ArchRequirement.new(tags)
|
when :arch then ArchRequirement.new(tags)
|
||||||
when :hg then MercurialRequirement.new(tags)
|
when :hg then MercurialRequirement.new(tags)
|
||||||
when :python then PythonRequirement.new(tags)
|
when :python then PythonRequirement.new(tags)
|
||||||
|
when :python2 then PythonRequirement.new(tags)
|
||||||
when :python3 then Python3Requirement.new(tags)
|
when :python3 then Python3Requirement.new(tags)
|
||||||
when :java then JavaRequirement.new(tags)
|
when :java then JavaRequirement.new(tags)
|
||||||
when :rbenv then RbenvRequirement.new(tags)
|
|
||||||
when :ruby then RubyRequirement.new(tags)
|
when :ruby then RubyRequirement.new(tags)
|
||||||
when :osxfuse then OsxfuseRequirement.new(tags)
|
when :osxfuse then OsxfuseRequirement.new(tags)
|
||||||
when :perl then PerlRequirement.new(tags)
|
when :perl then PerlRequirement.new(tags)
|
||||||
when :tuntap then TuntapRequirement.new(tags)
|
when :tuntap then TuntapRequirement.new(tags)
|
||||||
when :ant then ant_dep(tags)
|
when :ant then ant_dep_if_needed(tags)
|
||||||
when :emacs then EmacsRequirement.new(tags)
|
when :emacs then EmacsRequirement.new(tags)
|
||||||
# Tiger's ld is too old to properly link some software
|
when :ld64 then ld64_dep_if_needed(tags)
|
||||||
when :ld64 then LD64Dependency.new if MacOS.version < :leopard
|
when :expat then expat_dep_if_needed(tags)
|
||||||
# Tiger doesn't ship expat in /usr/lib
|
|
||||||
when :expat then Dependency.new("expat", tag) if MacOS.version < :leopard
|
|
||||||
when :python2
|
|
||||||
PythonRequirement.new(tags)
|
|
||||||
else
|
else
|
||||||
raise ArgumentError, "Unsupported special dependency #{spec.inspect}"
|
raise ArgumentError, "Unsupported special dependency #{spec.inspect}"
|
||||||
end
|
end
|
||||||
@ -152,16 +150,16 @@ class DependencyCollector
|
|||||||
parse_url_spec(spec.url, tags)
|
parse_url_spec(spec.url, tags)
|
||||||
elsif strategy <= GitDownloadStrategy
|
elsif strategy <= GitDownloadStrategy
|
||||||
GitRequirement.new(tags)
|
GitRequirement.new(tags)
|
||||||
|
elsif strategy <= SubversionDownloadStrategy
|
||||||
|
SubversionRequirement.new(tags)
|
||||||
elsif strategy <= MercurialDownloadStrategy
|
elsif strategy <= MercurialDownloadStrategy
|
||||||
MercurialRequirement.new(tags)
|
Dependency.new("hg", tags)
|
||||||
elsif strategy <= FossilDownloadStrategy
|
elsif strategy <= FossilDownloadStrategy
|
||||||
Dependency.new("fossil", tags)
|
Dependency.new("fossil", tags)
|
||||||
elsif strategy <= BazaarDownloadStrategy
|
elsif strategy <= BazaarDownloadStrategy
|
||||||
Dependency.new("bazaar", tags)
|
Dependency.new("bazaar", tags)
|
||||||
elsif strategy <= CVSDownloadStrategy
|
elsif strategy <= CVSDownloadStrategy
|
||||||
CVSRequirement.new(tags)
|
cvs_dep_if_needed(tags)
|
||||||
elsif strategy <= SubversionDownloadStrategy
|
|
||||||
SubversionRequirement.new(tags)
|
|
||||||
elsif strategy < AbstractDownloadStrategy
|
elsif strategy < AbstractDownloadStrategy
|
||||||
# allow unknown strategies to pass through
|
# allow unknown strategies to pass through
|
||||||
else
|
else
|
||||||
@ -172,7 +170,7 @@ class DependencyCollector
|
|||||||
|
|
||||||
def parse_url_spec(url, tags)
|
def parse_url_spec(url, tags)
|
||||||
case File.extname(url)
|
case File.extname(url)
|
||||||
when ".xz" then xz_dep(tags)
|
when ".xz" then xz_dep_if_needed(tags)
|
||||||
when ".lha", ".lzh" then Dependency.new("lha", tags)
|
when ".lha", ".lzh" then Dependency.new("lha", tags)
|
||||||
when ".lz" then Dependency.new("lzip", tags)
|
when ".lz" then Dependency.new("lzip", tags)
|
||||||
when ".rar" then Dependency.new("unrar", tags)
|
when ".rar" then Dependency.new("unrar", tags)
|
||||||
|
|||||||
@ -1,11 +1,28 @@
|
|||||||
class DependencyCollector
|
class DependencyCollector
|
||||||
def ant_dep(tags)
|
def ant_dep_if_needed(tags)
|
||||||
return if MacOS.version < :mavericks
|
return if MacOS.version < :mavericks
|
||||||
Dependency.new("ant", tags)
|
Dependency.new("ant", tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def xz_dep(tags)
|
def cvs_dep_if_needed(tags)
|
||||||
|
return if MacOS.version < :lion
|
||||||
|
Dependency.new("cvs", tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def xz_dep_if_needed(tags)
|
||||||
return if MacOS.version >= :mavericks
|
return if MacOS.version >= :mavericks
|
||||||
Dependency.new("xz", tags)
|
Dependency.new("xz", tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expat_dep_if_needed(tags)
|
||||||
|
# Tiger doesn't ship expat in /usr/lib
|
||||||
|
return if MacOS.version > :tiger
|
||||||
|
Dependency.new("expat", tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def ld64_dep_if_needed(*)
|
||||||
|
# Tiger's ld is too old to properly link some software
|
||||||
|
return if MacOS.version > :tiger
|
||||||
|
LD64Dependency.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,29 +1,17 @@
|
|||||||
require "utils"
|
require "utils"
|
||||||
|
|
||||||
class Gpg
|
class Gpg
|
||||||
def self.find_gpg(executable)
|
module_function
|
||||||
which_all(executable).detect do |gpg|
|
|
||||||
gpg_short_version = Utils.popen_read(gpg, "--version")[/\d\.\d/, 0]
|
def executable
|
||||||
next unless gpg_short_version
|
which "gpg"
|
||||||
gpg_version = Version.create(gpg_short_version.to_s)
|
|
||||||
@version = gpg_version
|
|
||||||
gpg_version >= Version.create("2.0")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.executable
|
def available?
|
||||||
find_gpg("gpg") || find_gpg("gpg2")
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.available?
|
|
||||||
File.executable?(executable.to_s)
|
File.executable?(executable.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.version
|
def create_test_key(path)
|
||||||
@version if available?
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_test_key(path)
|
|
||||||
odie "No GPG present to test against!" unless available?
|
odie "No GPG present to test against!" unless available?
|
||||||
|
|
||||||
(path/"batch.gpg").write <<~EOS
|
(path/"batch.gpg").write <<~EOS
|
||||||
@ -40,8 +28,9 @@ class Gpg
|
|||||||
system executable, "--batch", "--gen-key", "batch.gpg"
|
system executable, "--batch", "--gen-key", "batch.gpg"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.cleanup_test_processes!
|
def cleanup_test_processes!
|
||||||
odie "No GPG present to test against!" unless available?
|
odie "No GPG present to test against!" unless available?
|
||||||
|
|
||||||
gpgconf = Pathname.new(executable).parent/"gpgconf"
|
gpgconf = Pathname.new(executable).parent/"gpgconf"
|
||||||
|
|
||||||
system gpgconf, "--kill", "gpg-agent"
|
system gpgconf, "--kill", "gpg-agent"
|
||||||
@ -49,7 +38,7 @@ class Gpg
|
|||||||
"gpg-agent"
|
"gpg-agent"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.test(path)
|
def test(path)
|
||||||
create_test_key(path)
|
create_test_key(path)
|
||||||
begin
|
begin
|
||||||
yield
|
yield
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
require "requirement"
|
require "requirement"
|
||||||
require "requirements/fortran_requirement"
|
require "requirements/fortran_requirement"
|
||||||
require "requirements/gpg2_requirement"
|
|
||||||
require "requirements/language_module_requirement"
|
|
||||||
require "requirements/linux_requirement"
|
require "requirements/linux_requirement"
|
||||||
require "requirements/macos_requirement"
|
require "requirements/macos_requirement"
|
||||||
require "requirements/maximum_macos_requirement"
|
require "requirements/maximum_macos_requirement"
|
||||||
@ -15,116 +13,8 @@ require "requirements/tuntap_requirement"
|
|||||||
require "requirements/unsigned_kext_requirement"
|
require "requirements/unsigned_kext_requirement"
|
||||||
require "requirements/x11_requirement"
|
require "requirements/x11_requirement"
|
||||||
require "requirements/emacs_requirement"
|
require "requirements/emacs_requirement"
|
||||||
|
require "requirements/arch_requirement"
|
||||||
class XcodeRequirement < Requirement
|
require "requirements/xcode_requirement"
|
||||||
fatal true
|
|
||||||
|
|
||||||
satisfy(build_env: false) { xcode_installed_version }
|
|
||||||
|
|
||||||
def initialize(tags)
|
|
||||||
@version = tags.find { |tag| tags.delete(tag) if tag =~ /(\d\.)+\d/ }
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
def xcode_installed_version
|
|
||||||
return false unless MacOS::Xcode.installed?
|
|
||||||
return true unless @version
|
|
||||||
MacOS::Xcode.version >= @version
|
|
||||||
end
|
|
||||||
|
|
||||||
def message
|
|
||||||
version = " #{@version}" if @version
|
|
||||||
message = <<~EOS
|
|
||||||
A full installation of Xcode.app#{version} is required to compile this software.
|
|
||||||
Installing just the Command Line Tools is not sufficient.
|
|
||||||
EOS
|
|
||||||
if MacOS.version >= :lion
|
|
||||||
message + <<~EOS
|
|
||||||
Xcode can be installed from the App Store.
|
|
||||||
EOS
|
|
||||||
else
|
|
||||||
message + <<~EOS
|
|
||||||
Xcode can be installed from #{Formatter.url("https://developer.apple.com/download/more/")}.
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def inspect
|
|
||||||
"#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class MysqlRequirement < Requirement
|
|
||||||
fatal true
|
|
||||||
default_formula "mysql"
|
|
||||||
|
|
||||||
satisfy { which "mysql_config" }
|
|
||||||
end
|
|
||||||
|
|
||||||
class PostgresqlRequirement < Requirement
|
|
||||||
fatal true
|
|
||||||
default_formula "postgresql"
|
|
||||||
|
|
||||||
satisfy { which "pg_config" }
|
|
||||||
end
|
|
||||||
|
|
||||||
class RbenvRequirement < Requirement
|
|
||||||
fatal true
|
|
||||||
default_formula "rbenv"
|
|
||||||
|
|
||||||
satisfy { which "rbenv" }
|
|
||||||
end
|
|
||||||
|
|
||||||
class TeXRequirement < Requirement
|
|
||||||
fatal true
|
|
||||||
cask "mactex"
|
|
||||||
download "https://www.tug.org/mactex/"
|
|
||||||
|
|
||||||
satisfy { which("tex") || which("latex") }
|
|
||||||
|
|
||||||
def message
|
|
||||||
s = <<~EOS
|
|
||||||
A LaTeX distribution is required for Homebrew to install this formula.
|
|
||||||
|
|
||||||
Make sure that "/usr/texbin", or the location you installed it to, is in
|
|
||||||
your PATH before proceeding.
|
|
||||||
EOS
|
|
||||||
s += super
|
|
||||||
s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class ArchRequirement < Requirement
|
|
||||||
fatal true
|
|
||||||
|
|
||||||
def initialize(arch)
|
|
||||||
@arch = arch.pop
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
satisfy(build_env: false) do
|
|
||||||
case @arch
|
|
||||||
when :x86_64 then MacOS.prefer_64_bit?
|
|
||||||
when :intel, :ppc then Hardware::CPU.type == @arch
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def message
|
|
||||||
"This formula requires an #{@arch} architecture."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class CVSRequirement < Requirement
|
|
||||||
fatal true
|
|
||||||
default_formula "cvs"
|
|
||||||
satisfy { which "cvs" }
|
|
||||||
end
|
|
||||||
|
|
||||||
class MercurialRequirement < Requirement
|
|
||||||
fatal true
|
|
||||||
default_formula "mercurial"
|
|
||||||
satisfy { which("hg") }
|
|
||||||
end
|
|
||||||
|
|
||||||
class GitRequirement < Requirement
|
class GitRequirement < Requirement
|
||||||
fatal true
|
fatal true
|
||||||
|
|||||||
21
Library/Homebrew/requirements/arch_requirement.rb
Normal file
21
Library/Homebrew/requirements/arch_requirement.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
require "requirement"
|
||||||
|
|
||||||
|
class ArchRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
|
||||||
|
def initialize(arch)
|
||||||
|
@arch = arch.pop
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
satisfy(build_env: false) do
|
||||||
|
case @arch
|
||||||
|
when :x86_64 then MacOS.prefer_64_bit?
|
||||||
|
when :intel, :ppc then Hardware::CPU.type == @arch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def message
|
||||||
|
"This formula requires an #{@arch} architecture."
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -1,12 +0,0 @@
|
|||||||
require "requirement"
|
|
||||||
require "gpg"
|
|
||||||
|
|
||||||
class GPG2Requirement < Requirement
|
|
||||||
fatal true
|
|
||||||
default_formula "gnupg"
|
|
||||||
|
|
||||||
# GPGTools installs GnuPG 2.0.x as a `gpg` symlink pointing
|
|
||||||
# to `gpg2`. Our `gnupg` installs only a non-symlink `gpg`.
|
|
||||||
# The aim is to retain support for any version above 2.0.
|
|
||||||
satisfy(build_env: false) { Gpg.available? }
|
|
||||||
end
|
|
||||||
39
Library/Homebrew/requirements/xcode_requirement.rb
Normal file
39
Library/Homebrew/requirements/xcode_requirement.rb
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
require "requirement"
|
||||||
|
|
||||||
|
class XcodeRequirement < Requirement
|
||||||
|
fatal true
|
||||||
|
|
||||||
|
satisfy(build_env: false) { xcode_installed_version }
|
||||||
|
|
||||||
|
def initialize(tags)
|
||||||
|
@version = tags.find { |tag| tags.delete(tag) if tag =~ /(\d\.)+\d/ }
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def xcode_installed_version
|
||||||
|
return false unless MacOS::Xcode.installed?
|
||||||
|
return true unless @version
|
||||||
|
MacOS::Xcode.version >= @version
|
||||||
|
end
|
||||||
|
|
||||||
|
def message
|
||||||
|
version = " #{@version}" if @version
|
||||||
|
message = <<~EOS
|
||||||
|
A full installation of Xcode.app#{version} is required to compile this software.
|
||||||
|
Installing just the Command Line Tools is not sufficient.
|
||||||
|
EOS
|
||||||
|
if MacOS.version >= :lion
|
||||||
|
message + <<~EOS
|
||||||
|
Xcode can be installed from the App Store.
|
||||||
|
EOS
|
||||||
|
else
|
||||||
|
message + <<~EOS
|
||||||
|
Xcode can be installed from #{Formatter.url("https://developer.apple.com/download/more/")}.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
"#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>"
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -6,12 +6,16 @@ module RuboCop
|
|||||||
# This cop checks for various miscellaneous Homebrew coding styles
|
# This cop checks for various miscellaneous Homebrew coding styles
|
||||||
class Lines < FormulaCop
|
class Lines < FormulaCop
|
||||||
def audit_formula(_node, _class_node, _parent_class_node, _body_node)
|
def audit_formula(_node, _class_node, _parent_class_node, _body_node)
|
||||||
[:automake, :autoconf, :libtool].each do |dependency|
|
[:automake, :autoconf, :libtool, :mysql, :postgresql, :rbenv].each do |dependency|
|
||||||
next unless depends_on?(dependency)
|
next unless depends_on?(dependency)
|
||||||
problem ":#{dependency} is deprecated. Usage should be \"#{dependency}\"."
|
problem ":#{dependency} is deprecated. Usage should be \"#{dependency}\"."
|
||||||
end
|
end
|
||||||
|
|
||||||
problem ':apr is deprecated. Usage should be "apr-util".' if depends_on?(:apr)
|
{ apr: "apr-util", gpg: "gnupg" }.each do |requirement, dependency|
|
||||||
|
next unless depends_on?(requirement)
|
||||||
|
problem ":#{requirement} is deprecated. Usage should be \"#{dependency}\"."
|
||||||
|
end
|
||||||
|
|
||||||
problem ":tex is deprecated." if depends_on?(:tex)
|
problem ":tex is deprecated." if depends_on?(:tex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -87,7 +87,7 @@ describe DependencyCollector do
|
|||||||
it "creates a resource dependency from a CVS URL" do
|
it "creates a resource dependency from a CVS URL" do
|
||||||
resource = Resource.new
|
resource = Resource.new
|
||||||
resource.url(":pserver:anonymous:@example.com:/cvsroot/foo/bar", using: :cvs)
|
resource.url(":pserver:anonymous:@example.com:/cvsroot/foo/bar", using: :cvs)
|
||||||
expect(subject.add(resource)).to be_an_instance_of(CVSRequirement)
|
expect(subject.add(resource)).to eq(Dependency.new("cvs", [:build]))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a resource dependency from a Subversion URL" do
|
it "creates a resource dependency from a Subversion URL" do
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
require "requirements/gpg2_requirement"
|
|
||||||
require "fileutils"
|
|
||||||
|
|
||||||
describe GPG2Requirement do
|
|
||||||
let(:dir) { mktmpdir }
|
|
||||||
|
|
||||||
describe "#satisfied?" do
|
|
||||||
it "returns true if GPG2 is installed" do
|
|
||||||
ENV["PATH"] = dir/"bin"
|
|
||||||
(dir/"bin/gpg").write <<~EOS
|
|
||||||
#!/bin/bash
|
|
||||||
echo 2.1.20
|
|
||||||
EOS
|
|
||||||
FileUtils.chmod 0755, dir/"bin/gpg"
|
|
||||||
|
|
||||||
expect(subject).to be_satisfied
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
require "requirements/language_module_requirement"
|
require "compat/requirements/language_module_requirement"
|
||||||
|
|
||||||
describe LanguageModuleRequirement do
|
describe LanguageModuleRequirement, :needs_compat do
|
||||||
specify "unique dependencies are not equal" do
|
specify "unique dependencies are not equal" do
|
||||||
x = described_class.new(:node, "less")
|
x = described_class.new(:node, "less")
|
||||||
y = described_class.new(:node, "coffee-script")
|
y = described_class.new(:node, "coffee-script")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user