keg-only: provide more info about system dupes

System duplicates can now provide more information about why
they are included in Homebrew.
This commit is contained in:
Adam Vandenberg 2011-03-15 22:01:27 -07:00
parent 9995f9a651
commit 63846c7a92

View File

@ -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