diff options
| author | Mike McQuaid | 2013-05-10 13:35:38 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2013-05-10 13:37:41 +0100 |
| commit | 92ccfc548e0c635d9d3a7b18f033eb3160285f23 (patch) | |
| tree | ffa158475cdcab3749cfaefb6ed75c75e72d7582 /Library | |
| parent | ba93e6d3630c6007290567f160a9a16bc17253c5 (diff) | |
| download | brew-92ccfc548e0c635d9d3a7b18f033eb3160285f23.tar.bz2 | |
Allow requirements to specify a default formula.
This allows default resolution of requirements without user intervention.
Closes Homebrew/homebrew#19627.
Diffstat (limited to 'Library')
| -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 |
