2013-06-04 11:05:02 -05:00
|
|
|
require 'extend/module'
|
2012-09-27 16:22:01 -05:00
|
|
|
require 'extend/fileutils'
|
2009-10-15 12:36:09 +01:00
|
|
|
require 'extend/pathname'
|
|
|
|
require 'extend/ARGV'
|
2010-02-27 17:26:27 +00:00
|
|
|
require 'extend/string'
|
2013-01-09 17:36:17 -06:00
|
|
|
require 'extend/symbol'
|
2013-06-07 22:27:29 -05:00
|
|
|
require 'extend/enumerable'
|
2009-09-04 15:28:18 +01:00
|
|
|
require 'utils'
|
2010-09-11 20:22:54 +01:00
|
|
|
require 'exceptions'
|
2012-08-12 00:58:31 -05:00
|
|
|
require 'set'
|
2013-03-10 17:02:06 +00:00
|
|
|
require 'rbconfig'
|
2009-09-04 15:28:18 +01:00
|
|
|
|
2009-10-15 12:36:09 +01:00
|
|
|
ARGV.extend(HomebrewArgvExtension)
|
|
|
|
|
2013-09-19 23:10:09 -07:00
|
|
|
HOMEBREW_VERSION = '0.9.5'
|
2013-04-06 15:50:23 -05:00
|
|
|
HOMEBREW_WWW = 'http://brew.sh'
|
2009-10-15 12:36:09 +01:00
|
|
|
|
2012-03-07 12:51:02 +00:00
|
|
|
def cache
|
|
|
|
if ENV['HOMEBREW_CACHE']
|
|
|
|
Pathname.new(ENV['HOMEBREW_CACHE'])
|
|
|
|
else
|
2012-03-13 23:33:30 +00:00
|
|
|
# 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
|
2012-07-28 11:36:08 -07:00
|
|
|
if home_cache.directory? and home_cache.writable_real?
|
2012-03-13 23:33:30 +00:00
|
|
|
home_cache
|
2012-03-07 12:51:02 +00:00
|
|
|
else
|
2012-03-13 23:33:30 +00:00
|
|
|
root_cache = Pathname.new("/Library/Caches/Homebrew")
|
|
|
|
class << root_cache
|
|
|
|
alias :oldmkpath :mkpath
|
|
|
|
def mkpath
|
|
|
|
unless exist?
|
|
|
|
oldmkpath
|
|
|
|
chmod 0777
|
|
|
|
end
|
|
|
|
end
|
2012-03-07 12:51:02 +00:00
|
|
|
end
|
2012-03-13 23:33:30 +00:00
|
|
|
root_cache
|
2012-03-07 12:51:02 +00:00
|
|
|
end
|
|
|
|
end
|
2009-09-04 15:28:18 +01:00
|
|
|
end
|
|
|
|
|
2012-03-07 12:51:02 +00:00
|
|
|
HOMEBREW_CACHE = cache
|
2012-03-13 23:33:30 +00:00
|
|
|
undef cache # we use a function to prevent adding home_cache to the global scope
|
2012-03-07 12:51:02 +00:00
|
|
|
|
2011-06-08 11:13:50 -07:00
|
|
|
# Where brews installed via URL are cached
|
|
|
|
HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula"
|
|
|
|
|
2009-11-07 18:09:48 +00:00
|
|
|
if not defined? HOMEBREW_BREW_FILE
|
2013-03-21 08:17:26 -05:00
|
|
|
HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE'] || which('brew').to_s
|
2009-11-07 18:09:48 +00:00
|
|
|
end
|
|
|
|
|
2009-11-07 18:08:26 +00:00
|
|
|
HOMEBREW_PREFIX = Pathname.new(HOMEBREW_BREW_FILE).dirname.parent # Where we link under
|
|
|
|
HOMEBREW_REPOSITORY = Pathname.new(HOMEBREW_BREW_FILE).realpath.dirname.parent # Where .git is found
|
2012-03-16 12:59:27 +00:00
|
|
|
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY/"Library"
|
2012-08-20 13:57:01 -05:00
|
|
|
HOMEBREW_CONTRIB = HOMEBREW_REPOSITORY/"Library/Contributions"
|
2009-10-27 13:27:36 -07:00
|
|
|
|
2010-06-29 13:53:57 -07:00
|
|
|
# Where we store built products; /usr/local/Cellar if it exists,
|
|
|
|
# otherwise a Cellar relative to the Repository.
|
2010-12-31 11:00:15 -08:00
|
|
|
HOMEBREW_CELLAR = if (HOMEBREW_PREFIX+"Cellar").exist?
|
|
|
|
HOMEBREW_PREFIX+"Cellar"
|
2009-10-27 13:27:36 -07:00
|
|
|
else
|
2010-12-31 11:00:15 -08:00
|
|
|
HOMEBREW_REPOSITORY+"Cellar"
|
2009-10-27 13:27:36 -07:00
|
|
|
end
|
2009-09-30 02:36:21 -04:00
|
|
|
|
2012-03-07 18:44:05 -08:00
|
|
|
HOMEBREW_LOGS = Pathname.new('~/Library/Logs/Homebrew/').expand_path
|
|
|
|
|
2013-07-28 16:43:22 -05:00
|
|
|
RUBY_BIN = Pathname.new(RbConfig::CONFIG['bindir'])
|
2013-04-07 18:40:17 -05:00
|
|
|
RUBY_PATH = RUBY_BIN + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']
|
2013-03-10 17:02:06 +00:00
|
|
|
|
2012-03-16 15:14:20 +13:00
|
|
|
if RUBY_PLATFORM =~ /darwin/
|
|
|
|
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
2013-06-14 19:16:11 -05:00
|
|
|
MACOS_VERSION = MACOS_FULL_VERSION[/10\.\d+/].to_f
|
2012-03-16 15:14:20 +13:00
|
|
|
OS_VERSION = "Mac OS X #{MACOS_FULL_VERSION}"
|
|
|
|
MACOS = true
|
|
|
|
else
|
|
|
|
MACOS_FULL_VERSION = MACOS_VERSION = 0
|
|
|
|
OS_VERSION = RUBY_PLATFORM
|
|
|
|
MACOS = false
|
|
|
|
end
|
2009-09-16 11:28:50 +01:00
|
|
|
|
2013-05-18 08:27:22 -04:00
|
|
|
HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
2012-03-16 15:14:20 +13:00
|
|
|
HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})"
|
2009-11-05 21:37:51 +00:00
|
|
|
|
2012-10-08 14:00:20 +13:00
|
|
|
HOMEBREW_CURL_ARGS = '-f#LA'
|
2009-11-05 21:37:51 +00:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
module Homebrew extend self
|
|
|
|
include FileUtils
|
2012-03-15 10:57:34 +13:00
|
|
|
|
|
|
|
attr_accessor :failed
|
|
|
|
alias_method :failed?, :failed
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
2012-09-09 13:19:53 -07:00
|
|
|
require 'metafiles'
|
|
|
|
FORMULA_META_FILES = Metafiles.new
|
2012-09-28 19:20:34 +01:00
|
|
|
ISSUES_URL = "https://github.com/mxcl/homebrew/wiki/troubleshooting"
|
2013-06-02 12:48:57 +01:00
|
|
|
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = 'https:\/\/github.com\/(\w+)\/homebrew(-\w+)?\/(pull\/(\d+)|commit\/\w{4,40})'
|
2011-08-02 12:00:30 +01:00
|
|
|
|
2013-05-09 23:53:26 -05:00
|
|
|
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
|
Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2012-02-26 21:04:15 +01:00
|
|
|
|
2013-08-15 21:50:13 +02:00
|
|
|
ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
|
2013-06-08 18:17:28 -07:00
|
|
|
|
|
|
|
SUDO_BAD_ERRMSG = <<-EOS.undent
|
|
|
|
You can use brew with sudo, but only if the brew executable is owned by root.
|
|
|
|
However, this is both not recommended and completely unsupported so do so at
|
|
|
|
your own risk.
|
|
|
|
EOS
|