aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2016-09-09 09:29:46 +0100
committerGitHub2016-09-09 09:29:46 +0100
commitb5a6b4e8e15ec5110d3ac15543990f22c5abe7b4 (patch)
tree0c0d2a1d8937d81bb983f4e5227d04747d70627d /Library/Homebrew
parent930bcb7c52523a1e03a1de132192ad4cdd74ce7a (diff)
parent492391f5feb5b7d2c33973729d8243f1909078f6 (diff)
downloadbrew-b5a6b4e8e15ec5110d3ac15543990f22c5abe7b4.tar.bz2
Merge pull request #896 from MikeMcQuaid/no-chown-usr-local
Don't require/recommend ownership of /usr/local.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cmd/update.sh9
-rw-r--r--Library/Homebrew/diagnostic.rb42
2 files changed, 34 insertions, 17 deletions
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh
index c87c16a11..ee6048ca8 100644
--- a/Library/Homebrew/cmd/update.sh
+++ b/Library/Homebrew/cmd/update.sh
@@ -349,12 +349,13 @@ EOS
fi
# check permissions
- if [[ "$HOMEBREW_PREFIX" = "/usr/local" && ! -w /usr/local ]]
+ if [[ -e "$HOMEBREW_CELLAR" && ! -w "$HOMEBREW_CELLAR" ]]
then
odie <<EOS
-/usr/local is not writable. You should change the ownership
-and permissions of /usr/local back to your user account:
- sudo chown -R \$(whoami) /usr/local
+$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
fi
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index 230c96bfc..c064e9169 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -324,21 +324,37 @@ module Homebrew
EOS
end
- def check_access_usr_local
- return unless HOMEBREW_PREFIX.to_s == "/usr/local"
- return if HOMEBREW_PREFIX.writable_real?
+ def check_access_homebrew_cellar
+ return if HOMEBREW_CELLAR.writable_real?
<<-EOS.undent
- /usr/local is not writable.
- Even if this directory was writable when you installed Homebrew, other
- software may change permissions on this directory. For example, upgrading
- to OS X El Capitan has been known to do this. Some versions of the
- "InstantOn" component of Airfoil or running Cocktail cleanup/optimizations
- are known to do this as well.
-
- You should change the ownership and permissions of /usr/local back to
- your user account.
- sudo chown -R $(whoami) /usr/local
+ #{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
+ not_writable_dirs = []
+
+ (Keg::TOP_LEVEL_DIRECTORIES + ["opt"]).each do |dir|
+ path = HOMEBREW_PREFIX/dir
+ next unless path.exist?
+ next if path.writable_real?
+ not_writable_dirs << path
+ end
+
+ return if not_writable_dirs.empty?
+
+ <<-EOS.undent
+ The following directories are not writable:
+ #{not_writable_dirs.join("\n")}
+
+ 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