Change versioned bottle syntax and fix issues.
Fixed Homebrew/homebrew#11562.
This commit is contained in:
		
							parent
							
								
									11f382705c
								
							
						
					
					
						commit
						ebe4e07fa3
					
				@ -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? and bottle_current?(f)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
def built_bottle? f
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user