diff options
| author | Max Howell | 2011-08-24 01:13:15 +0100 |
|---|---|---|
| committer | Max Howell | 2011-08-24 22:30:43 +0100 |
| commit | 6ac0a285239d5fbd7943f070eac0e68847046ff8 (patch) | |
| tree | 447bcb793e55a0a97d2fb0c5d50714a4e1e7a1a9 /Library | |
| parent | 19e387d92e2741fa23cc6fde4743b1b8b28e0fa3 (diff) | |
| download | brew-6ac0a285239d5fbd7943f070eac0e68847046ff8.tar.bz2 | |
Implement bottles again
Bottles now pour purely, without doing all the other unnecessary stuff that happened before the `brew upgrade` code shuffle.
Formula.pourable? removed since it was install-specific metadata and not related to the formula itself. Now all such logic is in the FormulaInstaller which is much cleaner.
I also changed the bottle cache location to the normal directory and added a .bottle pre-extension. Thus you can see everything in one directory without messing about.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 40 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 16 |
3 files changed, 26 insertions, 33 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 6db69f3e3..32afea120 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -183,8 +183,7 @@ end class CurlBottleDownloadStrategy <CurlDownloadStrategy def initialize url, name, version, specs super - HOMEBREW_CACHE_BOTTLES.mkpath - @tarball_path=HOMEBREW_CACHE_BOTTLES+("#{name}-#{version}"+ext) + @tarball_path = HOMEBREW_CACHE/"#{name}-#{version}.bottle#{ext}" end def stage ohai "Pouring #{File.basename(@tarball_path)}" diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 173c7d187..d422c7bbb 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -45,13 +45,6 @@ class SoftwareSpecification end end -class BottleSoftwareSpecification < SoftwareSpecification - def download_strategy - return CurlBottleDownloadStrategy if @using.nil? - raise "Strategies cannot be used with bottles." - end -end - # Used to annotate formulae that duplicate OS X provided software # or cause conflicts when linked in. @@ -120,8 +113,6 @@ class Formula @url = @head @version = 'HEAD' @spec_to_use = @unstable - elsif pourable? - @spec_to_use = BottleSoftwareSpecification.new(@bottle, @specs) else if @stable.nil? @spec_to_use = SoftwareSpecification.new(@url, @specs) @@ -457,10 +448,6 @@ class Formula end end - def pourable? - @bottle and not ARGV.build_from_source? - end - protected # Pretty titles the command and buffers stdout/stderr # Throws if there's an error @@ -521,16 +508,17 @@ private CHECKSUM_TYPES=[:md5, :sha1, :sha256].freeze - def verify_download_integrity fn + public # for FormulaInstaller + + def verify_download_integrity fn, *args require 'digest' - if not pourable? + if args.count != 2 type=CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") } type ||= :md5 supplied=instance_variable_get("@#{type}") type=type.to_s.upcase else - supplied=instance_variable_get("@bottle_sha1") - type="SHA1" + supplied, type = args end hasher = Digest.const_get(type) @@ -552,26 +540,20 @@ EOF end end + private + def stage HOMEBREW_CACHE.mkpath fetched = @downloader.fetch verify_download_integrity fetched if fetched.kind_of? Pathname - - if not pourable? - mktemp do - @downloader.stage - yield - end - else - HOMEBREW_CELLAR.cd do - @downloader.stage - yield - end + mktemp do + @downloader.stage + yield end end def patch - return if patches.nil? or pourable? + return if patches.nil? if not patches.kind_of? Hash # We assume -p1 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 5c2e61590..dc145e371 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -14,7 +14,7 @@ class FormulaInstaller @f = ff @show_header = true @ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive? - @install_bottle = ff.pourable? #TODO better + @install_bottle = !ff.bottle.nil? && !ARGV.build_from_source? end def install @@ -149,7 +149,7 @@ class FormulaInstaller def clean require 'cleaner' - Cleaner.new f if not f.pourable? + Cleaner.new f rescue Exception => e opoo "The cleaning step did not complete successfully" puts "Still, the installation was successful, so we will link it into your prefix" @@ -157,6 +157,18 @@ class FormulaInstaller @show_summary_heading = true end + def pour + HOMEBREW_CACHE.mkpath + downloader = CurlBottleDownloadStrategy.new f.bottle, f.name, f.version, nil + downloader.fetch + f.verify_download_integrity downloader.tarball_path, f.bottle_sha1, "SHA1" + HOMEBREW_CELLAR.cd do + downloader.stage + end + end + + ## checks + def paths @paths ||= ENV['PATH'].split(':').map{ |p| File.expand_path p } end |
