Add conflicts_with DSL method
conflicts_with is a thin wrapper around Requirement which simplifies marking conflicts between formulae. Closes Homebrew/homebrew#13687. Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
This commit is contained in:
parent
6a8c4843f7
commit
0c237a8679
@ -68,6 +68,11 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
|
|
||||||
puts "Depends on: #{f.deps*', '}" unless f.deps.empty?
|
puts "Depends on: #{f.deps*', '}" unless f.deps.empty?
|
||||||
|
conflicts = []
|
||||||
|
f.external_deps.each do |dep|
|
||||||
|
conflicts << dep.formula if dep.is_a? ConflictRequirement
|
||||||
|
end
|
||||||
|
puts "Conflicts with: #{conflicts*', '}" unless conflicts.empty?
|
||||||
|
|
||||||
if f.rack.directory?
|
if f.rack.directory?
|
||||||
kegs = f.rack.children
|
kegs = f.rack.children
|
||||||
|
|||||||
@ -287,3 +287,23 @@ class MPIDependency < Requirement
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class ConflictRequirement < Requirement
|
||||||
|
attr_reader :formula
|
||||||
|
|
||||||
|
def initialize formula, message
|
||||||
|
@formula = formula
|
||||||
|
@message = message
|
||||||
|
end
|
||||||
|
|
||||||
|
def message; @message; end
|
||||||
|
|
||||||
|
def satisfied?
|
||||||
|
keg = Formula.factory(@formula).prefix
|
||||||
|
not keg.exist? && Keg.new(keg).linked?
|
||||||
|
end
|
||||||
|
|
||||||
|
def fatal?
|
||||||
|
not ARGV.force?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -626,6 +626,21 @@ private
|
|||||||
dependencies.add(dep)
|
dependencies.add(dep)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def conflicts_with formula, opts={}
|
||||||
|
message = <<-EOS.undent
|
||||||
|
#{formula} cannot be installed alongside #{name.downcase}.
|
||||||
|
EOS
|
||||||
|
message << "This is because #{opts[:reason]}\n" if opts[:reason]
|
||||||
|
if !ARGV.force? then message << <<-EOS.undent
|
||||||
|
Please `brew unlink` or `brew uninstall` #{formula} before continuing.
|
||||||
|
To install anyway, use:
|
||||||
|
brew install --force
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
dependencies.add ConflictRequirement.new(formula, message)
|
||||||
|
end
|
||||||
|
|
||||||
def skip_clean paths
|
def skip_clean paths
|
||||||
if paths == :all
|
if paths == :all
|
||||||
@skip_clean_all = true
|
@skip_clean_all = true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user