Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Commit

Permalink
When the root cache is not writable use home_cache
Browse files Browse the repository at this point in the history
The home_cache is `~/Library/Caches/Homebrew` on MacOS and
`~/.cache/Homebrew` on other systems.
Closes #17.
  • Loading branch information
sjackman committed Jul 5, 2013
1 parent e1c0c92 commit f4e8491
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,27 @@
HOMEBREW_VERSION = '0.9.4'
HOMEBREW_WWW = 'http://brew.sh'

if RUBY_PLATFORM =~ /darwin/
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
MACOS_VERSION = MACOS_FULL_VERSION[/10\.\d+/].to_f
OS_VERSION = "Mac OS X #{MACOS_FULL_VERSION}"
MACOS = true
else
MACOS_FULL_VERSION = MACOS_VERSION = 0
OS_VERSION = RUBY_PLATFORM
MACOS = false
end

def cache
if ENV['HOMEBREW_CACHE']
Pathname.new(ENV['HOMEBREW_CACHE'])
else
# 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_real?
home_cache = Pathname.new(if MACOS then "~/Library/Caches/Homebrew"
else "~/.cache/Homebrew" end).expand_path
if home_cache.directory? and home_cache.writable_real? \
or not Pathname.new('/Library/Caches').writable_real?
home_cache
else
root_cache = Pathname.new("/Library/Caches/Homebrew")
Expand Down Expand Up @@ -68,17 +81,6 @@ def mkpath
RUBY_BIN = Pathname.new("#{RbConfig::CONFIG['bindir']}")
RUBY_PATH = RUBY_BIN + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']

if RUBY_PLATFORM =~ /darwin/
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
MACOS_VERSION = MACOS_FULL_VERSION[/10\.\d+/].to_f
OS_VERSION = "Mac OS X #{MACOS_FULL_VERSION}"
MACOS = true
else
MACOS_FULL_VERSION = MACOS_VERSION = 0
OS_VERSION = RUBY_PLATFORM
MACOS = false
end

HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})"

Expand Down

0 comments on commit f4e8491

Please sign in to comment.