diff options
| author | Mike McQuaid | 2017-12-30 18:58:30 +0000 | 
|---|---|---|
| committer | Mike McQuaid | 2017-12-30 20:56:55 +0000 | 
| commit | d54e670a6491ae3e6681448cfcf9332635149aa8 (patch) | |
| tree | 6499f8269f928376e66ffa06b99bbcf3b426ece7 | |
| parent | faf2182495e770041274c59e3b9ac80b98326fae (diff) | |
| download | brew-d54e670a6491ae3e6681448cfcf9332635149aa8.tar.bz2 | |
requirements: move more to compat.
21 files changed, 60 insertions, 102 deletions
| diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index ca1c2a9f8..8cd1053fb 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -1,4 +1,5 @@  require "forwardable" +require "language/python"  class Caveats    extend Forwardable diff --git a/Library/Homebrew/compat/dependency_collector.rb b/Library/Homebrew/compat/dependency_collector.rb index 2e97d9d7f..82511bcc7 100644 --- a/Library/Homebrew/compat/dependency_collector.rb +++ b/Library/Homebrew/compat/dependency_collector.rb @@ -22,31 +22,61 @@ class DependencyCollector      case spec      when :clt        odeprecated "'depends_on :clt'" +    when :tex +      # odeprecated "'depends_on :tex'" +      TeXRequirement.new(tags)      when :autoconf, :automake, :bsdmake, :libtool        output_deprecation(spec, tags)        autotools_dep(spec, tags)      when :cairo, :fontconfig, :freetype, :libpng, :pixman        output_deprecation(spec, tags)        Dependency.new(spec.to_s, tags) -    when :apr -      # output_deprecation(spec, tags, "apr-util") -      Dependency.new("apr-util", tags) +    when :ant, :expat +      # output_deprecation(spec, tags) +      Dependency.new(spec.to_s, tags)      when :libltdl        tags << :run        output_deprecation("libtool", tags)        Dependency.new("libtool", tags) +    when :apr +      # output_deprecation(spec, tags, "apr-util") +      Dependency.new("apr-util", tags) +    when :fortran +      # output_deprecation(spec, tags, "gcc") +      FortranRequirement.new(tags) +    when :gpg +      # output_deprecation(spec, tags, "gnupg") +      GPG2Requirement.new(tags) +    when :hg +      # output_deprecation(spec, tags, "mercurial") +      MercurialRequirement.new(tags) +    when :mpi +      # output_deprecation(spec, tags, "open-mpi") +      MPIRequirement.new(*tags) +    when :emacs +      # output_deprecation(spec, tags) +      EmacsRequirement.new(tags)      when :mysql -      # output_deprecation("mysql", tags) +      # output_deprecation(spec, tags)        MysqlRequirement.new(tags) +    when :perl +      # output_deprecation(spec, tags) +      PerlRequirement.new(tags)      when :postgresql -      # output_deprecation("postgresql", tags) +      # output_deprecation(spec, tags)        PostgresqlRequirement.new(tags) -    when :gpg -      # output_deprecation("gnupg", tags) -      GPG2Requirement.new(tags) +    when :python, :python2 +      # output_deprecation(spec, tags) +      PythonRequirement.new(tags) +    when :python3 +      # output_deprecation(spec, tags) +      Python3Requirement.new(tags)      when :rbenv -      # output_deprecation("rbenv", tags) +      # output_deprecation(spec, tags)        RbenvRequirement.new(tags) +    when :ruby +      # output_deprecation(spec, tags) +      RubyRequirement.new(tags)      else        _parse_symbol_spec(spec, tags)      end diff --git a/Library/Homebrew/compat/requirements.rb b/Library/Homebrew/compat/requirements.rb index da6d867b3..48911b52b 100644 --- a/Library/Homebrew/compat/requirements.rb +++ b/Library/Homebrew/compat/requirements.rb @@ -1,5 +1,11 @@  require "requirements" +require "compat/requirements/emacs_requirement" +require "compat/requirements/fortran_requirement"  require "compat/requirements/language_module_requirement" +require "compat/requirements/mpi_requirement" +require "compat/requirements/perl_requirement" +require "compat/requirements/python_requirement" +require "compat/requirements/ruby_requirement"  require "compat/requirements/tex_requirement"  class MysqlRequirement < Requirement diff --git a/Library/Homebrew/requirements/emacs_requirement.rb b/Library/Homebrew/compat/requirements/emacs_requirement.rb index c8e2ec274..c8e2ec274 100644 --- a/Library/Homebrew/requirements/emacs_requirement.rb +++ b/Library/Homebrew/compat/requirements/emacs_requirement.rb diff --git a/Library/Homebrew/requirements/fortran_requirement.rb b/Library/Homebrew/compat/requirements/fortran_requirement.rb index ba3fead6f..ba3fead6f 100644 --- a/Library/Homebrew/requirements/fortran_requirement.rb +++ b/Library/Homebrew/compat/requirements/fortran_requirement.rb diff --git a/Library/Homebrew/requirements/mpi_requirement.rb b/Library/Homebrew/compat/requirements/mpi_requirement.rb index 065b56c8b..065b56c8b 100644 --- a/Library/Homebrew/requirements/mpi_requirement.rb +++ b/Library/Homebrew/compat/requirements/mpi_requirement.rb diff --git a/Library/Homebrew/requirements/perl_requirement.rb b/Library/Homebrew/compat/requirements/perl_requirement.rb index 70eb2a36c..70eb2a36c 100644 --- a/Library/Homebrew/requirements/perl_requirement.rb +++ b/Library/Homebrew/compat/requirements/perl_requirement.rb diff --git a/Library/Homebrew/requirements/python_requirement.rb b/Library/Homebrew/compat/requirements/python_requirement.rb index 3215d0a6c..3215d0a6c 100644 --- a/Library/Homebrew/requirements/python_requirement.rb +++ b/Library/Homebrew/compat/requirements/python_requirement.rb diff --git a/Library/Homebrew/requirements/ruby_requirement.rb b/Library/Homebrew/compat/requirements/ruby_requirement.rb index a9ec8c42d..a9ec8c42d 100644 --- a/Library/Homebrew/requirements/ruby_requirement.rb +++ b/Library/Homebrew/compat/requirements/ruby_requirement.rb diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 2e955a5e2..3164d237e 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -53,10 +53,6 @@ class DependencyCollector      parse_spec(spec, Array(tags))    end -  def ant_dep_if_needed(tags) -    Dependency.new("ant", tags) -  end -    def cvs_dep_if_needed(tags)      Dependency.new("cvs", tags)    end @@ -65,10 +61,6 @@ class DependencyCollector      Dependency.new("xz", tags)    end -  def expat_dep_if_needed(tags) -    Dependency.new("expat", tags) -  end -    def ld64_dep_if_needed(*)      LD64Dependency.new    end @@ -112,23 +104,11 @@ class DependencyCollector      when :xcode      then XcodeRequirement.new(tags)      when :linux      then LinuxRequirement.new(tags)      when :macos      then MacOSRequirement.new(tags) -    when :fortran    then FortranRequirement.new(tags) -    when :mpi        then MPIRequirement.new(*tags) -    when :tex        then TeXRequirement.new(tags)      when :arch       then ArchRequirement.new(tags) -    when :hg         then MercurialRequirement.new(tags) -    when :python     then PythonRequirement.new(tags) -    when :python2    then PythonRequirement.new(tags) -    when :python3    then Python3Requirement.new(tags)      when :java       then JavaRequirement.new(tags) -    when :ruby       then RubyRequirement.new(tags)      when :osxfuse    then OsxfuseRequirement.new(tags) -    when :perl       then PerlRequirement.new(tags)      when :tuntap     then TuntapRequirement.new(tags) -    when :ant        then ant_dep_if_needed(tags) -    when :emacs      then EmacsRequirement.new(tags)      when :ld64       then ld64_dep_if_needed(tags) -    when :expat      then expat_dep_if_needed(tags)      else        raise ArgumentError, "Unsupported special dependency #{spec.inspect}"      end diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 6da591f1a..4982bfbc5 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -379,24 +379,7 @@ class FormulaAuditor          case dep.name          when "git" -          problem "Don't use git as a dependency" -        when "gfortran" -          problem "Use `depends_on :fortran` instead of `depends_on 'gfortran'`" -        when "ruby" -          problem <<~EOS -            Don't use "ruby" as a dependency. If this formula requires a -            minimum Ruby version not provided by the system you should -            use the RubyRequirement: -              depends_on :ruby => "1.8" -            where "1.8" is the minimum version of Ruby required. -          EOS -        when "open-mpi", "mpich" -          problem <<~EOS -            There are multiple conflicting ways to install MPI. Use an MPIRequirement: -              depends_on :mpi => [<lang list>] -            Where <lang list> is a comma delimited list that can include: -              :cc, :cxx, :f77, :f90 -            EOS +          problem "Don't use git as a dependency (it's always available)"          when *BUILD_TIME_DEPS            next if dep.build? || dep.run?            problem <<~EOS diff --git a/Library/Homebrew/extend/os/mac/dependency_collector.rb b/Library/Homebrew/extend/os/mac/dependency_collector.rb index 66dcf3afe..03534bab9 100644 --- a/Library/Homebrew/extend/os/mac/dependency_collector.rb +++ b/Library/Homebrew/extend/os/mac/dependency_collector.rb @@ -1,9 +1,4 @@  class DependencyCollector -  def ant_dep_if_needed(tags) -    return if MacOS.version < :mavericks -    Dependency.new("ant", tags) -  end -    def cvs_dep_if_needed(tags)      return if MacOS.version < :lion      Dependency.new("cvs", tags) @@ -14,12 +9,6 @@ class DependencyCollector      Dependency.new("xz", tags)    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 diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb index 456dabd0a..e8c33465b 100644 --- a/Library/Homebrew/requirements.rb +++ b/Library/Homebrew/requirements.rb @@ -1,18 +1,12 @@  require "requirement" -require "requirements/fortran_requirement"  require "requirements/linux_requirement"  require "requirements/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"  require "requirements/tuntap_requirement"  require "requirements/unsigned_kext_requirement"  require "requirements/x11_requirement" -require "requirements/emacs_requirement"  require "requirements/arch_requirement"  require "requirements/xcode_requirement" diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index c49fdcba9..213203ff3 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -10,7 +10,7 @@ class JavaRequirement < Requirement      next true    end -  def initialize(tags) +  def initialize(tags = [])      @version = tags.shift if /(\d+\.)+\d/ =~ tags.first      super    end diff --git a/Library/Homebrew/requirements/xcode_requirement.rb b/Library/Homebrew/requirements/xcode_requirement.rb index ff167c6fd..a5f078c62 100644 --- a/Library/Homebrew/requirements/xcode_requirement.rb +++ b/Library/Homebrew/requirements/xcode_requirement.rb @@ -5,7 +5,7 @@ class XcodeRequirement < Requirement    satisfy(build_env: false) { xcode_installed_version } -  def initialize(tags) +  def initialize(tags = [])      @version = tags.find { |tag| tags.delete(tag) if tag =~ /(\d\.)+\d/ }      super    end diff --git a/Library/Homebrew/test/dependency_collector_spec.rb b/Library/Homebrew/test/dependency_collector_spec.rb index 5ba3c20bd..cfbd260b3 100644 --- a/Library/Homebrew/test/dependency_collector_spec.rb +++ b/Library/Homebrew/test/dependency_collector_spec.rb @@ -66,7 +66,7 @@ describe DependencyCollector do        expect(dep).to be_optional      end -    specify "ant dependency" do +    specify "ant dependency", :needs_compat do        subject.add ant: :build        expect(find_dependency("ant")).to eq(Dependency.new("ant", [:build]))      end diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb index b85e75b81..d3710a4cb 100644 --- a/Library/Homebrew/test/formula_installer_spec.rb +++ b/Library/Homebrew/test/formula_installer_spec.rb @@ -133,7 +133,7 @@ describe FormulaInstaller do      }.to raise_error(CannotInstallFormulaError)    end -  describe "#install_requirement_formula?" do +  describe "#install_requirement_formula?", :needs_compat do      before do        @requirement = Python3Requirement.new        @requirement_dependency = @requirement.to_dependency diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index 6ba6af307..a9d09cb00 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -711,21 +711,21 @@ describe Formula do      f1 = formula "f1" do        url "f1-1" -      depends_on :python +      depends_on :java        depends_on x11: :recommended        depends_on xcode: ["1.0", :optional]      end      stub_formula_loader(f1) -    python = PythonRequirement.new +    java = JavaRequirement.new      x11 = X11Requirement.new("x11", [:recommended])      xcode = XcodeRequirement.new(["1.0", :optional]) -    expect(Set.new(f1.recursive_requirements)).to eq(Set[python, x11]) +    expect(Set.new(f1.recursive_requirements)).to eq(Set[java, x11])      f1.build = BuildOptions.new(["--with-xcode", "--without-x11"], f1.options) -    expect(Set.new(f1.recursive_requirements)).to eq(Set[python, xcode]) +    expect(Set.new(f1.recursive_requirements)).to eq(Set[java, xcode])      f1.build = f1.stable.build      f2 = formula "f2" do @@ -734,11 +734,11 @@ describe Formula do        depends_on "f1"      end -    expect(Set.new(f2.recursive_requirements)).to eq(Set[python, x11]) -    expect(Set.new(f2.recursive_requirements {})).to eq(Set[python, x11, xcode]) +    expect(Set.new(f2.recursive_requirements)).to eq(Set[java, x11]) +    expect(Set.new(f2.recursive_requirements {})).to eq(Set[java, x11, xcode])      requirements = f2.recursive_requirements do |_dependent, requirement| -      Requirement.prune if requirement.is_a?(PythonRequirement) +      Requirement.prune if requirement.is_a?(JavaRequirement)      end      expect(Set.new(requirements)).to eq(Set[x11, xcode]) diff --git a/Library/Homebrew/test/mpi_requirement_spec.rb b/Library/Homebrew/test/mpi_requirement_spec.rb index f32b27993..87f99eb3a 100644 --- a/Library/Homebrew/test/mpi_requirement_spec.rb +++ b/Library/Homebrew/test/mpi_requirement_spec.rb @@ -1,6 +1,6 @@ -require "requirements/mpi_requirement" +require "compat/requirements/mpi_requirement" -describe MPIRequirement do +describe MPIRequirement, :needs_compat do    describe "::new" do      subject { described_class.new(*(wrappers + tags)) }      let(:wrappers) { [:cc, :cxx, :f77] } diff --git a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb index 688149021..357c35c2d 100644 --- a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb @@ -22,18 +22,6 @@ describe DependencyCollector do      expect(subject.build(:ld64)).to be nil    end -  specify "ant Mavericks or newer dependency" do -    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.9")) -    subject.add ant: :build -    expect(subject.deps.find { |dep| dep.name == "ant" }).to eq(Dependency.new("ant", [:build])) -  end - -  specify "ant pre-Mavericks dependency" do -    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.7")) -    subject.add ant: :build -    expect(subject.deps.find { |dep| dep.name == "ant" }).to be nil -  end -    specify "Resource xz pre-Mavericks dependency" do      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.8"))      resource = Resource.new diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb index 0d2146339..ee1de059c 100644 --- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb @@ -717,19 +717,6 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do        RUBY      end -    it "deprecated ENV.fortran usage" do -      expect_offense(<<~RUBY) -        class Foo < Formula -          desc "foo" -          url 'http://example.com/foo-1.0.tgz' -          test do -            ENV.fortran -            ^^^^^^^^^^^ Use `depends_on :fortran` instead of `ENV.fortran` -          end -        end -      RUBY -    end -      it "deprecated ARGV.include? (--HEAD) usage" do        expect_offense(<<~RUBY)          class Foo < Formula | 
