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
def install_bottle? f, options={:warn=>false}
return true if f.downloader and defined? f.downloader.local_bottle_path \
and f.downloader.local_bottle_path
return true if f.local_bottle_path
return false if ARGV.build_from_source?
return true if ARGV.force_bottle?
return false unless f.pour_bottle?

View File

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

View File

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

View File

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

View File

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