aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/bottles.rb49
-rwxr-xr-xLibrary/Homebrew/cmd/bottle.rb9
-rw-r--r--Library/Homebrew/extend/ARGV.rb6
-rw-r--r--Library/Homebrew/extend/pathname.rb5
-rw-r--r--Library/Homebrew/formula.rb12
-rw-r--r--Library/Homebrew/formula_installer.rb3
-rw-r--r--Library/Homebrew/utils.rb4
7 files changed, 62 insertions, 26 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
new file mode 100644
index 000000000..13ed77590
--- /dev/null
+++ b/Library/Homebrew/bottles.rb
@@ -0,0 +1,49 @@
+require 'tab'
+require 'extend/ARGV'
+
+def bottle_filename f
+ "#{f.name}-#{f.version}#{bottle_native_suffix}"
+end
+
+def bottles_supported?
+ HOMEBREW_PREFIX.to_s == '/usr/local' and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar'
+end
+
+def install_bottle? f
+ !ARGV.build_from_source? && bottle_current?(f) && bottle_native?(f)
+end
+
+def bottle_native? f
+ return true if bottle_native_regex.match(f.bottle_url)
+ # old brew bottle style
+ return true if MacOS.lion? && old_bottle_regex.match(f.bottle_url)
+ return false
+end
+
+def built_bottle? f
+ Tab.for_formula(f).built_bottle
+end
+
+def bottle_current? f
+ !f.bottle_url.nil? && Pathname.new(f.bottle_url).version == f.version
+end
+
+def bottle_native_suffix
+ ".#{MacOS.cat}#{bottle_suffix}"
+end
+
+def bottle_suffix
+ ".bottle.tar.gz"
+end
+
+def bottle_native_regex
+ /(\.#{MacOS.cat}\.bottle\.tar\.gz)$/
+end
+
+def bottle_regex
+ /(\.[a-z]+\.bottle\.tar\.gz)$/
+end
+
+def old_bottle_regex
+ /(-bottle\.tar\.gz)$/
+end \ No newline at end of file
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 25160b5c6..4a1cd0f36 100755
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -1,17 +1,14 @@
require 'formula'
+require 'bottles'
require 'tab'
module Homebrew extend self
- def formula_bottle_name f
- "#{f.name}-#{f.version}.#{MacOS.cat}.bottle.tar.gz"
- end
-
def bottle_formula f
return onoe "Formula not installed: #{f.name}" unless f.installed?
- return onoe "Formula not installed with '--build-bottle': #{f.name}" unless Tab.for_formula(f).built_bottle
+ return onoe "Formula not installed with '--build-bottle': #{f.name}" unless built_bottle? f
directory = Pathname.pwd
- filename = formula_bottle_name f
+ filename = bottle_filename f
HOMEBREW_CELLAR.cd do
ohai "Bottling #{f.name} #{f.version}..."
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index 59a5087e7..25d19e2e7 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -1,3 +1,5 @@
+require 'bottles'
+
module HomebrewArgvExtension
def named
@named ||= reject{|arg| arg[0..0] == '-'}
@@ -94,12 +96,12 @@ module HomebrewArgvExtension
end
def build_bottle?
- MacOS.bottles_supported? and include? '--build-bottle'
+ bottles_supported? and include? '--build-bottle'
end
def build_from_source?
flag? '--build-from-source' or ENV['HOMEBREW_BUILD_FROM_SOURCE'] \
- or not MacOS.bottles_supported? or not options_only.empty?
+ or not bottles_supported? or not options_only.empty?
end
def flag? flag
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index f05fc9f5f..34f692f28 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -1,4 +1,5 @@
require 'pathname'
+require 'bottles'
# we enhance pathname to make our code more readable
class Pathname
@@ -100,9 +101,9 @@ class Pathname
# extended to support common double extensions
def extname
- return $1 if to_s =~ /(\.[a-z]+\.bottle\.tar\.gz)$/
+ return $1 if to_s =~ bottle_regex
# old brew bottle style
- return $1 if to_s =~ /(-bottle\.tar\.gz)$/
+ return $1 if to_s =~ old_bottle_regex
/(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s
return $1 if $1
return File.extname(to_s)
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index b3623b336..b1cb3dc0e 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -1,6 +1,7 @@
require 'download_strategy'
require 'formula_support'
require 'hardware'
+require 'bottles'
require 'extend/fileutils'
@@ -64,17 +65,6 @@ class Formula
return false
end
- def bottle_for_current_osx_version?
- return true if /#{MacOS.cat}\.bottle\.tar\.gz$/.match(bottle_url)
- # old brew bottle style
- return true if MacOS.lion? && /-bottle\.tar\.gz$/.match(bottle_url)
- return false
- end
-
- def bottle_up_to_date?
- !bottle_url.nil? && Pathname.new(bottle_url).version == version
- end
-
def explicitly_requested?
# `ARGV.formulae` will throw an exception if it comes up with an empty list.
# FIXME: `ARGV.formulae` shouldn't be throwing exceptions, see issue #8823
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 82c58c9d0..cc6d61b8e 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -3,6 +3,7 @@ require 'formula'
require 'keg'
require 'set'
require 'tab'
+require 'bottles'
class FormulaInstaller
attr :f
@@ -15,7 +16,7 @@ class FormulaInstaller
@f = ff
@show_header = true
@ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive?
- @install_bottle = !ARGV.build_from_source? && ff.bottle_up_to_date? && ff.bottle_for_current_osx_version?
+ @install_bottle = install_bottle? ff
check_install_sanity
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index f18b908b2..4ef0a5a67 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -503,10 +503,6 @@ module MacOS extend self
def prefer_64_bit?
Hardware.is_64_bit? and not leopard?
end
-
- def bottles_supported?
- HOMEBREW_PREFIX.to_s == '/usr/local' and HOMEBREW_CELLAR.to_s == '/usr/local/Cellar'
- end
end
module GitHub extend self