aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/bottles.rb2
-rw-r--r--Library/Homebrew/cmd/bottle.rb10
-rw-r--r--Library/Homebrew/formula_support.rb7
-rw-r--r--Library/Homebrew/macos.rb10
-rw-r--r--Library/Homebrew/test/testball.rb3
5 files changed, 20 insertions, 12 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
index 7962a50e1..07eb2c5f3 100644
--- a/Library/Homebrew/bottles.rb
+++ b/Library/Homebrew/bottles.rb
@@ -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
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 87b380aa6..cda1d776d 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -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"
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index c9355d641..3cd221129 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -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
diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb
index 14715499f..bc886ce4b 100644
--- a/Library/Homebrew/macos.rb
+++ b/Library/Homebrew/macos.rb
@@ -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
diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb
index f01d14a83..858f1d647 100644
--- a/Library/Homebrew/test/testball.rb
+++ b/Library/Homebrew/test/testball.rb
@@ -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