Improve bottle error messages.

On installation or creation of a bottle error out of the current
machine does not support bottles.

References Homebrew/homebrew#16291.
This commit is contained in:
Mike McQuaid 2012-12-04 12:06:02 +00:00
parent 5d7940228e
commit 4b0e663c2c
3 changed files with 19 additions and 6 deletions

View File

@ -10,7 +10,7 @@ def bottle_filename f, bottle_version=nil
end
def install_bottle? f
return true if ARGV.include? '--install-bottle'
return true if ARGV.include? '--install-bottle' and MacOS.bottles_supported?(true)
return true if f.downloader and defined? f.downloader.local_bottle_path \
and f.downloader.local_bottle_path
not ARGV.build_from_source? \

View File

@ -130,7 +130,7 @@ module HomebrewArgvExtension
end
def build_bottle?
include? '--build-bottle' and MacOS.bottles_supported?
include? '--build-bottle' and MacOS.bottles_supported?(true)
end
def build_from_source?

View File

@ -228,11 +228,24 @@ module MacOS extend self
`/usr/sbin/pkgutil --pkg-info "#{id}" 2>/dev/null`.strip
end
def bottles_supported?
def bottles_supported? raise_if_failed=false
# We support bottles on all versions of OS X except 32-bit Snow Leopard.
(Hardware.is_64_bit? or not MacOS.version >= :snow_leopard) \
and HOMEBREW_PREFIX.to_s == '/usr/local' \
and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar' \
unless Hardware.is_64_bit? or MacOS.version >= :snow_leopard
return false unless raise_if_failed
raise "Bottles are not supported on 32-bit Snow Leopard."
end
unless HOMEBREW_PREFIX.to_s == '/usr/local'
return false unless raise_if_failed
raise "Bottles are only supported with a /usr/local prefix."
end
unless HOMEBREW_CELLAR.to_s == '/usr/local/Cellar'
return false unless raise_if_failed
raise "Bottles are only supported with a /usr/local/Cellar cellar."
end
true
end
end