brew/Library/Homebrew/formula_support.rb
Mike McQuaid 9580afb222 formula_support: deprecate more keg_only reasons.
It's unnecessary extra complexity to have versions that are keg-only on
some versions of macOS and not others.

Initially this was to only do so on old versions of OS X and Xcode but
the discussion in https://github.com/Homebrew/brew/pull/4081 meant that
it made more sense to remove them all.
2018-04-17 11:17:18 +01:00

64 lines
1.4 KiB
Ruby

# 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?
true
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
# Used to annotate formulae that don't require compiling or cannot build bottle.
class BottleDisableReason
SUPPORTED_TYPES = [:unneeded, :disable].freeze
def initialize(type, reason)
@type = type
@reason = reason
end
def unneeded?
@type == :unneeded
end
def valid?
SUPPORTED_TYPES.include? @type
end
def to_s
return "This formula doesn't require compiling." if unneeded?
@reason
end
end