aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorJack Nagel2013-04-12 19:21:36 -0500
committerJack Nagel2013-04-12 19:32:02 -0500
commitfd11f138bda51572e38568b4fa466fd5647e0abc (patch)
tree3ed94e0596337ec2e8b7544e433726dc41584847 /Library/Homebrew
parent18f5284e8caa5b9c2316575262c36b5c3f8614fe (diff)
downloadhomebrew-fd11f138bda51572e38568b4fa466fd5647e0abc.tar.bz2
doctor: consolidate directory access checks
Also include a writability check for lib. Closes #18571.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cmd/doctor.rb66
1 files changed, 22 insertions, 44 deletions
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 419d8556c..836572f0c 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -307,6 +307,14 @@ def __check_subdir_access base
end
end
+def check_access_share_locale
+ __check_subdir_access 'share/locale'
+end
+
+def check_access_share_man
+ __check_subdir_access 'share/man'
+end
+
def check_access_usr_local
return unless HOMEBREW_PREFIX.to_s == '/usr/local'
@@ -322,51 +330,21 @@ def check_access_usr_local
end
end
-def check_access_share_locale
- __check_subdir_access 'share/locale'
-end
-
-def check_access_share_man
- __check_subdir_access 'share/man'
-end
-
-def __check_folder_access base, msg
- folder = HOMEBREW_PREFIX+base
- if folder.exist? and not folder.writable_real?
- <<-EOS.undent
- #{folder} isn't writable.
- This can happen if you "sudo make install" software that isn't managed
- by Homebrew.
-
- #{msg}
-
- You should probably `chown` #{folder}
+%w{include etc lib lib/pkgconfig share}.each do |d|
+ class_eval <<-EOS, __FILE__, __LINE__ + 1
+ def check_access_#{d.sub("/", "_")}
+ if (dir = HOMEBREW_PREFIX+'#{d}').exist? && !dir.writable_real?
+ <<-EOF.undent
+ \#{dir} isn't writable.
+ This can happen if you "sudo make install" software that isn't managed by
+ by Homebrew. If a brew tries to write a file to this directory, the
+ install will fail during the link step.
+
+ You should probably `chown` \#{dir}
+ EOF
+ end
+ end
EOS
- end
-end
-
-def check_access_pkgconfig
- __check_folder_access 'lib/pkgconfig',
- 'If a brew tries to write a .pc file to this directory, the install will\n'+
- 'fail during the link step.'
-end
-
-def check_access_include
- __check_folder_access 'include',
- 'If a brew tries to write a header file to this directory, the install will\n'+
- 'fail during the link step.'
-end
-
-def check_access_etc
- __check_folder_access 'etc',
- 'If a brew tries to write a file to this directory, the install will\n'+
- 'fail during the link step.'
-end
-
-def check_access_share
- __check_folder_access 'share',
- 'If a brew tries to write a file to this directory, the install will\n'+
- 'fail during the link step.'
end
def check_access_logs