mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Simplify setup for local bottle installation
Closes Homebrew/homebrew#22833.
This commit is contained in:
parent
e420683a07
commit
1fb9f85c5f
@ -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?
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user