diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index c07690a673..25160b5c6e 100755 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -3,7 +3,7 @@ require 'tab' module Homebrew extend self def formula_bottle_name f - "#{f.name}-#{f.version}-bottle.tar.gz" + "#{f.name}-#{f.version}.#{MacOS.cat}.bottle.tar.gz" end def bottle_formula f diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 8b8fcd7c5b..072aa712f5 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -191,7 +191,7 @@ end class CurlBottleDownloadStrategy < CurlDownloadStrategy def initialize url, name, version, specs super - @tarball_path = HOMEBREW_CACHE/"#{name}-#{version}.bottle#{ext}" + @tarball_path = HOMEBREW_CACHE/"#{name}-#{version}.#{MacOS.cat}.bottle#{ext}" end def stage ohai "Pouring #{File.basename(@tarball_path)}" diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 6d45d0b77f..f05fc9f5f3 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -100,7 +100,9 @@ class Pathname # extended to support common double extensions def extname - return $1 if to_s =~ /(\.bottle\.tar\.gz)$/ + return $1 if to_s =~ /(\.[a-z]+\.bottle\.tar\.gz)$/ + # old brew bottle style + return $1 if to_s =~ /(-bottle\.tar\.gz)$/ /(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s return $1 if $1 return File.extname(to_s) @@ -205,19 +207,14 @@ class Pathname /_((\d+\.)+\d+[abc]?)[.]orig$/.match stem return $1 if $1 - # brew bottle style e.g. qt-4.7.3-bottle.tar.gz - /-((\d+\.)*\d+(-\d)*)-bottle$/.match stem - return $1 if $1 - # eg. otp_src_R13B (this is erlang's style) # eg. astyle_1.23_macosx.tar.gz stem.scan(/_([^_]+)/) do |match| return match.first if /\d/.match $1 end - # erlang bottle style, booya - # e.g. erlang-R14B03-bottle.tar.gz - /-([^-]+)-bottle$/.match stem + # old erlang bottle style e.g. erlang-R14B03-bottle.tar.gz + /-([^-]+)/.match stem return $1 if $1 nil diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index eb3cd7b2e8..b3623b336c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -64,6 +64,13 @@ class Formula return false end + def bottle_for_current_osx_version? + return true if /#{MacOS.cat}\.bottle\.tar\.gz$/.match(bottle_url) + # old brew bottle style + return true if MacOS.lion? && /-bottle\.tar\.gz$/.match(bottle_url) + return false + end + def bottle_up_to_date? !bottle_url.nil? && Pathname.new(bottle_url).version == version end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 7257f72cae..82c58c9d03 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -15,7 +15,7 @@ class FormulaInstaller @f = ff @show_header = true @ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive? - @install_bottle = !ARGV.build_from_source? && ff.bottle_up_to_date? + @install_bottle = !ARGV.build_from_source? && ff.bottle_up_to_date? && ff.bottle_for_current_osx_version? check_install_sanity end diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index a86fb46fa3..50a96bd6e5 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -165,10 +165,25 @@ class VersionTests < Test::Unit::TestCase end def test_bottle_style - check 'https://downloads.sourceforge.net/project/machomebrew/Bottles/qt-4.7.3-bottle.tar.gz', + check 'https://downloads.sf.net/project/machomebrew/Bottles/qt-4.8.0.lion.bottle.tar.gz', + '4.8.0' + end + + def test_erlang_bottle_style + check 'https://downloads.sf.net/project/machomebrew/Bottles/erlang-R15B.lion.bottle.tar.gz', + 'R15B' + end + + def test_old_bottle_style + check 'https://downloads.sf.net/project/machomebrew/Bottles/qt-4.7.3-bottle.tar.gz', '4.7.3' end + def test_old_erlang_bottle_style + check 'https://downloads.sf.net/project/machomebrew/Bottles/erlang-R15B-bottle.tar.gz', + 'R15B' + end + def test_imagemagick_bottle_style check 'http://downloads.sf.net/project/machomebrew/Bottles/imagemagick-6.7.1-1-bottle.tar.gz', '6.7.1-1' diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index c088877403..f18b908b2f 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -264,6 +264,20 @@ module MacOS extend self MACOS_VERSION end + def cat + if mountain_lion? + :mountainlion + elsif lion? + :lion + elsif snow_leopard? + :snowleopard + elsif leopard? + :leopard + else + nil + end + end + def dev_tools_path @dev_tools_path ||= if File.file? "/usr/bin/cc" and File.file? "/usr/bin/make" # probably a safe enough assumption @@ -491,7 +505,7 @@ module MacOS extend self end def bottles_supported? - lion? and HOMEBREW_PREFIX.to_s == '/usr/local' and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar' + HOMEBREW_PREFIX.to_s == '/usr/local' and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar' end end