MacOS: full_version added

Closes Homebrew/homebrew#44988.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Baptiste Fontaine 2015-10-16 16:41:14 +08:00 committed by Xu Cheng
parent 0915f0c668
commit abfaa59e06
6 changed files with 21 additions and 12 deletions

View File

@ -770,6 +770,10 @@ class FormulaAuditor
problem "Use MacOS.version instead of MACOS_VERSION" problem "Use MacOS.version instead of MACOS_VERSION"
end end
if line =~ /MACOS_FULL_VERSION/
problem "Use MacOS.full_version instead of MACOS_FULL_VERSION"
end
cats = %w[leopard snow_leopard lion mountain_lion].join("|") cats = %w[leopard snow_leopard lion mountain_lion].join("|")
if line =~ /MacOS\.(?:#{cats})\?/ if line =~ /MacOS\.(?:#{cats})\?/
problem "\"#{$&}\" is deprecated, use a comparison to MacOS.version instead" problem "\"#{$&}\" is deprecated, use a comparison to MacOS.version instead"

View File

@ -145,7 +145,7 @@ module Homebrew
f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}"
f.puts "HOMEBREW_BOTTLE_DOMAIN: #{BottleSpecification::DEFAULT_DOMAIN}" f.puts "HOMEBREW_BOTTLE_DOMAIN: #{BottleSpecification::DEFAULT_DOMAIN}"
f.puts hardware f.puts hardware
f.puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}" f.puts "OS X: #{MacOS.full_version}-#{kernel}"
f.puts "Xcode: #{xcode ? xcode : "N/A"}" f.puts "Xcode: #{xcode ? xcode : "N/A"}"
f.puts "CLT: #{clt ? clt : "N/A"}" f.puts "CLT: #{clt ? clt : "N/A"}"
f.puts "GCC-4.0: build #{gcc_40}" if gcc_40 f.puts "GCC-4.0: build #{gcc_40}" if gcc_40

View File

@ -34,7 +34,7 @@ module Homebrew
auth = :AUTH_BASIC auth = :AUTH_BASIC
end end
url = new_issue(f.tap, "#{f.name} failed to build on #{MACOS_FULL_VERSION}", url, auth) url = new_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url, auth)
end end
puts url if url puts url if url

View File

@ -26,15 +26,6 @@ else
end end
RUBY_BIN = RUBY_PATH.dirname RUBY_BIN = RUBY_PATH.dirname
if RUBY_PLATFORM =~ /darwin/
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
MACOS_VERSION = MACOS_FULL_VERSION[/10\.\d+/]
OS_VERSION = "OS X #{MACOS_FULL_VERSION}"
else
MACOS_FULL_VERSION = MACOS_VERSION = "0"
OS_VERSION = RUBY_PLATFORM
end
HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"] HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})" HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})"

View File

@ -8,11 +8,19 @@ module OS
end end
if OS.mac? if OS.mac?
require "os/mac"
ISSUES_URL = "https://git.io/brew-troubleshooting" ISSUES_URL = "https://git.io/brew-troubleshooting"
PATH_OPEN = "/usr/bin/open" PATH_OPEN = "/usr/bin/open"
# compatibility
::MACOS_FULL_VERSION = OS::Mac.full_version.to_s
::MACOS_VERSION = OS::Mac.version.to_s
::OS_VERSION = "OS X #{MACOS_FULL_VERSION}"
elsif OS.linux? elsif OS.linux?
ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting" ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting"
PATH_OPEN = "xdg-open" PATH_OPEN = "xdg-open"
# compatibility
::MACOS_FULL_VERSION = ::MACOS_VERSION = "0"
::OS_VERSION = RUBY_PLATFORM
else else
raise "Unknown operating system" raise "Unknown operating system"
end end

View File

@ -12,7 +12,13 @@ module OS
# This can be compared to numerics, strings, or symbols # This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods. # using the standard Ruby Comparable methods.
def version def version
@version ||= Version.new(MACOS_VERSION) @version ||= Version.new(full_version.to_s[/10\.\d+/])
end
# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
def full_version
@full_version ||= Version.new(`/usr/bin/sw_vers -productVersion`.chomp)
end end
def cat def cat