Add OS.mac? and OS.linux?
This commit is contained in:
		
							parent
							
								
									45e7f0ccb0
								
							
						
					
					
						commit
						c511d7d2f4
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -384,7 +384,7 @@ class FormulaInstaller
 | 
			
		||||
      link
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    fix_install_names
 | 
			
		||||
    fix_install_names if OS.mac?
 | 
			
		||||
 | 
			
		||||
    record_cxx_stdlib
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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"]
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								Library/Homebrew/os.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Library/Homebrew/os.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
module OS
 | 
			
		||||
  def self.mac?
 | 
			
		||||
    /darwin/i === RUBY_PLATFORM
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.linux?
 | 
			
		||||
    /linux/i === RUBY_PLATFORM
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user