Support bottles for non-Lion OSX versions.

This commit is contained in:
Mike McQuaid 2012-03-07 20:44:19 -05:00
parent 22f908d520
commit 4a306f32f4
7 changed files with 46 additions and 13 deletions

View File

@ -3,7 +3,7 @@ require 'tab'
module Homebrew extend self module Homebrew extend self
def formula_bottle_name f def formula_bottle_name f
"#{f.name}-#{f.version}-bottle.tar.gz" "#{f.name}-#{f.version}.#{MacOS.cat}.bottle.tar.gz"
end end
def bottle_formula f def bottle_formula f

View File

@ -191,7 +191,7 @@ end
class CurlBottleDownloadStrategy < CurlDownloadStrategy class CurlBottleDownloadStrategy < CurlDownloadStrategy
def initialize url, name, version, specs def initialize url, name, version, specs
super super
@tarball_path = HOMEBREW_CACHE/"#{name}-#{version}.bottle#{ext}" @tarball_path = HOMEBREW_CACHE/"#{name}-#{version}.#{MacOS.cat}.bottle#{ext}"
end end
def stage def stage
ohai "Pouring #{File.basename(@tarball_path)}" ohai "Pouring #{File.basename(@tarball_path)}"

View File

@ -100,7 +100,9 @@ class Pathname
# extended to support common double extensions # extended to support common double extensions
def extname 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 /(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s
return $1 if $1 return $1 if $1
return File.extname(to_s) return File.extname(to_s)
@ -205,19 +207,14 @@ class Pathname
/_((\d+\.)+\d+[abc]?)[.]orig$/.match stem /_((\d+\.)+\d+[abc]?)[.]orig$/.match stem
return $1 if $1 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. otp_src_R13B (this is erlang's style)
# eg. astyle_1.23_macosx.tar.gz # eg. astyle_1.23_macosx.tar.gz
stem.scan(/_([^_]+)/) do |match| stem.scan(/_([^_]+)/) do |match|
return match.first if /\d/.match $1 return match.first if /\d/.match $1
end end
# erlang bottle style, booya # old erlang bottle style e.g. erlang-R14B03-bottle.tar.gz
# e.g. erlang-R14B03-bottle.tar.gz /-([^-]+)/.match stem
/-([^-]+)-bottle$/.match stem
return $1 if $1 return $1 if $1
nil nil

View File

@ -64,6 +64,13 @@ class Formula
return false return false
end 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? def bottle_up_to_date?
!bottle_url.nil? && Pathname.new(bottle_url).version == version !bottle_url.nil? && Pathname.new(bottle_url).version == version
end end

View File

@ -15,7 +15,7 @@ class FormulaInstaller
@f = ff @f = ff
@show_header = true @show_header = true
@ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive? @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 check_install_sanity
end end

View File

@ -165,10 +165,25 @@ class VersionTests < Test::Unit::TestCase
end end
def test_bottle_style 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' '4.7.3'
end 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 def test_imagemagick_bottle_style
check 'http://downloads.sf.net/project/machomebrew/Bottles/imagemagick-6.7.1-1-bottle.tar.gz', check 'http://downloads.sf.net/project/machomebrew/Bottles/imagemagick-6.7.1-1-bottle.tar.gz',
'6.7.1-1' '6.7.1-1'

View File

@ -264,6 +264,20 @@ module MacOS extend self
MACOS_VERSION MACOS_VERSION
end 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 def dev_tools_path
@dev_tools_path ||= if File.file? "/usr/bin/cc" and File.file? "/usr/bin/make" @dev_tools_path ||= if File.file? "/usr/bin/cc" and File.file? "/usr/bin/make"
# probably a safe enough assumption # probably a safe enough assumption
@ -491,7 +505,7 @@ module MacOS extend self
end end
def bottles_supported? 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
end end