From 59d5a246e7d7d86ee3535bc72a2fcef320ae6e90 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 4 Sep 2012 23:04:01 -0500 Subject: [PATCH] Clean up MacOS version method usage The MacOS.version? family of methods (other than "leopard?") are poorly defined and lead to confusing code. Replace them in formulae with more explicit comparisons. "MacOS.version" is a special version object that can be compared to numerics, symbols, and strings using the standard Ruby comparison methods. The old methods were moved to compat when the version comparison code was merged, and they must remain there "forever", but they should not be used in new code. Signed-off-by: Jack Nagel --- Library/Homebrew/compat/compatibility.rb | 1 + Library/Homebrew/macos.rb | 4 +++- Library/Homebrew/superenv.rb | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/compat/compatibility.rb b/Library/Homebrew/compat/compatibility.rb index aff8e0be99..b6e01b290c 100644 --- a/Library/Homebrew/compat/compatibility.rb +++ b/Library/Homebrew/compat/compatibility.rb @@ -165,6 +165,7 @@ class FailsWithLLVM end end +# TODO eventually some of these should print deprecation warnings module MacOS extend self def xcode_folder Xcode.folder diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index a58f980b04..e186760b35 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -1,5 +1,7 @@ module MacOS extend self + # This can be compared to numerics, strings, or symbols + # using the standard Ruby Comparable methods. def version require 'version' MacOSVersion.new(MACOS_VERSION.to_s) @@ -221,7 +223,7 @@ module MacOS extend self def bottles_supported? # We support bottles on all versions of OS X except 32-bit Snow Leopard. - (Hardware.is_64_bit? or not MacOS.snow_leopard?) \ + (Hardware.is_64_bit? or not MacOS.version >= :snow_leopard) \ and HOMEBREW_PREFIX.to_s == '/usr/local' \ and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar' \ end diff --git a/Library/Homebrew/superenv.rb b/Library/Homebrew/superenv.rb index 96606d1081..bdc271c3ef 100644 --- a/Library/Homebrew/superenv.rb +++ b/Library/Homebrew/superenv.rb @@ -119,7 +119,7 @@ class << ENV # we put our paths before X because we dupe some of the X libraries paths << "#{MacSystem.x11_prefix}/lib/pkgconfig" << "#{MacSystem.x11_prefix}/share/pkgconfig" if x11? # Mountain Lion no longer ships some .pcs; ensure we pick up our versions - paths << "#{HOMEBREW_REPOSITORY}/Library/Homebrew/pkgconfig" if MacOS.mountain_lion? + paths << "#{HOMEBREW_REPOSITORY}/Library/Homebrew/pkgconfig" if MacOS.version >= :mountain_lion paths.to_path_s end @@ -173,9 +173,9 @@ class << ENV s = "" s << 'b' if ARGV.build_bottle? # Fix issue with sed barfing on unicode characters on Mountain Lion - s << 's' if MacOS.mountain_lion? + s << 's' if MacOS.version >= :mountain_lion # Fix issue with 10.8 apr-1-config having broken paths - s << 'a' if MacOS.cat == :mountainlion + s << 'a' if MacOS.version == :mountain_lion s end