diff options
| author | Mike McQuaid | 2016-08-24 11:06:20 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-08-24 11:06:58 +0100 |
| commit | 8cc027a3cd24b95120932c581c8b9eebb8c710f3 (patch) | |
| tree | e0f224d961143662465b49b91f5d9575a832a6b2 /Library/Homebrew | |
| parent | e93771ae073d333b78ec8e9b54aada290326781a (diff) | |
| download | brew-8cc027a3cd24b95120932c581c8b9eebb8c710f3.tar.bz2 | |
utils: add link_path_manpages method.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/utils.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 0a1b5158d..7b7289ca2 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 |
