mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Set MACOS_VERSION as 0 on non-OSX platforms.
This commit is contained in:
parent
e33937a1e3
commit
23b84ef732
@ -24,7 +24,7 @@ test "$1" = '-l' && {
|
||||
exit 0
|
||||
}
|
||||
|
||||
/usr/bin/which -s ronn || die "You need to \"gem install ronn\" and put it in your path."
|
||||
/usr/bin/which ronn &>/dev/null || die "You need to \"gem install ronn\" and put it in your path."
|
||||
|
||||
test "$1" = '--server' || \
|
||||
test "$1" = '-s' && {
|
||||
|
@ -624,7 +624,7 @@ def check_for_multiple_volumes
|
||||
end
|
||||
|
||||
def check_for_git
|
||||
unless system "/usr/bin/which -s git" then <<-EOS.undent
|
||||
unless which_s "git" then <<-EOS.undent
|
||||
Git could not be found in your PATH.
|
||||
Homebrew uses Git for several internal functions, and some formulae use Git
|
||||
checkouts instead of stable tarballs. You may want to install Git:
|
||||
@ -634,7 +634,7 @@ def check_for_git
|
||||
end
|
||||
|
||||
def check_git_newline_settings
|
||||
return unless system "/usr/bin/which -s git"
|
||||
return unless which_s "git"
|
||||
|
||||
autocrlf = `git config --get core.autocrlf`.chomp
|
||||
safecrlf = `git config --get core.safecrlf`.chomp
|
||||
@ -765,7 +765,7 @@ def check_missing_deps
|
||||
end
|
||||
|
||||
def check_git_status
|
||||
return unless system "/usr/bin/which -s git"
|
||||
return unless which_s "git"
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
unless `git status -s -- Library/Homebrew/ 2>/dev/null`.chomp.empty? then <<-EOS.undent
|
||||
You have uncommitted modifications to Homebrew's core.
|
||||
@ -794,7 +794,7 @@ end
|
||||
|
||||
def check_git_version
|
||||
# see https://github.com/blog/642-smart-http-support
|
||||
return unless system "/usr/bin/which -s git"
|
||||
return unless which_s "git"
|
||||
`git --version`.chomp =~ /git version (\d)\.(\d)\.(\d)/
|
||||
|
||||
if $2.to_i < 6 or $2.to_i == 6 and $3.to_i < 6 then <<-EOS.undent
|
||||
@ -806,7 +806,7 @@ def check_git_version
|
||||
end
|
||||
|
||||
def check_for_enthought_python
|
||||
if system "/usr/bin/which -s enpkg" then <<-EOS.undent
|
||||
if which_s "enpkg" then <<-EOS.undent
|
||||
Enthought Python was found in your PATH.
|
||||
This can cause build problems, as this software installs its own
|
||||
copies of iconv and libxml2 into directories that are picked up by
|
||||
@ -816,7 +816,7 @@ def check_for_enthought_python
|
||||
end
|
||||
|
||||
def check_for_bad_python_symlink
|
||||
return unless system "/usr/bin/which -s python"
|
||||
return unless which_s "python"
|
||||
# Indeed Python --version outputs to stderr (WTF?)
|
||||
`python --version 2>&1` =~ /Python (\d+)\./
|
||||
unless $1 == "2" then <<-EOS.undent
|
||||
|
@ -4,7 +4,7 @@ require 'cmd/untap'
|
||||
module Homebrew extend self
|
||||
|
||||
def update
|
||||
abort "Please `brew install git' first." unless system "/usr/bin/which -s git"
|
||||
abort "Please `brew install git' first." unless which_s "git"
|
||||
|
||||
# ensure GIT_CONFIG is unset as we need to operate on .git/config
|
||||
ENV.delete('GIT_CONFIG')
|
||||
|
@ -2,7 +2,7 @@ require 'formula'
|
||||
|
||||
module Homebrew extend self
|
||||
def versions
|
||||
raise "Please `brew install git' first" unless system "/usr/bin/which -s git"
|
||||
raise "Please `brew install git` first" unless which_s "git"
|
||||
raise "Please `brew update' first" unless (HOMEBREW_REPOSITORY/".git").directory?
|
||||
|
||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||
|
@ -90,7 +90,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
||||
safe_system '/usr/bin/tar', 'xf', @tarball_path
|
||||
chdir
|
||||
when /^\xFD7zXZ\x00/ # xz compressed
|
||||
raise "You must install XZutils: brew install xz" unless system "/usr/bin/which -s xz"
|
||||
raise "You must install XZutils: brew install xz" unless which_s "xz"
|
||||
safe_system "xz -dc \"#{@tarball_path}\" | /usr/bin/tar xf -"
|
||||
chdir
|
||||
when '____pkg'
|
||||
@ -326,7 +326,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
||||
end
|
||||
|
||||
def fetch
|
||||
raise "You must install Git: brew install git" unless system "/usr/bin/which -s git"
|
||||
raise "You must install Git: brew install git" unless which_s "git"
|
||||
|
||||
ohai "Cloning #{@url}"
|
||||
|
||||
@ -447,7 +447,7 @@ class MercurialDownloadStrategy < AbstractDownloadStrategy
|
||||
def cached_location; @clone; end
|
||||
|
||||
def fetch
|
||||
raise "You must install Mercurial: brew install mercurial" unless system "/usr/bin/which -s hg"
|
||||
raise "You must install Mercurial: brew install mercurial" unless which_s "hg"
|
||||
|
||||
ohai "Cloning #{@url}"
|
||||
|
||||
@ -488,8 +488,7 @@ class BazaarDownloadStrategy < AbstractDownloadStrategy
|
||||
def cached_location; @clone; end
|
||||
|
||||
def fetch
|
||||
raise "You must install bazaar first" \
|
||||
unless system "/usr/bin/which -s bzr"
|
||||
raise "You must install bazaar first" unless which_s "bzr"
|
||||
|
||||
ohai "Cloning #{@url}"
|
||||
unless @clone.exist?
|
||||
@ -532,8 +531,7 @@ class FossilDownloadStrategy < AbstractDownloadStrategy
|
||||
def cached_location; @clone; end
|
||||
|
||||
def fetch
|
||||
raise "You must install fossil first" \
|
||||
unless system "/usr/bin/which -s fossil"
|
||||
raise "You must install fossil first" unless which_s "fossil"
|
||||
|
||||
ohai "Cloning #{@url}"
|
||||
unless @clone.exist?
|
||||
|
@ -61,10 +61,18 @@ end
|
||||
|
||||
HOMEBREW_LOGS = Pathname.new('~/Library/Logs/Homebrew/').expand_path
|
||||
|
||||
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
||||
MACOS_VERSION = /(10\.\d+)(\.\d+)?/.match(MACOS_FULL_VERSION).captures.first.to_f
|
||||
if RUBY_PLATFORM =~ /darwin/
|
||||
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
||||
MACOS_VERSION = /(10\.\d+)(\.\d+)?/.match(MACOS_FULL_VERSION).captures.first.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_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; Mac OS X #{MACOS_FULL_VERSION})"
|
||||
HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})"
|
||||
|
||||
HOMEBREW_CURL_ARGS = '-qf#LA'
|
||||
|
||||
|
@ -138,7 +138,8 @@ def puts_columns items, star_items=[]
|
||||
end
|
||||
end
|
||||
|
||||
def which cmd
|
||||
def which cmd, silent=false
|
||||
cmd += " 2>/dev/null" if silent
|
||||
path = `/usr/bin/which #{cmd}`.chomp
|
||||
if path.empty?
|
||||
nil
|
||||
@ -147,15 +148,19 @@ def which cmd
|
||||
end
|
||||
end
|
||||
|
||||
def which_s cmd
|
||||
which cmd, true
|
||||
end
|
||||
|
||||
def which_editor
|
||||
editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR']
|
||||
# If an editor wasn't set, try to pick a sane default
|
||||
return editor unless editor.nil?
|
||||
|
||||
# Find Textmate
|
||||
return 'mate' if system "/usr/bin/which -s mate"
|
||||
return 'mate' if which_s "mate"
|
||||
# Find # BBEdit / TextWrangler
|
||||
return 'edit' if system "/usr/bin/which -s edit"
|
||||
return 'edit' if which_s "edit"
|
||||
# Default to vim
|
||||
return '/usr/bin/vim'
|
||||
end
|
||||
@ -378,6 +383,8 @@ module MacOS extend self
|
||||
|
||||
def xcode_version
|
||||
@xcode_version ||= begin
|
||||
return "0" unless MACOS
|
||||
|
||||
# this shortcut makes xcode_version work for people who don't realise you
|
||||
# need to install the CLI tools
|
||||
xcode43build = "/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild"
|
||||
@ -389,7 +396,7 @@ module MacOS extend self
|
||||
# Xcode 4.3 xc* tools hang indefinately if xcode-select path is set thus
|
||||
raise if `xcode-select -print-path 2>/dev/null`.chomp == "/"
|
||||
|
||||
raise unless system "/usr/bin/which -s xcodebuild"
|
||||
raise unless which_s "xcodebuild"
|
||||
`xcodebuild -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/
|
||||
raise if $1.nil? or not $?.success?
|
||||
$1
|
||||
@ -468,9 +475,10 @@ module MacOS extend self
|
||||
# http://github.com/mxcl/homebrew/issues/#issue/13
|
||||
# http://github.com/mxcl/homebrew/issues/#issue/41
|
||||
# http://github.com/mxcl/homebrew/issues/#issue/48
|
||||
return false unless MACOS
|
||||
|
||||
%w[port fink].each do |ponk|
|
||||
path = `/usr/bin/which -s #{ponk}`
|
||||
path = `/usr/bin/which #{ponk} 2>/dev/null`
|
||||
return ponk unless path.empty?
|
||||
end
|
||||
|
||||
|
4
bin/brew
4
bin/brew
@ -31,7 +31,7 @@ case HOMEBREW_PREFIX.to_s when '/', '/usr'
|
||||
# it may work, but I only see pain this route and don't want to support it
|
||||
abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
|
||||
end
|
||||
if MACOS_VERSION < 10.5
|
||||
if MACOS and MACOS_VERSION < 10.5
|
||||
abort <<-EOABORT.undent
|
||||
Homebrew requires Leopard or higher. For Tiger support, see:
|
||||
http://github.com/sceaga/homebrew/tree/tiger
|
||||
@ -72,7 +72,7 @@ begin
|
||||
|
||||
# Add example external commands to PATH before checking.
|
||||
ENV['PATH'] += ":#{HOMEBREW_REPOSITORY}/Library/Contributions/cmds"
|
||||
if system "/usr/bin/which -s brew-#{cmd}"
|
||||
if which_s "brew-#{cmd}"
|
||||
%w[CACHE CELLAR LIBRARY_PATH PREFIX REPOSITORY].each do |e|
|
||||
ENV["HOMEBREW_#{e}"] = Object.const_get "HOMEBREW_#{e}"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user