Support installing bottles from local files.

This commit is contained in:
Mike McQuaid 2012-11-25 14:33:52 +00:00
parent 92c971fbb4
commit c4fb2b73e2
4 changed files with 22 additions and 6 deletions

View File

@ -11,6 +11,7 @@ end
def install_bottle? f
return true if ARGV.include? '--install-bottle'
return true if f.downloader and f.downloader.local_bottle_path
not ARGV.build_from_source? \
and MacOS.bottles_supported? \
and ARGV.used_options(f).empty? \

View File

@ -32,7 +32,8 @@ class AbstractDownloadStrategy
end
class CurlDownloadStrategy < AbstractDownloadStrategy
attr_reader :tarball_path
attr_reader :tarball_path, :local_bottle_path
attr_writer :local_bottle_path
def initialize name, package
super
@ -55,6 +56,11 @@ 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?
begin
@ -79,6 +85,8 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
end
def stage
ohai "Pouring #{File.basename(@tarball_path)}" if @tarball_path.to_s.match bottle_regex
case @tarball_path.compression_type
when :zip
quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @tarball_path
@ -204,10 +212,6 @@ class CurlBottleDownloadStrategy < CurlDownloadStrategy
FileUtils.mv old_bottle_path, @tarball_path if old_bottle_path.exist?
end
end
def stage
ohai "Pouring #{File.basename(@tarball_path)}"
super
end
end
class SubversionDownloadStrategy < AbstractDownloadStrategy

View File

@ -355,6 +355,11 @@ class Formula
end
install_type = :from_url
elsif name.match bottle_regex
bottle_filename = Pathname(name).realpath
name = name.split('-').first
path = Formula.path(name)
install_type = :from_local_bottle
else
name = Formula.canonical_name(name)
@ -395,6 +400,12 @@ class Formula
raise LoadError
end
if install_type == :from_local_bottle
formula = klass.new(name)
formula.downloader.local_bottle_path = bottle_filename
return formula
end
raise NameError if !klass.ancestors.include? Formula
return klass.new(name) if install_type == :from_name

View File

@ -364,7 +364,7 @@ class FormulaInstaller
def pour
fetched, downloader = f.fetch
f.verify_download_integrity fetched
f.verify_download_integrity fetched unless downloader.local_bottle_path
HOMEBREW_CELLAR.cd do
downloader.stage
end