diff options
| author | Mike McQuaid | 2013-05-10 13:35:38 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2013-05-10 13:37:41 +0100 | 
| commit | 2d9329f14eaac22dd0e2411e31295dd9acf6d1c5 (patch) | |
| tree | 2fc7c19abb862f1e93022ae6c2a30d2164b14222 /Library/Homebrew | |
| parent | 849942f9fd8028de0ed99c3c740fb33e28cf84ea (diff) | |
| download | homebrew-2d9329f14eaac22dd0e2411e31295dd9acf6d1c5.tar.bz2 | |
Allow requirements to specify a default formula.
This allows default resolution of requirements without user intervention.
Closes #19627.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/requirement.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/requirements.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/requirements/mpi_dependency.rb | 2 | 
3 files changed, 17 insertions, 0 deletions
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index c20273895..4cae1f246 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -75,6 +75,11 @@ class Requirement    end    class << self +    # The default formula to install to satisfy this requirement. +    def default_formula(val=nil) +      val.nil? ? @default_formula : @default_formula = val.to_s +    end +      def fatal(val=nil)        val.nil? ? @fatal : @fatal = val      end @@ -138,6 +143,13 @@ class Requirement          next if prune +        # TODO: Do this in a cleaner way, perhaps with another type of +        # dependency type. +        if req.class.default_formula +          dependent.class.depends_on(req.class.default_formula) +          next +        end +          reqs << req        end      end diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb index 29e61b696..bdbe71ee0 100644 --- a/Library/Homebrew/requirements.rb +++ b/Library/Homebrew/requirements.rb @@ -19,6 +19,7 @@ end  class MysqlDependency < Requirement    fatal true +  default_formula 'mysql'    satisfy { which 'mysql_config' } @@ -40,6 +41,7 @@ end  class PostgresqlDependency < Requirement    fatal true +  default_formula 'postgres'    satisfy { which 'pg_config' } @@ -110,6 +112,7 @@ end  class MercurialDependency < Requirement    fatal true +  default_formula 'mercurial'    satisfy { which('hg') } diff --git a/Library/Homebrew/requirements/mpi_dependency.rb b/Library/Homebrew/requirements/mpi_dependency.rb index b51efc303..e83f7d80c 100644 --- a/Library/Homebrew/requirements/mpi_dependency.rb +++ b/Library/Homebrew/requirements/mpi_dependency.rb @@ -9,6 +9,8 @@ class MPIDependency < Requirement    fatal true +  default_formula 'open-mpi' +    env :userpaths    def initialize *lang_list  | 
