diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb index 0191d76c79..c873e75680 100644 --- a/Library/Homebrew/cmd/man.rb +++ b/Library/Homebrew/cmd/man.rb @@ -11,7 +11,7 @@ module Homebrew raise UsageError unless ARGV.named.empty? if ARGV.flag? "--link" - link_man_pages + odie "`brew man --link` is now done automatically by `brew update`." else regenerate_man_pages end @@ -19,18 +19,6 @@ module Homebrew private - def link_man_pages - linked_path = HOMEBREW_PREFIX/"share/man/man1" - - if TARGET_MAN_PATH == linked_path - odie "The target path is the same as the linked one." - end - - Dir["#{TARGET_MAN_PATH}/*.1"].each do |page| - FileUtils.ln_s page, linked_path - end - end - def regenerate_man_pages Homebrew.install_gem_setup_path! "ronn" diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 9b648a5389..5121bdb6c2 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -85,6 +85,7 @@ module Homebrew Descriptions.update_cache(hub) end + link_manpages Tap.each(&:link_manpages) Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"] @@ -158,6 +159,11 @@ module Homebrew end end end + + def link_manpages + return if HOMEBREW_PREFIX.to_s == HOMEBREW_REPOSITORY.to_s + link_path_manpages(HOMEBREW_REPOSITORY/"share", "brew update") + end end class Reporter diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index fb194a5bb9..8dd7fd1557 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -248,26 +248,7 @@ class Tap end def link_manpages - return unless (path/"man").exist? - conflicts = [] - (path/"man").find do |src| - next if src.directory? - dst = HOMEBREW_PREFIX/"share"/src.relative_path_from(path) - next if dst.symlink? && src == dst.resolved_path - if dst.exist? - conflicts << dst - next - end - dst.make_relative_symlink(src) - end - unless conflicts.empty? - onoe <<-EOS.undent - Could not link #{name} manpages to: - #{conflicts.join("\n")} - - Please delete these files and run `brew tap --repair`. - EOS - end + link_path_manpages(path, "brew tap --repair") end # uninstall this {Tap}. diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 0a1b5158d5..7b7289ca26 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -594,3 +594,26 @@ def truncate_text_to_approximate_size(s, max_bytes, options = {}) out.encode!("UTF-8") out end + +def link_path_manpages(path, command) + return unless (path/"man").exist? + conflicts = [] + (path/"man").find do |src| + next if src.directory? + dst = HOMEBREW_PREFIX/"share"/src.relative_path_from(path) + next if dst.symlink? && src == dst.resolved_path + if dst.exist? + conflicts << dst + next + end + dst.make_relative_symlink(src) + end + unless conflicts.empty? + onoe <<-EOS.undent + Could not link #{name} manpages to: + #{conflicts.join("\n")} + + Please delete these files and run `#{command}`. + EOS + end +end