diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 3de1935d8b..868aebfc58 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1,7 +1,7 @@ require 'download_strategy' require 'fileutils' - +# Defines a URL and download method for a stable or HEAD build class SoftwareSpecification attr_reader :url, :specs, :using @@ -46,6 +46,31 @@ class SoftwareSpecification end +# Used to annotate formulae that duplicate OS X provided software +# :provided_by_osx +class KegOnlyReason + attr_reader :reason, :explanation + + def initialize reason, explanation=nil + @reason = reason + @explanation = explanation + end + + def to_s + if @reason == :provided_by_osx + <<-EOS.chomp +Mac OS X already provides this program and installing another version in +parallel can cause all kinds of trouble. + +#{@explanation} +EOS + else + @reason + end + end +end + + # Derive and define at least @url, see Library/Formula for examples class Formula include FileUtils @@ -648,8 +673,8 @@ EOF puts "detected as an alias for the target formula." end - def keg_only reason - @keg_only_reason = reason + def keg_only reason, explanation=nil + @keg_only_reason = KegOnlyReason.new(reason, explanation.chomp) end end end