From 63846c7a929157842c1657dedcb76ce0ceb123ee Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Tue, 15 Mar 2011 22:01:27 -0700 Subject: [PATCH] keg-only: provide more info about system dupes System duplicates can now provide more information about why they are included in Homebrew. --- Library/Homebrew/formula.rb | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) 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