Skip to content

Commit

Permalink
Change versioned bottle syntax and fix issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Apr 24, 2012
1 parent 5052a43 commit ffea2d2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
20 changes: 10 additions & 10 deletions Library/Homebrew/bottles.rb
Expand Up @@ -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?
Expand All @@ -15,7 +14,7 @@ def bottles_supported?

def install_bottle? f
return true if ARGV.include? '--install-bottle'
!ARGV.build_from_source? && bottle_current?(f)
not ARGV.build_from_source? and bottle_current?(f)
end

def built_bottle? f
Expand All @@ -31,24 +30,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
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/download_strategy.rb
Expand Up @@ -194,8 +194,10 @@ def initialize url, name, version, specs
@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
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/extend/pathname.rb
Expand Up @@ -119,7 +119,6 @@ def cp dst
# 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
Expand Down
19 changes: 17 additions & 2 deletions Library/Homebrew/test/test_versions.rb
Expand Up @@ -169,6 +169,11 @@ def test_bottle_style
'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'
Expand All @@ -184,9 +189,19 @@ def test_old_erlang_bottle_style
'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
Expand Down

0 comments on commit ffea2d2

Please sign in to comment.