diff options
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/cmds/brew-man | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/doctor.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/versions.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/global.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 18 |
7 files changed, 38 insertions, 24 deletions
diff --git a/Library/Contributions/cmds/brew-man b/Library/Contributions/cmds/brew-man index 8afe2029d..a646427dc 100755 --- a/Library/Contributions/cmds/brew-man +++ b/Library/Contributions/cmds/brew-man @@ -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' && { diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index 7c1d2e93d..4db70cb32 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -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 diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index aacd68fc5..383c0121f 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -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') diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index 6c13e741a..ba312ab6f 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -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? diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 7aa31ad1f..5e91ac11b 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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? diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 9550729b1..2da57df50 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -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' diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index b335c45ea..9b1980149 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -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 |
