aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2016-09-09 13:37:14 +0100
committerGitHub2016-09-09 13:37:14 +0100
commitaaf8c415f45cda203325b02d464bd4b8d8d61e36 (patch)
tree830eea1154d9638df7e6e2a027ca87487e0d762f
parentb5a6b4e8e15ec5110d3ac15543990f22c5abe7b4 (diff)
parent30fd4f3fe5d13f4fce9ba273580073327e17cf35 (diff)
downloadbrew-aaf8c415f45cda203325b02d464bd4b8d8d61e36.tar.bz2
Merge pull request #899 from MikeMcQuaid/diagnostic-duplicate-remove
diagnostic: remove duplicate checks.
-rw-r--r--Library/Homebrew/diagnostic.rb96
-rw-r--r--Library/Homebrew/test/test_diagnostic.rb11
2 files changed, 13 insertions, 94 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index c064e9169..1b3018251 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -283,35 +283,16 @@ module Homebrew
EOS
end
- def __check_subdir_access(base)
- target = HOMEBREW_PREFIX+base
- return unless target.exist?
-
- cant_read = []
- target.find do |d|
- next unless d.directory?
- cant_read << d unless d.writable_real?
- end
- return if cant_read.empty?
-
- inject_file_list cant_read.sort, <<-EOS.undent
- Some directories in #{target} aren't writable.
- This can happen if you "sudo make install" software that isn't managed
- by Homebrew. If a brew tries to add locale information to one of these
- directories, then the install will fail during the link step.
+ def check_tmpdir_sticky_bit
+ world_writable = HOMEBREW_TEMP.stat.mode & 0777 == 0777
+ return if !world_writable || HOMEBREW_TEMP.sticky?
- You should `sudo chown -R $(whoami)` them:
+ <<-EOS.undent
+ #{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set.
+ Please execute `sudo chmod +t #{HOMEBREW_TEMP}` in your Terminal.
EOS
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_homebrew_repository
return if HOMEBREW_REPOSITORY.writable_real?
@@ -324,22 +305,11 @@ module Homebrew
EOS
end
- def check_access_homebrew_cellar
- return if HOMEBREW_CELLAR.writable_real?
-
- <<-EOS.undent
- #{HOMEBREW_CELLAR} is not writable.
-
- You should change the ownership and permissions of #{HOMEBREW_CELLAR}
- back to your user account.
- sudo chown -R $(whoami) #{HOMEBREW_CELLAR}
- EOS
- end
-
- def check_access_top_level_directories
+ def check_access_prefix_directories
not_writable_dirs = []
- (Keg::TOP_LEVEL_DIRECTORIES + ["opt"]).each do |dir|
+ extra_dirs = ["lib/pkgconfig", "share/locale", "share/man", "opt"]
+ (Keg::TOP_LEVEL_DIRECTORIES + extra_dirs).each do |dir|
path = HOMEBREW_PREFIX/dir
next unless path.exist?
next if path.writable_real?
@@ -352,42 +322,16 @@ module Homebrew
The following directories are not writable:
#{not_writable_dirs.join("\n")}
+ This can happen if you "sudo make install" software that isn't managed
+ by Homebrew. If a formula tries to write a file to this directory, the
+ install will fail during the link step.
+
You should change the ownership and permissions of these directories.
back to your user account.
sudo chown -R $(whoami) #{not_writable_dirs.join(" ")}
EOS
end
- def check_tmpdir_sticky_bit
- world_writable = HOMEBREW_TEMP.stat.mode & 0777 == 0777
- return if !world_writable || HOMEBREW_TEMP.sticky?
-
- <<-EOS.undent
- #{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set.
- Please execute `sudo chmod +t #{HOMEBREW_TEMP}` in your Terminal.
- EOS
- end
-
- (Keg::TOP_LEVEL_DIRECTORIES + ["lib/pkgconfig"]).each do |d|
- define_method("check_access_#{d.sub("/", "_")}") do
- dir = HOMEBREW_PREFIX.join(d)
- return unless dir.exist?
- return if dir.writable_real?
-
- <<-EOS.undent
- #{dir} isn't writable.
-
- This can happen if you "sudo make install" software that isn't managed
- by Homebrew. If a formula tries to write a file to this directory, the
- install will fail during the link step.
-
- You should change the ownership and permissions of #{dir} back to
- your user account.
- sudo chown -R $(whoami) #{dir}
- EOS
- end
- end
-
def check_access_site_packages
return unless Language::Python.homebrew_site_packages.exist?
return if Language::Python.homebrew_site_packages.writable_real?
@@ -446,20 +390,6 @@ module Homebrew
EOS
end
- def check_access_prefix_opt
- opt = HOMEBREW_PREFIX.join("opt")
- return unless opt.exist?
- return if opt.writable_real?
-
- <<-EOS.undent
- #{opt} isn't writable.
-
- You should change the ownership and permissions of #{opt}
- back to your user account.
- sudo chown -R $(whoami) #{opt}
- EOS
- end
-
def check_homebrew_prefix
return if HOMEBREW_PREFIX.to_s == "/usr/local"
diff --git a/Library/Homebrew/test/test_diagnostic.rb b/Library/Homebrew/test/test_diagnostic.rb
index eeb1fcf1f..5d0f5f386 100644
--- a/Library/Homebrew/test/test_diagnostic.rb
+++ b/Library/Homebrew/test/test_diagnostic.rb
@@ -83,17 +83,6 @@ class DiagnosticChecksTest < Homebrew::TestCase
HOMEBREW_CELLAR.chmod mod
end
- def test_check_access_prefix_opt
- opt = HOMEBREW_PREFIX.join("opt")
- opt.mkpath
- opt.chmod 0555
-
- assert_match "#{opt} isn't writable.",
- @checks.check_access_prefix_opt
- ensure
- opt.unlink
- end
-
def test_check_homebrew_prefix
# the integration tests are run in a special prefix
assert_match "Your Homebrew is not installed to /usr/local",