Add non-/usr/local bottles support.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Mike McQuaid 2013-02-28 22:14:59 +00:00
parent 22aec1d0d9
commit 20c0ddc401
5 changed files with 20 additions and 12 deletions

View File

@ -10,7 +10,6 @@ def bottle_filename f, bottle_revision=nil
end
def install_bottle? f
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
@ -19,6 +18,7 @@ def install_bottle? f
return false unless f.pour_bottle?
return false unless f.build.used_options.empty?
return false unless bottle_current?(f)
return false if f.bottle.cellar != :any && f.bottle.cellar != HOMEBREW_CELLAR.to_s
true
end

View File

@ -20,12 +20,22 @@ module Homebrew extend self
HOMEBREW_CELLAR.cd do
ohai "Bottling #{f.name} #{f.version}..."
bottle_relocatable = !quiet_system(
'grep', '--recursive', '--quiet', '--max-count=1',
HOMEBREW_CELLAR, "#{f.name}/#{f.version}")
cellar = nil
if bottle_relocatable
cellar = ':any'
elsif HOMEBREW_CELLAR.to_s != '/usr/local/Cellar'
cellar = "'#{HOMEBREW_CELLAR}'"
end
# Use gzip, faster to compress than bzip2, faster to uncompress than bzip2
# or an uncompressed tarball (and more bandwidth friendly).
safe_system 'tar', 'czf', bottle_path, "#{f.name}/#{f.version}"
sha1 = bottle_path.sha1
puts "./#{filename}"
puts "bottle do"
puts " cellar #{cellar}" if cellar
puts " revision #{bottle_revision}" if bottle_revision > 0
puts " sha1 '#{sha1}' => :#{MacOS.cat}"
puts "end"

View File

@ -79,13 +79,14 @@ end
class Bottle < SoftwareSpec
attr_writer :url
attr_reader :revision, :root_url
attr_reader :revision, :root_url, :cellar
# TODO: Can be removed when all bottles migrated to underscored cat symbols.
attr_reader :cat_without_underscores
def initialize
super
@revision = 0
@cellar = '/usr/local/Cellar'
@cat_without_underscores = false
end
@ -117,6 +118,10 @@ class Bottle < SoftwareSpec
val.nil? ? @root_url : @root_url = val
end
def cellar val=nil
val.nil? ? @cellar : @cellar = val
end
def revision val=nil
val.nil? ? @revision : @revision = val
end

View File

@ -242,16 +242,6 @@ module MacOS extend self
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

View File

@ -190,6 +190,7 @@ class SnowLeopardBottleSpecTestBall < Formula
sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
bottle do
cellar :any
sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard
end
@ -204,6 +205,7 @@ class LionBottleSpecTestBall < Formula
sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
bottle do
cellar :any
sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :lion
end
@ -218,6 +220,7 @@ class AllCatsBottleSpecTestBall < Formula
sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
bottle do
cellar '/private/tmp/testbrew/cellar'
sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard
sha1 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' => :lion
sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountain_lion