diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 739f601c5b..0cd1f7bf23 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -5,8 +5,7 @@ def bottle_filename f, bottle_version=nil name = f.name.downcase version = f.version || f.standard.detect_version bottle_version = bottle_version || f.bottle_version - bottle_version_tag = bottle_version > 0 ? "-#{bottle_version}" : "" - "#{name}-#{version}#{bottle_version_tag}#{bottle_native_suffix}" + "#{name}-#{version}#{bottle_native_suffix(bottle_version)}" end def bottles_supported? @@ -15,7 +14,7 @@ end def install_bottle? f return true if ARGV.include? '--install-bottle' - !ARGV.build_from_source? && bottle_current?(f) + not ARGV.build_from_source? && bottle_current?(f) end def built_bottle? f @@ -23,6 +22,8 @@ def built_bottle? f end def bottle_current? f + puts Pathname.new(f.bottle_url).version + puts f.version f.bottle_url && f.bottle_sha1 && Pathname.new(f.bottle_url).version == f.version end @@ -31,24 +32,25 @@ def bottle_new_version f f.bottle_version + 1 end -def bottle_native_suffix - ".#{MacOS.cat}#{bottle_suffix}" +def bottle_native_suffix version=nil + ".#{MacOS.cat}#{bottle_suffix(version)}" end -def bottle_suffix - ".bottle.tar.gz" +def bottle_suffix version=nil + version = version.to_i > 0 ? ".#{version}" : "" + ".bottle#{version}.tar.gz" end def bottle_native_regex - /((-\d+)?\.#{MacOS.cat}\.bottle\.tar\.gz)$/ + /(\.#{MacOS.cat}\.bottle\.((\d+)?\.tar\.gz))$/ end def bottle_regex - /((-\d+)?\.[a-z]+\.bottle\.tar\.gz)$/ + /(\.[a-z]+\.bottle\.(\d+\.)?tar\.gz)$/ end def old_bottle_regex - /(-bottle\.tar\.gz)$/ + /((\.[a-z]+)?[\.-]bottle\.tar\.gz)$/ end def bottle_base_url diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 4c510db992..3a68a25417 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -194,8 +194,10 @@ class CurlBottleDownloadStrategy < CurlDownloadStrategy @tarball_path = HOMEBREW_CACHE/"#{name}-#{version}#{ext}" unless @tarball_path.exist? + # Stop people redownloading bottles just because I (Mike) was stupid. old_bottle_path = HOMEBREW_CACHE/"#{name}-#{version}-bottle.tar.gz" old_bottle_path = HOMEBREW_CACHE/"#{name}-#{version}.#{MacOS.cat}.bottle-bottle.tar.gz" unless old_bottle_path.exist? + old_bottle_path = HOMEBREW_CACHE/"#{name}-#{version}-7.#{MacOS.cat}.bottle.tar.gz" unless old_bottle_path.exist? or name != "imagemagick" FileUtils.mv old_bottle_path, @tarball_path if old_bottle_path.exist? end end diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 454afb0747..d705bc2f95 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -119,7 +119,6 @@ class Pathname # extended to support common double extensions def extname return $1 if to_s =~ bottle_regex - # old brew bottle style return $1 if to_s =~ old_bottle_regex /(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s return $1 if $1 diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index 44058b70a0..4c9b700458 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -169,6 +169,11 @@ class VersionTests < Test::Unit::TestCase '4.8.0' end + def test_versioned_bottle_style + check 'https://downloads.sf.net/project/machomebrew/Bottles/qt-4.8.1.lion.bottle.1.tar.gz', + '4.8.1' + end + def test_erlang_bottle_style check 'https://downloads.sf.net/project/machomebrew/Bottles/erlang-R15B.lion.bottle.tar.gz', 'R15B' @@ -184,9 +189,19 @@ class VersionTests < Test::Unit::TestCase 'R15B' end + def test_imagemagick_style + check 'http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.7.5-7.tar.bz2', + '6.7.5-7' + 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' + check 'https://downloads.sf.net/project/machomebrew/Bottles/imagemagick-6.7.5-7.lion.bottle.tar.gz', + '6.7.5-7' + end + + def test_imagemagick_versioned_bottle_style + check 'https://downloads.sf.net/project/machomebrew/Bottles/imagemagick-6.7.5-7.lion.bottle.1.tar.gz', + '6.7.5-7' end def test_dash_version_dash_style