mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Use new download strategy for local bottles.
Fixes installation of e.g. ScriptFileFormula/denominator bottles.
This commit is contained in:
parent
ff65923531
commit
95f9c6227a
@ -2,6 +2,8 @@ require 'open-uri'
|
|||||||
require 'vendor/multi_json'
|
require 'vendor/multi_json'
|
||||||
|
|
||||||
class AbstractDownloadStrategy
|
class AbstractDownloadStrategy
|
||||||
|
attr_accessor :local_bottle_path
|
||||||
|
|
||||||
def initialize name, package
|
def initialize name, package
|
||||||
@url = package.url
|
@url = package.url
|
||||||
specs = package.specs
|
specs = package.specs
|
||||||
@ -36,8 +38,6 @@ class AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class CurlDownloadStrategy < AbstractDownloadStrategy
|
class CurlDownloadStrategy < AbstractDownloadStrategy
|
||||||
attr_accessor :local_bottle_path
|
|
||||||
|
|
||||||
def initialize name, package
|
def initialize name, package
|
||||||
super
|
super
|
||||||
|
|
||||||
@ -49,7 +49,6 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
|||||||
|
|
||||||
@mirrors = package.mirrors
|
@mirrors = package.mirrors
|
||||||
@temporary_path = Pathname.new("#@tarball_path.incomplete")
|
@temporary_path = Pathname.new("#@tarball_path.incomplete")
|
||||||
@local_bottle_path = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_location
|
def cached_location
|
||||||
@ -66,11 +65,6 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
if @local_bottle_path
|
|
||||||
@tarball_path = @local_bottle_path
|
|
||||||
return @local_bottle_path
|
|
||||||
end
|
|
||||||
|
|
||||||
ohai "Downloading #{@url}"
|
ohai "Downloading #{@url}"
|
||||||
unless @tarball_path.exist?
|
unless @tarball_path.exist?
|
||||||
had_incomplete_download = @temporary_path.exist?
|
had_incomplete_download = @temporary_path.exist?
|
||||||
@ -230,6 +224,14 @@ class CurlBottleDownloadStrategy < CurlDownloadStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This strategy extracts local binary packages.
|
||||||
|
class LocalBottleDownloadStrategy < CurlDownloadStrategy
|
||||||
|
def initialize formula, local_bottle_path
|
||||||
|
super formula.name, formula.active_spec
|
||||||
|
@tarball_path = local_bottle_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class SubversionDownloadStrategy < AbstractDownloadStrategy
|
class SubversionDownloadStrategy < AbstractDownloadStrategy
|
||||||
def initialize name, package
|
def initialize name, package
|
||||||
super
|
super
|
||||||
|
@ -403,8 +403,14 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pour
|
def pour
|
||||||
fetched, downloader = f.fetch, f.downloader
|
downloader = f.downloader
|
||||||
f.verify_download_integrity(fetched) unless downloader.local_bottle_path
|
if downloader.local_bottle_path
|
||||||
|
downloader = LocalBottleDownloadStrategy.new f,
|
||||||
|
downloader.local_bottle_path
|
||||||
|
else
|
||||||
|
fetched = f.fetch
|
||||||
|
f.verify_download_integrity fetched
|
||||||
|
end
|
||||||
HOMEBREW_CELLAR.cd do
|
HOMEBREW_CELLAR.cd do
|
||||||
downloader.stage
|
downloader.stage
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user