diff options
| author | Mike McQuaid | 2015-12-08 17:26:53 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2015-12-09 09:09:26 +0000 |
| commit | d36d88edf27ead55adb6efe312f7f70f090b729d (patch) | |
| tree | 26e0a61e8139ee738fd1ac31abab487b7523b81a /Library | |
| parent | ed35c18fcf39405b8ab9fe87f3ebcf2a7f617ef2 (diff) | |
| download | brew-d36d88edf27ead55adb6efe312f7f70f090b729d.tar.bz2 | |
Allow taps to link manpages.
A blocker for https://github.com/caskroom/homebrew-cask/pull/15381
being merged.
Closes Homebrew/homebrew#46795.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/tap.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/tap.rb | 40 |
3 files changed, 40 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 08b9e8327..a7fd3f500 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -5,6 +5,7 @@ module Homebrew if ARGV.empty? puts Tap.names elsif ARGV.first == "--repair" + Tap.each(&:link_manpages) migrate_taps :force => true elsif ARGV.first == "--list-official" require "official_taps" diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 39a0371fb..dfabe95ee 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -76,6 +76,7 @@ module Homebrew puts "Already up-to-date." unless master_updated || !updated_taps.empty? Tap.clear_cache + Tap.each(&:link_manpages) # automatically tap any migrated formulae's new tap report.select_formula(:D).each do |f| diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 9134b7d8c..03b702569 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -138,6 +138,8 @@ class Tap raise end + link_manpages + formula_count = formula_files.size puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{path.abv})" Descriptions.cache_formulae(formula_names) @@ -153,6 +155,29 @@ class Tap end 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 + end + # uninstall this {Tap}. def uninstall raise TapUnavailableError, name unless installed? @@ -161,11 +186,22 @@ class Tap unpin if pinned? formula_count = formula_files.size Descriptions.uncache_formulae(formula_names) + unlink_manpages path.rmtree - path.dirname.rmdir_if_possible + path.parent.rmdir_if_possible puts "Untapped #{formula_count} formula#{plural(formula_count, "e")}" end + def unlink_manpages + return unless (path/"man").exist? + (path/"man").find do |src| + next if src.directory? + dst = HOMEBREW_PREFIX/src.relative_path_from(path) + dst.delete if dst.symlink? && src == dst.resolved_path + dst.parent.rmdir_if_possible + end + end + # True if the {#remote} of {Tap} is customized. def custom_remote? return true unless remote @@ -262,7 +298,7 @@ class Tap raise TapUnavailableError, name unless installed? raise TapPinStatusError.new(name, false) unless pinned? pinned_symlink_path.delete - pinned_symlink_path.dirname.rmdir_if_possible + pinned_symlink_path.parent.rmdir_if_possible @pinned = false end |
