diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb index 0191d76c79add3e9378edf7ec2f0e93b752ff389..c873e756804bcd1917f4f23587e4e882243363c7 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 9b648a5389cc8e26bdb0c0b39bb7a9126aee6ae0..5121bdb6c23f5dedc33f0bd133f6039855399de8 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 fb194a5bb9c025a8f5284b780c819fb8299d5bc4..8dd7fd1557629ecbe21b05196ecf3241e177d73d 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 0a1b5158d5aca6c933d1e12b4ca8cfdb62a9cf65..7b7289ca2606724b70841ed3c1b8c9ed9251b1fa 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