diff options
| author | Mike McQuaid | 2017-12-23 16:38:06 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2017-12-23 16:53:25 +0000 |
| commit | 38ce9940071351f7a41ad3b48a8dba021d0acbdf (patch) | |
| tree | 5c2ec372c28ac0d730f99bbdc8d7d5c377c57377 /Library/Homebrew/compat | |
| parent | 5b178c2892576c9f26fc54b4f07b45db48c387e9 (diff) | |
| download | brew-38ce9940071351f7a41ad3b48a8dba021d0acbdf.tar.bz2 | |
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.
Diffstat (limited to 'Library/Homebrew/compat')
4 files changed, 148 insertions, 0 deletions
diff --git a/Library/Homebrew/compat/dependency_collector.rb b/Library/Homebrew/compat/dependency_collector.rb index fbcf1c2a0..2e97d9d7f 100644 --- a/Library/Homebrew/compat/dependency_collector.rb +++ b/Library/Homebrew/compat/dependency_collector.rb @@ -1,6 +1,21 @@ require "dependency_collector" 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 def parse_symbol_spec(spec, tags) @@ -20,6 +35,18 @@ class DependencyCollector tags << :run output_deprecation("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 _parse_symbol_spec(spec, tags) end diff --git a/Library/Homebrew/compat/requirements.rb b/Library/Homebrew/compat/requirements.rb index 3886cd7c7..da6d867b3 100644 --- a/Library/Homebrew/compat/requirements.rb +++ b/Library/Homebrew/compat/requirements.rb @@ -1,4 +1,42 @@ 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 MysqlDependency = MysqlRequirement diff --git a/Library/Homebrew/compat/requirements/language_module_requirement.rb b/Library/Homebrew/compat/requirements/language_module_requirement.rb new file mode 100644 index 000000000..5ddce7a66 --- /dev/null +++ b/Library/Homebrew/compat/requirements/language_module_requirement.rb @@ -0,0 +1,63 @@ +require "requirement" + +class LanguageModuleRequirement < Requirement + fatal true + + def initialize(language, module_name, import_name = nil) + @language = language + @module_name = module_name + @import_name = import_name || module_name + super([language, module_name, import_name]) + end + + satisfy(build_env: false) { quiet_system(*the_test) } + + def message + s = <<~EOS + Unsatisfied dependency: #{@module_name} + Homebrew does not provide special #{@language.to_s.capitalize} dependencies; install with: + `#{command_line} #{@module_name}` + EOS + + unless [:python, :perl, :ruby].include? @language + s += <<~EOS + You may need to: `brew install #{@language}` + + EOS + end + + s + end + + def the_test + case @language + when :lua + ["/usr/bin/env", "luarocks-5.2", "show", @import_name.to_s] + when :lua51 + ["/usr/bin/env", "luarocks-5.1", "show", @import_name.to_s] + when :perl + ["/usr/bin/env", "perl", "-e", "use #{@import_name}"] + when :python + ["/usr/bin/env", "python", "-c", "import #{@import_name}"] + when :python3 + ["/usr/bin/env", "python3", "-c", "import #{@import_name}"] + when :ruby + ["/usr/bin/env", "ruby", "-rubygems", "-e", "require '#{@import_name}'"] + end + end + + def command_line + case @language + when :lua then "luarocks-5.2 install" + when :lua51 then "luarocks-5.1 install" + when :perl then "cpan -i" + when :python then "pip install" + when :python3 then "pip3 install" + when :ruby then "gem install" + end + end + + def display_s + "#{@module_name} (#{@language} module)" + end +end diff --git a/Library/Homebrew/compat/requirements/tex_requirement.rb b/Library/Homebrew/compat/requirements/tex_requirement.rb new file mode 100644 index 000000000..cb26a8477 --- /dev/null +++ b/Library/Homebrew/compat/requirements/tex_requirement.rb @@ -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 |
