Use BottleCollector in Bottle SoftwareSpec
This commit is contained in:
parent
079d0556ad
commit
e2af1cbeeb
@ -3,11 +3,11 @@ require 'os/mac'
|
|||||||
require 'extend/ARGV'
|
require 'extend/ARGV'
|
||||||
require 'bottle_version'
|
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
|
name = f.name.downcase
|
||||||
version = f.stable.version
|
version = f.stable.version
|
||||||
bottle_revision ||= f.bottle.revision.to_i if f.bottle
|
bottle_revision ||= f.bottle.revision.to_i if f.bottle
|
||||||
"#{name}-#{version}#{bottle_native_suffix(bottle_revision)}"
|
"#{name}-#{version}#{bottle_native_suffix(options)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_bottle? f, options={:warn=>false}
|
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
|
bottle_ext && bottle_url_ext && bottle_ext != bottle_url_ext
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_native_suffix revision=nil
|
def bottle_native_suffix options={:tag=>bottle_tag}
|
||||||
".#{bottle_tag}#{bottle_suffix(revision)}"
|
".#{options[:tag]}#{bottle_suffix(options[:revision])}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_suffix revision=nil
|
def bottle_suffix revision=nil
|
||||||
@ -70,8 +70,8 @@ def bottle_root_url f
|
|||||||
root_url ||= 'https://downloads.sf.net/project/machomebrew/Bottles'
|
root_url ||= 'https://downloads.sf.net/project/machomebrew/Bottles'
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_url f
|
def bottle_url f, tag=bottle_tag
|
||||||
"#{bottle_root_url(f)}/#{bottle_filename(f)}"
|
"#{bottle_root_url(f)}/#{bottle_filename(f, {:tag => tag})}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_tag
|
def bottle_tag
|
||||||
@ -109,9 +109,12 @@ class BottleCollector
|
|||||||
def fetch_bottle_for(tag)
|
def fetch_bottle_for(tag)
|
||||||
return [@bottles[tag], tag] if @bottles[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
|
end
|
||||||
|
|
||||||
|
def keys; @bottles.keys; end
|
||||||
|
def [](arg); @bottles[arg]; end
|
||||||
|
|
||||||
# This allows generic Altivec PPC bottles to be supported in some
|
# This allows generic Altivec PPC bottles to be supported in some
|
||||||
# formulae, while also allowing specific bottles in others; e.g.,
|
# formulae, while also allowing specific bottles in others; e.g.,
|
||||||
# sometimes a formula has just :tiger_altivec, other times it has
|
# sometimes a formula has just :tiger_altivec, other times it has
|
||||||
|
@ -105,7 +105,7 @@ module Homebrew extend self
|
|||||||
bottle_revision = -1
|
bottle_revision = -1
|
||||||
begin
|
begin
|
||||||
bottle_revision += 1
|
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' \
|
end while not ARGV.include? '--no-revision' \
|
||||||
and master_bottle_filenames.include? filename
|
and master_bottle_filenames.include? filename
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Formula
|
|||||||
# into a validation method on the bottle instance.
|
# into a validation method on the bottle instance.
|
||||||
unless bottle.checksum.nil? || bottle.checksum.empty?
|
unless bottle.checksum.nil? || bottle.checksum.empty?
|
||||||
@bottle = bottle
|
@bottle = bottle
|
||||||
bottle.url ||= bottle_url(self)
|
bottle.url ||= bottle_url(self, bottle.current_tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ require 'checksum'
|
|||||||
require 'version'
|
require 'version'
|
||||||
require 'build_options'
|
require 'build_options'
|
||||||
require 'dependency_collector'
|
require 'dependency_collector'
|
||||||
|
require 'bottles'
|
||||||
|
|
||||||
class SoftwareSpec
|
class SoftwareSpec
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
@ -87,6 +88,7 @@ end
|
|||||||
|
|
||||||
class Bottle < SoftwareSpec
|
class Bottle < SoftwareSpec
|
||||||
attr_rw :root_url, :prefix, :cellar, :revision
|
attr_rw :root_url, :prefix, :cellar, :revision
|
||||||
|
attr_accessor :current_tag
|
||||||
|
|
||||||
def_delegators :@resource, :version=, :url=
|
def_delegators :@resource, :version=, :url=
|
||||||
|
|
||||||
@ -103,16 +105,16 @@ class Bottle < SoftwareSpec
|
|||||||
class_eval <<-EOS, __FILE__, __LINE__ + 1
|
class_eval <<-EOS, __FILE__, __LINE__ + 1
|
||||||
def #{cksum}(val=nil)
|
def #{cksum}(val=nil)
|
||||||
return @#{cksum} if val.nil?
|
return @#{cksum} if val.nil?
|
||||||
@#{cksum} ||= Hash.new
|
@#{cksum} ||= BottleCollector.new
|
||||||
case val
|
case val
|
||||||
when Hash
|
when Hash
|
||||||
key, value = val.shift
|
key, value = val.shift
|
||||||
@#{cksum}[value] = Checksum.new(:#{cksum}, key)
|
@#{cksum}.add(Checksum.new(:#{cksum}, key), value)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @#{cksum}.has_key? bottle_tag
|
cksum, current_tag = @#{cksum}.fetch_bottle_for(bottle_tag)
|
||||||
@resource.checksum = @#{cksum}[bottle_tag]
|
@resource.checksum = cksum if cksum
|
||||||
end
|
@current_tag = current_tag if cksum
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
@ -110,8 +110,8 @@ class BottleTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
checksums.each_pair do |cat, sha1|
|
checksums.each_pair do |cat, sha1|
|
||||||
assert_equal Checksum.new(:sha1, sha1),
|
hsh, _ = @spec.instance_variable_get(:@sha1).fetch_bottle_for(cat)
|
||||||
@spec.instance_variable_get(:@sha1)[cat]
|
assert_equal Checksum.new(:sha1, sha1), hsh
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user