Restore keg-only caveats

Fixes Homebrew/homebrew#16989.
This commit is contained in:
Jack Nagel 2013-01-12 13:08:29 -06:00
parent 2a4a3c3a95
commit 870f095c69
3 changed files with 55 additions and 33 deletions

View File

@ -1,34 +1,51 @@
class Caveats class Caveats
def self.print f attr_reader :f
s = []
unless f.caveats.to_s.strip.empty? def initialize(f)
s << f.caveats @f = f
end end
keg = Keg.new(f.prefix) rescue nil def caveats
keg ||= Keg.new(f.opt_prefix.realpath) rescue nil caveats = []
keg ||= Keg.new(f.linked_keg.realpath) rescue nil caveats << f.caveats
caveats << f.keg_only_text rescue nil if f.keg_only?
caveats << bash_completion_caveats
caveats << zsh_completion_caveats
caveats << plist_caveats
caveats.compact.join("\n")
end
if keg and keg.completion_installed? :bash def empty?
s << "\n" unless s.empty? caveats.empty?
s << <<-EOS.undent end
private
def keg
@keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d|
Keg.new(d.realpath) rescue nil
end.compact.first
end
def bash_completion_caveats
if keg and keg.completion_installed? :bash then <<-EOS.undent
Bash completion has been installed to: Bash completion has been installed to:
#{HOMEBREW_PREFIX}/etc/bash_completion.d #{HOMEBREW_PREFIX}/etc/bash_completion.d
EOS EOS
end end
end
if keg and keg.completion_installed? :zsh def zsh_completion_caveats
s << "\n" unless s.empty? if keg and keg.completion_installed? :zsh then <<-EOS.undent
s << <<-EOS.undent
zsh completion has been installed to: zsh completion has been installed to:
#{HOMEBREW_PREFIX}/share/zsh/site-functions #{HOMEBREW_PREFIX}/share/zsh/site-functions
EOS EOS
end end
end
def plist_caveats
s = []
if f.plist or (keg and keg.plist_installed?) if f.plist or (keg and keg.plist_installed?)
s << "\n" unless s.empty?
destination = f.plist_startup ? '/Library/LaunchDaemons' \ destination = f.plist_startup ? '/Library/LaunchDaemons' \
: '~/Library/LaunchAgents' : '~/Library/LaunchAgents'
@ -79,7 +96,6 @@ class Caveats
end end
end end
end end
s.join("\n") unless s.empty?
ohai 'Caveats', s unless s.empty?
end end
end end

View File

@ -120,7 +120,8 @@ module Homebrew extend self
Homebrew.dump_options_for_formula f Homebrew.dump_options_for_formula f
end end
Caveats.print f c = Caveats.new(f)
ohai 'Caveats', c.caveats unless c.empty?
rescue FormulaUnavailableError rescue FormulaUnavailableError
# check for DIY installation # check for DIY installation

View File

@ -154,7 +154,12 @@ class FormulaInstaller
check_infopages check_infopages
end end
Caveats.print f c = Caveats.new(f)
unless c.empty?
@show_summary_heading = true
ohai 'Caveats', c.caveats
end
end end
def finish def finish
@ -175,7 +180,7 @@ class FormulaInstaller
install_plist install_plist
fix_install_names fix_install_names
ohai "Summary - #{f.name}" if ARGV.verbose? or show_summary_heading ohai "Summary" if ARGV.verbose? or show_summary_heading
print "🍺 " if MacOS.version >= :lion print "🍺 " if MacOS.version >= :lion
print "#{f.prefix}: #{f.prefix.abv}" print "#{f.prefix}: #{f.prefix.abv}"
print ", built in #{pretty_duration build_time}" if build_time print ", built in #{pretty_duration build_time}" if build_time