Use new download strategy for local bottles.

Fixes installation of e.g. ScriptFileFormula/denominator bottles.
This commit is contained in:
Mike McQuaid 2013-06-08 16:41:23 +01:00
parent ff65923531
commit 95f9c6227a
2 changed files with 18 additions and 10 deletions

View File

@ -2,6 +2,8 @@ require 'open-uri'
require 'vendor/multi_json'
class AbstractDownloadStrategy
attr_accessor :local_bottle_path
def initialize name, package
@url = package.url
specs = package.specs
@ -36,8 +38,6 @@ class AbstractDownloadStrategy
end
class CurlDownloadStrategy < AbstractDownloadStrategy
attr_accessor :local_bottle_path
def initialize name, package
super
@ -49,7 +49,6 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
@mirrors = package.mirrors
@temporary_path = Pathname.new("#@tarball_path.incomplete")
@local_bottle_path = nil
end
def cached_location
@ -66,11 +65,6 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
end
def fetch
if @local_bottle_path
@tarball_path = @local_bottle_path
return @local_bottle_path
end
ohai "Downloading #{@url}"
unless @tarball_path.exist?
had_incomplete_download = @temporary_path.exist?
@ -230,6 +224,14 @@ class CurlBottleDownloadStrategy < CurlDownloadStrategy
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
def initialize name, package
super

View File

@ -403,8 +403,14 @@ class FormulaInstaller
end
def pour
fetched, downloader = f.fetch, f.downloader
f.verify_download_integrity(fetched) unless downloader.local_bottle_path
downloader = f.downloader
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
downloader.stage
end