diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 96562f6c32..4932a191b2 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -54,7 +54,7 @@ def bottle_new_revision f end def bottle_native_suffix revision=nil - ".#{MacOS.cat}#{bottle_suffix(revision)}" + ".#{bottle_tag}#{bottle_suffix(revision)}" end def bottle_suffix revision=nil @@ -63,7 +63,7 @@ def bottle_suffix revision=nil end def bottle_native_regex - /(\.#{MacOS.cat}\.bottle\.(\d+\.)?tar\.gz)$/o + /(\.#{bottle_tag}\.bottle\.(\d+\.)?tar\.gz)$/o end def bottle_regex @@ -78,3 +78,14 @@ end def bottle_url f "#{bottle_root_url(f)}/#{bottle_filename(f)}" end + +def bottle_tag + case MacOS.version + when 10.8, 10.7, 10.5 + MacOS.cat + when 10.6 + Hardware.is_64_bit? ? :snow_leopard : :snow_leopard_32 + else + Hardware::CPU.type == :ppc ? Hardware::CPU.family : MacOS.cat + end +end diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index 5f45013924..8019f6c0ee 100644 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -66,7 +66,7 @@ module Homebrew extend self puts " prefix #{prefix}" if prefix puts " cellar #{cellar}" if cellar puts " revision #{bottle_revision}" if bottle_revision > 0 - puts " sha1 '#{sha1}' => :#{MacOS.cat}" + puts " sha1 '#{sha1}' => :#{bottle_tag}" puts "end" end end diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index f1eebd1d79..54f00f2623 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -98,8 +98,8 @@ class Bottle < SoftwareSpec @#{cksum}[value] = Checksum.new(:#{cksum}, key) end - if @#{cksum}.has_key? MacOS.cat - @checksum = @#{cksum}[MacOS.cat] + if @#{cksum}.has_key? bottle_tag + @checksum = @#{cksum}[bottle_tag] end end EOS diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index bd44ef7abf..b0320c9f46 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -10,21 +10,12 @@ module MacOS extend self end def cat - @cat ||= uncached_cat - end - - def uncached_cat case MacOS.version - when 10.8 - :mountain_lion - when 10.7 - :lion - when 10.6 - Hardware.is_64_bit? ? :snow_leopard : :snow_leopard_32 - when 10.5 - :leopard - else - Hardware::CPU.family if Hardware::CPU.type == :ppc + when 10.8 then :mountain_lion + when 10.7 then :lion + when 10.6 then :snow_leopard + when 10.5 then :leopard + when 10.4 then :tiger end end diff --git a/Library/Homebrew/test/test_bottle_tag.rb b/Library/Homebrew/test/test_bottle_tag.rb new file mode 100644 index 0000000000..50028c164e --- /dev/null +++ b/Library/Homebrew/test/test_bottle_tag.rb @@ -0,0 +1,44 @@ +require 'testing_env' +require 'bottles' + +class BottleTagTests < Test::Unit::TestCase + def test_cat_tiger_ppc + MacOS.stubs(:version).returns(MacOS::Version.new(10.4)) + Hardware::CPU.stubs(:type).returns(:ppc) + Hardware::CPU.stubs(:family).returns(:foo) + assert_equal :foo, bottle_tag + end + + def test_cat_tiger_intel + MacOS.stubs(:version).returns(MacOS::Version.new(10.4)) + Hardware::CPU.stubs(:type).returns(:intel) + assert_equal :tiger, bottle_tag + end + + def test_cat_leopard + MacOS.stubs(:version).returns(MacOS::Version.new(10.5)) + assert_equal :leopard, bottle_tag + end + + def test_cat_snow_leopard_32 + MacOS.stubs(:version).returns(MacOS::Version.new(10.6)) + Hardware.stubs(:is_64_bit?).returns(false) + assert_equal :snow_leopard_32, bottle_tag + end + + def test_cat_snow_leopard_64 + MacOS.stubs(:version).returns(MacOS::Version.new(10.6)) + Hardware.stubs(:is_64_bit?).returns(true) + assert_equal :snow_leopard, bottle_tag + end + + def test_cat_lion + MacOS.stubs(:version).returns(MacOS::Version.new(10.7)) + assert_equal :lion, bottle_tag + end + + def test_cat_mountain_lion + MacOS.stubs(:version).returns(MacOS::Version.new(10.8)) + assert_equal :mountain_lion, bottle_tag + end +end diff --git a/Library/Homebrew/test/test_version_subclasses.rb b/Library/Homebrew/test/test_version_subclasses.rb index a855f9df5e..6b18246ba2 100644 --- a/Library/Homebrew/test/test_version_subclasses.rb +++ b/Library/Homebrew/test/test_version_subclasses.rb @@ -39,38 +39,4 @@ class MacOSVersionTests < Test::Unit::TestCase assert_operator @v, :===, Version.new(10.7) assert_operator @v, :<, Version.new(10.8) end - - def test_cat_tiger - MacOS.stubs(:version).returns(MacOS::Version.new(10.4)) - Hardware::CPU.stubs(:type).returns(:ppc) - Hardware::CPU.stubs(:family).returns(:foo) - assert_equal :foo, MacOS.uncached_cat - end - - def test_cat_leopard - MacOS.stubs(:version).returns(MacOS::Version.new(10.5)) - assert_equal :leopard, MacOS.uncached_cat - end - - def test_cat_snow_leopard_32 - MacOS.stubs(:version).returns(MacOS::Version.new(10.6)) - Hardware.stubs(:is_64_bit?).returns(false) - assert_equal :snow_leopard_32, MacOS.uncached_cat - end - - def test_cat_snow_leopard_64 - MacOS.stubs(:version).returns(MacOS::Version.new(10.6)) - Hardware.stubs(:is_64_bit?).returns(true) - assert_equal :snow_leopard, MacOS.uncached_cat - end - - def test_cat_lion - MacOS.stubs(:version).returns(MacOS::Version.new(10.7)) - assert_equal :lion, MacOS.uncached_cat - end - - def test_cat_mountain_lion - MacOS.stubs(:version).returns(MacOS::Version.new(10.8)) - assert_equal :mountain_lion, MacOS.uncached_cat - end end