diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb index 153140000cc3499f3afb5b30b67aa86e9a1e6002..7e5b7898c72bfa31e3cf217ae03356a6a657b96a 100644 --- a/Library/Homebrew/requirements.rb +++ b/Library/Homebrew/requirements.rb @@ -6,6 +6,7 @@ require "requirements/minimum_macos_requirement" require "requirements/maximum_macos_requirement" require "requirements/mpi_requirement" require "requirements/osxfuse_requirement" +require "requirements/perl_requirement" require "requirements/python_requirement" require "requirements/java_requirement" require "requirements/ruby_requirement" diff --git a/Library/Homebrew/requirements/perl_requirement.rb b/Library/Homebrew/requirements/perl_requirement.rb new file mode 100644 index 0000000000000000000000000000000000000000..79d5e8e9269f0af3a000ee4053f09b6327baae40 --- /dev/null +++ b/Library/Homebrew/requirements/perl_requirement.rb @@ -0,0 +1,28 @@ +class PerlRequirement < Requirement + fatal true + default_formula "perl" + + def initialize(tags) + @version = tags.shift if /^\d+\.\d+$/ === tags.first + raise "PerlRequirement requires a version!" unless @version + super + end + + satisfy(:build_env => false) do + which_all("perl").detect do |perl| + perl_version = Utils.popen_read(perl, "--version")[/\(v(\d+\.\d+)(?:\.\d+)?\)/, 1] + next unless perl_version + Version.new(perl_version.to_s) >= Version.new(@version) + end + end + + def message + s = "Perl #{@version} is required to install this formula." + s += super + s + end + + def inspect + "#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>" + end +end