brew/Library/Homebrew/formula_support.rb

67 lines
1.5 KiB
Ruby
Raw Normal View History

# Used to track formulae that cannot be installed at the same time.
FormulaConflict = Struct.new(:name, :reason)
# Used to annotate formulae that duplicate macOS provided software
# or cause conflicts when linked in.
class KegOnlyReason
attr_reader :reason
def initialize(reason, explanation)
@reason = reason
@explanation = explanation
end
def valid?
![:provided_by_macos, :provided_by_osx, :shadowed_by_macos].include?(@reason)
end
def to_s
return @explanation unless @explanation.empty?
case @reason
when :versioned_formula
<<~EOS
this is an alternate version of another formula
EOS
when :provided_by_macos
<<~EOS
macOS already provides this software and installing another version in
parallel can cause all kinds of trouble
EOS
when :shadowed_by_macos
<<~EOS
macOS provides similar software and installing this software in
parallel can cause all kinds of trouble
EOS
else
@reason
end.strip
end
end
2015-09-14 19:51:04 +08:00
# Used to annotate formulae that don't require compiling or cannot build a bottle.
2015-09-14 19:51:04 +08:00
class BottleDisableReason
SUPPORTED_TYPES = [:unneeded, :disable].freeze
2015-09-14 19:51:04 +08:00
def initialize(type, reason)
@type = type
@reason = reason
end
def unneeded?
@type == :unneeded
end
def valid?
SUPPORTED_TYPES.include? @type
end
2015-09-14 19:51:04 +08:00
def to_s
return "This formula doesn't require compiling." if unneeded?
2018-09-17 02:45:00 +02:00
@reason
2015-09-14 19:51:04 +08:00
end
end
require "extend/os/formula_support"