keg: add ALL_TOP_LEVEL_DIRECTORIES constant.

This is used in diagnostic (and will be used in other places later)
rather than hard-coding other directories later.
This commit is contained in:
Mike McQuaid 2016-09-15 09:20:39 +01:00
parent 0992951634
commit 842d6ce8bd
2 changed files with 2 additions and 2 deletions

View File

@ -308,8 +308,7 @@ module Homebrew
def check_access_prefix_directories def check_access_prefix_directories
not_writable_dirs = [] not_writable_dirs = []
extra_dirs = ["lib/pkgconfig", "share/locale", "share/man", "opt"] Keg::ALL_TOP_LEVEL_DIRECTORIES.each do |dir|
(Keg::TOP_LEVEL_DIRECTORIES + extra_dirs).each do |dir|
path = HOMEBREW_PREFIX/dir path = HOMEBREW_PREFIX/dir
next unless path.exist? next unless path.exist?
next if path.writable_real? next if path.writable_real?

View File

@ -65,6 +65,7 @@ class Keg
LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/ LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$} INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks] TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks]
ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze
PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs].map do |d| PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs].map do |d|
case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end
end end