From 67f78074f9fe0dc9b00bc499e8f66c069c2ab35c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 25 Aug 2012 13:08:24 -0700 Subject: [PATCH] Miscellaneous bottle code cleanup. --- Library/Homebrew/bottles.rb | 10 +++++++--- Library/Homebrew/cmd/info.rb | 2 +- Library/Homebrew/extend/ARGV.rb | 10 +--------- Library/Homebrew/macos.rb | 7 +++++++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 7d725ccb7c..2d5fa6aa0f 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -1,4 +1,5 @@ require 'tab' +require 'macos' require 'extend/ARGV' def bottle_filename f, bottle_version=nil @@ -11,7 +12,7 @@ end def install_bottle? f return true if ARGV.include? '--install-bottle' not ARGV.build_from_source? \ - and ARGV.bottles_supported? \ + and MacOS.bottles_supported? \ and ARGV.used_options(f).empty? \ and bottle_current?(f) end @@ -25,12 +26,15 @@ def built_as_bottle? f end def bottle_current? f - f.bottle and f.bottle.url && !f.bottle.checksum.empty? && f.bottle.version == f.stable.version + f.bottle and f.bottle.url \ + and (not f.bottle.checksum.empty?) \ + and (f.bottle.version == f.stable.version) end def bottle_file_outdated? f, file filename = file.basename.to_s - return nil unless (filename.match(bottle_regex) or filename.match(old_bottle_regex)) and f.bottle and f.bottle.url + return nil unless f.bottle and f.bottle.url \ + and (filename.match(bottle_regex) or filename.match(old_bottle_regex)) bottle_ext = filename.match(bottle_native_regex).captures.first rescue nil bottle_ext ||= filename.match(old_bottle_regex).captures.first rescue nil diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index b9de91dbdf..c9040eac62 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -51,7 +51,7 @@ module Homebrew extend self specs = [] stable = "stable #{f.stable.version}" if f.stable - stable += " (bottled)" if f.bottle and bottles_supported? + stable += " (bottled)" if f.bottle and MacOS.bottles_supported? specs << stable if stable specs << "devel #{f.devel.version}" if f.devel specs << "HEAD" if f.head diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 4d8663394f..694850df2e 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -124,16 +124,8 @@ module HomebrewArgvExtension include? '--32-bit' end - def bottles_supported? - # Snow Leopard was the only version of OS X that supported - # both 64-bit and 32-bit processors and kernels. - (Hardware.is_64_bit? or not MacOS.snow_leopard?) \ - and HOMEBREW_PREFIX.to_s == '/usr/local' \ - and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar' \ - end - def build_bottle? - include? '--build-bottle' and bottles_supported? + include? '--build-bottle' and MacOS.bottles_supported? end def build_from_source? diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index 4979956ab9..933070c9f6 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -215,6 +215,13 @@ module MacOS extend self def pkgutil_info id `pkgutil --pkg-info #{id} 2>/dev/null`.strip end + + def bottles_supported? + # We support bottles on all versions of OS X except 32-bit Snow Leopard. + (Hardware.is_64_bit? or not MacOS.snow_leopard?) \ + and HOMEBREW_PREFIX.to_s == '/usr/local' \ + and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar' \ + end end require 'macos/xcode'