aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/bottles.rb17
-rw-r--r--Library/Homebrew/cmd/bottle.rb2
-rw-r--r--Library/Homebrew/formula.rb2
-rw-r--r--Library/Homebrew/software_spec.rb12
-rw-r--r--Library/Homebrew/test/test_software_spec.rb4
5 files changed, 21 insertions, 16 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
index e20ffdf8e..0ea0e9c65 100644
--- a/Library/Homebrew/bottles.rb
+++ b/Library/Homebrew/bottles.rb
@@ -3,11 +3,11 @@ require 'os/mac'
require 'extend/ARGV'
require 'bottle_version'
-def bottle_filename f, bottle_revision=nil
+def bottle_filename f, options={:tag=>bottle_tag, :bottle_revision=>nil}
name = f.name.downcase
version = f.stable.version
bottle_revision ||= f.bottle.revision.to_i if f.bottle
- "#{name}-#{version}#{bottle_native_suffix(bottle_revision)}"
+ "#{name}-#{version}#{bottle_native_suffix(options)}"
end
def install_bottle? f, options={:warn=>false}
@@ -48,8 +48,8 @@ def bottle_file_outdated? f, file
bottle_ext && bottle_url_ext && bottle_ext != bottle_url_ext
end
-def bottle_native_suffix revision=nil
- ".#{bottle_tag}#{bottle_suffix(revision)}"
+def bottle_native_suffix options={:tag=>bottle_tag}
+ ".#{options[:tag]}#{bottle_suffix(options[:revision])}"
end
def bottle_suffix revision=nil
@@ -70,8 +70,8 @@ def bottle_root_url f
root_url ||= 'https://downloads.sf.net/project/machomebrew/Bottles'
end
-def bottle_url f
- "#{bottle_root_url(f)}/#{bottle_filename(f)}"
+def bottle_url f, tag=bottle_tag
+ "#{bottle_root_url(f)}/#{bottle_filename(f, {:tag => tag})}"
end
def bottle_tag
@@ -109,9 +109,12 @@ class BottleCollector
def fetch_bottle_for(tag)
return [@bottles[tag], tag] if @bottles[tag]
- find_altivec_tag(tag) || find_or_later(tag)
+ find_altivec_tag(tag) || find_or_later_tag(tag)
end
+ def keys; @bottles.keys; end
+ def [](arg); @bottles[arg]; end
+
# This allows generic Altivec PPC bottles to be supported in some
# formulae, while also allowing specific bottles in others; e.g.,
# sometimes a formula has just :tiger_altivec, other times it has
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 1db07254b..71ed7dad6 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -105,7 +105,7 @@ module Homebrew extend self
bottle_revision = -1
begin
bottle_revision += 1
- filename = bottle_filename(f, bottle_revision)
+ filename = bottle_filename(f, :tag => bottle_tag, :bottle_revision => bottle_revision)
end while not ARGV.include? '--no-revision' \
and master_bottle_filenames.include? filename
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index f9de49adb..b29df1cba 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -46,7 +46,7 @@ class Formula
# into a validation method on the bottle instance.
unless bottle.checksum.nil? || bottle.checksum.empty?
@bottle = bottle
- bottle.url ||= bottle_url(self)
+ bottle.url ||= bottle_url(self, bottle.current_tag)
end
end
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index 4a630dbc1..288db99ca 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -4,6 +4,7 @@ require 'checksum'
require 'version'
require 'build_options'
require 'dependency_collector'
+require 'bottles'
class SoftwareSpec
extend Forwardable
@@ -87,6 +88,7 @@ end
class Bottle < SoftwareSpec
attr_rw :root_url, :prefix, :cellar, :revision
+ attr_accessor :current_tag
def_delegators :@resource, :version=, :url=
@@ -103,16 +105,16 @@ class Bottle < SoftwareSpec
class_eval <<-EOS, __FILE__, __LINE__ + 1
def #{cksum}(val=nil)
return @#{cksum} if val.nil?
- @#{cksum} ||= Hash.new
+ @#{cksum} ||= BottleCollector.new
case val
when Hash
key, value = val.shift
- @#{cksum}[value] = Checksum.new(:#{cksum}, key)
+ @#{cksum}.add(Checksum.new(:#{cksum}, key), value)
end
- if @#{cksum}.has_key? bottle_tag
- @resource.checksum = @#{cksum}[bottle_tag]
- end
+ cksum, current_tag = @#{cksum}.fetch_bottle_for(bottle_tag)
+ @resource.checksum = cksum if cksum
+ @current_tag = current_tag if cksum
end
EOS
end
diff --git a/Library/Homebrew/test/test_software_spec.rb b/Library/Homebrew/test/test_software_spec.rb
index 547afa73c..42bcf73fc 100644
--- a/Library/Homebrew/test/test_software_spec.rb
+++ b/Library/Homebrew/test/test_software_spec.rb
@@ -110,8 +110,8 @@ class BottleTests < Test::Unit::TestCase
end
checksums.each_pair do |cat, sha1|
- assert_equal Checksum.new(:sha1, sha1),
- @spec.instance_variable_get(:@sha1)[cat]
+ hsh, _ = @spec.instance_variable_get(:@sha1).fetch_bottle_for(cat)
+ assert_equal Checksum.new(:sha1, sha1), hsh
end
end