diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 03273fc888..09c36ae68e 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -224,7 +224,7 @@ module Stdenv end def macosxsdk version=MacOS.version - return unless MACOS + return unless OS.mac? # Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS. remove_macosxsdk version = version.to_s diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index f09a2d6eb2..a7b233cf39 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -384,7 +384,7 @@ class FormulaInstaller link end - fix_install_names + fix_install_names if OS.mac? record_cxx_stdlib diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 36e5cf992a..dc809021d0 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -5,6 +5,7 @@ require 'extend/ARGV' require 'extend/string' require 'extend/symbol' require 'extend/enumerable' +require 'os' require 'utils' require 'exceptions' require 'set' @@ -72,11 +73,9 @@ if RUBY_PLATFORM =~ /darwin/ MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp MACOS_VERSION = MACOS_FULL_VERSION[/10\.\d+/].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_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"] diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index 44642d44fe..0a52d10dbc 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -1,3 +1,5 @@ +require 'os' + class Hardware module CPU extend self INTEL_32BIT_ARCHS = [:i386].freeze @@ -30,11 +32,10 @@ class Hardware end end - case RUBY_PLATFORM.downcase - when /darwin/ + if OS.mac? require 'os/mac/hardware' CPU.extend MacCPUs - when /linux/ + elsif OS.linux? require 'os/linux/hardware' CPU.extend LinuxCPUs else diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb index c9ff7b4bc9..694daaba8a 100644 --- a/Library/Homebrew/keg_fix_install_names.rb +++ b/Library/Homebrew/keg_fix_install_names.rb @@ -1,6 +1,5 @@ class Keg def fix_install_names options={} - return unless MACOS mach_o_files.each do |file| install_names_for(file, options) do |id, bad_names| file.ensure_writable do diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index b3e4b6452b..1caaa8b43d 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -253,7 +253,7 @@ module MacOS extend self end def mdfind id - return [] unless MACOS + return [] unless OS.mac? (@mdfind ||= {}).fetch(id.to_s) do |key| @mdfind[key] = `/usr/bin/mdfind "kMDItemCFBundleIdentifier == '#{key}'"`.split("\n") end diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb new file mode 100644 index 0000000000..e16c81c7de --- /dev/null +++ b/Library/Homebrew/os.rb @@ -0,0 +1,9 @@ +module OS + def self.mac? + /darwin/i === RUBY_PLATFORM + end + + def self.linux? + /linux/i === RUBY_PLATFORM + end +end diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 1279be1d1f..0472f73ab5 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -84,7 +84,7 @@ module MacOS::Xcode extend self # This is a separate function as you can't cache the value out of a block # if return is used in the middle, which we do many times in here. - return "0" unless MACOS + return "0" unless OS.mac? # this shortcut makes version work for people who don't realise you # need to install the CLI tools diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 9bc5d871fb..a7b25aa200 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -29,7 +29,6 @@ HOMEBREW_VERSION = '0.9-test' RUBY_BIN = Pathname.new(RbConfig::CONFIG['bindir']) RUBY_PATH = RUBY_BIN + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT'] -MACOS = true MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] }.to_f diff --git a/Library/brew.rb b/Library/brew.rb index 1ec1ad4c00..b72d61494f 100755 --- a/Library/brew.rb +++ b/Library/brew.rb @@ -35,7 +35,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 and MACOS_VERSION < 10.5 +if OS.mac? and MacOS.version < 10.5 abort <<-EOABORT.undent Homebrew requires Leopard or higher. For Tiger support, see: https://github.com/mistydemeo/tigerbrew