From ab41071d2b1d8795a68b5330c65237765969ca83 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 16 Jul 2014 21:11:48 -0500 Subject: [PATCH] Separate tag matching and checksum lookup --- Library/Homebrew/bottles.rb | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index ec02075d01..cc29c54fda 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -69,8 +69,8 @@ class BottleCollector end def fetch_checksum_for(tag) - return self[tag], tag if key?(tag) - find_altivec_tag(tag) || find_or_later_tag(tag) + tag = find_matching_tag(tag) + return self[tag], tag if tag end def keys @@ -91,6 +91,14 @@ class BottleCollector private + def find_matching_tag(tag) + if key?(tag) + tag + else + find_altivec_tag(tag) || find_or_later_tag(tag) + end + 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 @@ -98,7 +106,7 @@ class BottleCollector def find_altivec_tag(tag) if tag.to_s =~ /(\w+)_(g4|g4e|g5)$/ altivec_tag = "#{$1}_altivec".to_sym - return self[altivec_tag], altivec_tag if key?(altivec_tag) + altivec_tag if key?(altivec_tag) end end @@ -106,13 +114,11 @@ class BottleCollector # so the same bottle can target multiple OSs. # Not used in core, used in taps. def find_or_later_tag(tag) - results = @checksums.find_all {|k,v| k.to_s =~ /_or_later$/} - results.each do |key, hsh| - later_tag = key.to_s[/(\w+)_or_later$/, 1].to_sym - bottle_version = MacOS::Version.from_symbol(later_tag) - return [hsh, key] if bottle_version <= MacOS::Version.from_symbol(tag) + keys.find do |key| + if key.to_s.end_with?("_or_later") + later_tag = key.to_s[/(\w+)_or_later$/, 1].to_sym + MacOS::Version.from_symbol(later_tag) <= MacOS::Version.from_symbol(tag) + end end - - nil end end