Allow requirements to specify a default formula.
This allows default resolution of requirements without user intervention. Closes Homebrew/homebrew#19627.
This commit is contained in:
parent
ba93e6d363
commit
92ccfc548e
@ -75,6 +75,11 @@ class Requirement
|
|||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
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)
|
def fatal(val=nil)
|
||||||
val.nil? ? @fatal : @fatal = val
|
val.nil? ? @fatal : @fatal = val
|
||||||
end
|
end
|
||||||
@ -138,6 +143,13 @@ class Requirement
|
|||||||
|
|
||||||
next if prune
|
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
|
reqs << req
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,6 +19,7 @@ end
|
|||||||
|
|
||||||
class MysqlDependency < Requirement
|
class MysqlDependency < Requirement
|
||||||
fatal true
|
fatal true
|
||||||
|
default_formula 'mysql'
|
||||||
|
|
||||||
satisfy { which 'mysql_config' }
|
satisfy { which 'mysql_config' }
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ end
|
|||||||
|
|
||||||
class PostgresqlDependency < Requirement
|
class PostgresqlDependency < Requirement
|
||||||
fatal true
|
fatal true
|
||||||
|
default_formula 'postgres'
|
||||||
|
|
||||||
satisfy { which 'pg_config' }
|
satisfy { which 'pg_config' }
|
||||||
|
|
||||||
@ -110,6 +112,7 @@ end
|
|||||||
|
|
||||||
class MercurialDependency < Requirement
|
class MercurialDependency < Requirement
|
||||||
fatal true
|
fatal true
|
||||||
|
default_formula 'mercurial'
|
||||||
|
|
||||||
satisfy { which('hg') }
|
satisfy { which('hg') }
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,8 @@ class MPIDependency < Requirement
|
|||||||
|
|
||||||
fatal true
|
fatal true
|
||||||
|
|
||||||
|
default_formula 'open-mpi'
|
||||||
|
|
||||||
env :userpaths
|
env :userpaths
|
||||||
|
|
||||||
def initialize *lang_list
|
def initialize *lang_list
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user