Simplify setup for local bottle installation

Closes Homebrew/homebrew#22833.
This commit is contained in:
Jack Nagel 2013-09-25 18:51:30 -05:00
parent e420683a07
commit 1fb9f85c5f
5 changed files with 9 additions and 12 deletions

View File

@ -11,9 +11,7 @@ def bottle_filename f, bottle_revision=nil
end end
def install_bottle? f, options={:warn=>false} def install_bottle? f, options={:warn=>false}
return true if f.downloader and defined? f.downloader.local_bottle_path \ return true if f.local_bottle_path
and f.downloader.local_bottle_path
return false if ARGV.build_from_source? return false if ARGV.build_from_source?
return true if ARGV.force_bottle? return true if ARGV.force_bottle?
return false unless f.pour_bottle? return false unless f.pour_bottle?

View File

@ -2,8 +2,6 @@ require 'open-uri'
require 'utils/json' require 'utils/json'
class AbstractDownloadStrategy class AbstractDownloadStrategy
attr_accessor :local_bottle_path
attr_reader :name, :resource attr_reader :name, :resource
def initialize name, resource def initialize name, resource
@ -251,9 +249,9 @@ end
# This strategy extracts local binary packages. # This strategy extracts local binary packages.
class LocalBottleDownloadStrategy < CurlDownloadStrategy class LocalBottleDownloadStrategy < CurlDownloadStrategy
def initialize formula, local_bottle_path def initialize formula
super formula.name, formula.active_spec super formula.name, formula.active_spec
@tarball_path = local_bottle_path @tarball_path = formula.local_bottle_path
end end
def stage def stage

View File

@ -23,6 +23,8 @@ class Formula
# Will only be non-nil inside #stage and #test. # Will only be non-nil inside #stage and #test.
attr_reader :buildpath, :testpath attr_reader :buildpath, :testpath
attr_accessor :local_bottle_path
# Homebrew determines the name # Homebrew determines the name
def initialize name='__UNKNOWN__', path=nil def initialize name='__UNKNOWN__', path=nil
@name = name @name = name

View File

@ -509,11 +509,10 @@ class FormulaInstaller
end end
def pour def pour
downloader = f.downloader if f.local_bottle_path
if downloader.local_bottle_path downloader = LocalBottleDownloadStrategy.new(f)
downloader = LocalBottleDownloadStrategy.new f,
downloader.local_bottle_path
else else
downloader = f.downloader
fetched = f.fetch fetched = f.fetch
f.verify_download_integrity fetched f.verify_download_integrity fetched
end end

View File

@ -74,7 +74,7 @@ class Formulary
def get_formula def get_formula
formula = klass.new(name) formula = klass.new(name)
formula.downloader.local_bottle_path = @bottle_filename formula.local_bottle_path = @bottle_filename
return formula return formula
end end
end end