aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Howell2012-03-13 23:33:30 +0000
committerMax Howell2012-03-14 00:05:46 +0000
commit6ded0d0cbbde5fcd387a6ad75f6e44d83899ef51 (patch)
treee40161f8f463e8c475ab7e43ead82705a322fc61
parentb8edc0cd73efe441cf9cdf52416195fdcc6b1df0 (diff)
downloadbrew-6ded0d0cbbde5fcd387a6ad75f6e44d83899ef51.tar.bz2
Use /Library/Caches/Homebrew
We don't penalise existing users; if ~/Library/Caches/Homebrew already exists and is writable, we select that. This is the correct choice, the cache should be the same directory whichever user is used and whatever instance of brew is invoked. The Cache directory is set to 0777 this allows any user to write to it and fixes Homebrew/homebrew#10857.
-rw-r--r--Library/Homebrew/global.rb25
1 files changed, 16 insertions, 9 deletions
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index c53160fe7..573b199e3 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -13,22 +13,29 @@ def cache
if ENV['HOMEBREW_CACHE']
Pathname.new(ENV['HOMEBREW_CACHE'])
else
- root_library = Pathname.new("/Library/Caches/Homebrew")
- if Process.uid == 0
- root_library
+ # we do this for historic reasons, however the cache *should* be the same
+ # directory whichever user is used and whatever instance of brew is executed
+ home_cache = Pathname.new("~/Library/Caches/Homebrew").expand_path
+ if home_cache.directory? and home_cache.writable?
+ home_cache
else
- home_library = Pathname.new("~/Library/Caches/Homebrew").expand_path
- if not home_library.writable?
- root_library
- else
- home_library
+ root_cache = Pathname.new("/Library/Caches/Homebrew")
+ class << root_cache
+ alias :oldmkpath :mkpath
+ def mkpath
+ unless exist?
+ oldmkpath
+ chmod 0777
+ end
+ end
end
+ root_cache
end
end
end
HOMEBREW_CACHE = cache
-undef cache
+undef cache # we use a function to prevent adding home_cache to the global scope
# Where brews installed via URL are cached
HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula"