mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Deprecate more requirements.
These are ones that were either already deprecated due to audit rules or are just a simple `which` with a `default_formula` so should just be a dependency.
This commit is contained in:
parent
5b178c2892
commit
38ce994007
@ -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
|
||||||
@ -62,6 +57,10 @@ class DependencyCollector
|
|||||||
Dependency.new("ant", tags)
|
Dependency.new("ant", tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cvs_dep_if_needed(tags)
|
||||||
|
Dependency.new("cvs", tags)
|
||||||
|
end
|
||||||
|
|
||||||
def xz_dep_if_needed(tags)
|
def xz_dep_if_needed(tags)
|
||||||
Dependency.new("xz", tags)
|
Dependency.new("xz", tags)
|
||||||
end
|
end
|
||||||
@ -102,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
|
||||||
@ -115,9 +112,6 @@ 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)
|
||||||
@ -156,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
|
||||||
|
@ -4,6 +4,11 @@ class DependencyCollector
|
|||||||
Dependency.new("ant", tags)
|
Dependency.new("ant", tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cvs_dep_if_needed(tags)
|
||||||
|
return if MacOS.version < :lion
|
||||||
|
Dependency.new("cvs", tags)
|
||||||
|
end
|
||||||
|
|
||||||
def xz_dep_if_needed(tags)
|
def xz_dep_if_needed(tags)
|
||||||
return if MacOS.version >= :mavericks
|
return if MacOS.version >= :mavericks
|
||||||
Dependency.new("xz", tags)
|
Dependency.new("xz", tags)
|
||||||
|
@ -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
|
@ -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