diff options
| author | Mike McQuaid | 2012-11-25 14:33:52 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2012-12-01 12:45:23 +0000 |
| commit | c4fb2b73e2602c07e02a78360ef9de59d417ca37 (patch) | |
| tree | e8452a683d76d73010f5e68ee23d53f8719e45bb /Library/Homebrew | |
| parent | 92c971fbb40c2212136c38fdb77fdb750e14a345 (diff) | |
| download | brew-c4fb2b73e2602c07e02a78360ef9de59d417ca37.tar.bz2 | |
Support installing bottles from local files.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/bottles.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 11 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 2 |
4 files changed, 22 insertions, 6 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index a060d671e..ff316f925 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -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? \ diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 3a1e0e64c..f9df839d1 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index d553846e3..3563badec 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 4d25ead56..8f3670c6b 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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 |
