brew/Library/Homebrew/formula_support.rb

97 lines
2.5 KiB
Ruby
Raw Normal View History

2014-02-22 07:51:33 -08:00
# 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?
2014-04-01 21:35:22 -05:00
case @reason
when :provided_pre_mountain_lion
MacOS.version < :mountain_lion
when :provided_pre_mavericks
MacOS.version < :mavericks
when :provided_pre_el_capitan
MacOS.version < :el_capitan
when :provided_pre_high_sierra
MacOS.version < :high_sierra
when :provided_until_xcode43
MacOS::Xcode.version < "4.3"
when :provided_until_xcode5
MacOS::Xcode.version < "5.0"
2014-04-01 21:35:22 -05:00
else
true
end
end
def to_s
return @explanation unless @explanation.empty?
case @reason
2017-10-15 02:28:32 +02:00
when :versioned_formula then <<~EOS
this is an alternate version of another formula
EOS
when :provided_by_macos then <<~EOS
macOS already provides this software and installing another version in
parallel can cause all kinds of trouble
EOS
when :shadowed_by_macos then <<~EOS
macOS provides similar software and installing this software in
parallel can cause all kinds of trouble
EOS
2017-10-15 02:28:32 +02:00
when :provided_pre_mountain_lion then <<~EOS
macOS already provides this software in versions before Mountain Lion
EOS
2017-10-15 02:28:32 +02:00
when :provided_pre_mavericks then <<~EOS
macOS already provides this software in versions before Mavericks
EOS
2017-10-15 02:28:32 +02:00
when :provided_pre_el_capitan then <<~EOS
macOS already provides this software in versions before El Capitan
EOS
2017-10-15 02:28:32 +02:00
when :provided_pre_high_sierra then <<~EOS
macOS already provides this software in versions before High Sierra
EOS
2017-10-15 02:28:32 +02:00
when :provided_until_xcode43 then <<~EOS
Xcode provides this software prior to version 4.3
EOS
2017-10-15 02:28:32 +02:00
when :provided_until_xcode5 then <<~EOS
Xcode provides this software prior to version 5
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 bottle.
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
if unneeded?
2015-09-14 19:51:04 +08:00
"This formula doesn't require compiling."
else
@reason
end
end
end