diff options
| author | Mike McQuaid | 2010-11-24 09:40:37 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2011-06-08 22:19:10 +0100 |
| commit | e4dd52e9de628a426131e2c6845edc52b4f8dbdb (patch) | |
| tree | 87eceed1ec3e5b3efb8765d2b67252ca0da42f78 | |
| parent | 383f0d276e28724207c5ccf200398e6d2914ebc1 (diff) | |
| download | homebrew-e4dd52e9de628a426131e2c6845edc52b4f8dbdb.tar.bz2 | |
Add changes to Homebrew internals for bottling.
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ARGV.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 47 | ||||
| -rwxr-xr-x | Library/Homebrew/install.rb | 6 |
4 files changed, 63 insertions, 13 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 772a3d40c..ea25eafbb 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -60,7 +60,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy raise end else - puts "File already downloaded and cached to #{HOMEBREW_CACHE}" + puts "File already downloaded in #{File.dirname(@tarball_path)}" end return @tarball_path # thus performs checksum verification end @@ -160,6 +160,18 @@ class CurlUnsafeDownloadStrategy < CurlDownloadStrategy end end +# This strategy extracts our binary packages. +class CurlBottleDownloadStrategy <CurlDownloadStrategy + def initialize url, name, version, specs + super + @tarball_path=HOMEBREW_CACHE+'Bottles'+("#{name}-#{version}"+ext) + end + def stage + ohai "Pouring #{File.basename(@tarball_path)}" + super + end +end + class SubversionDownloadStrategy <AbstractDownloadStrategy def initialize url, name, version, specs super diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index eef3cbc0c..4803ecf44 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -58,10 +58,19 @@ module HomebrewArgvExtension def build_head? flag? '--HEAD' end + def build_universal? include? '--universal' end + def build_from_source? + flag? '--build-from-source' or ENV['HOMEBREW_BUILD_FROM_SOURCE'] + end + + def one? + flag? "--1" + end + def flag? flag options_only.each do |arg| return true if arg == flag diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a381ce3b7..c1c05b347 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -45,6 +45,13 @@ 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. @@ -94,12 +101,14 @@ end class Formula include FileUtils - attr_reader :name, :path, :url, :version, :homepage, :specs, :downloader + attr_reader :name, :path, :url, :bottle, :bottle_sha1, :version, :homepage, :specs, :downloader # Homebrew determines the name def initialize name='__UNKNOWN__', path=nil set_instance_variable 'homepage' set_instance_variable 'url' + set_instance_variable 'bottle' + set_instance_variable 'bottle_sha1' set_instance_variable 'head' set_instance_variable 'specs' @@ -110,6 +119,8 @@ class Formula @url = @head @version = 'HEAD' @spec_to_use = @unstable + elsif pouring + @spec_to_use = BottleSoftwareSpecification.new(@bottle, @specs) else if @stable.nil? @spec_to_use = SoftwareSpecification.new(@url, @specs) @@ -442,6 +453,10 @@ class Formula end end + def pouring + return (@bottle or ARGV.build_from_source?) + end + protected # Pretty titles the command and buffers stdout/stderr # Throws if there's an error @@ -500,10 +515,16 @@ private def verify_download_integrity fn require 'digest' - type=CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") } - type ||= :md5 - supplied=instance_variable_get("@#{type}") - type=type.to_s.upcase + if not pouring + 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" + end + hasher = Digest.const_get(type) hash = fn.incremental_hash(hasher) @@ -528,14 +549,21 @@ EOF fetched = @downloader.fetch verify_download_integrity fetched if fetched.kind_of? Pathname - mktemp do - @downloader.stage - yield + if not pouring + mktemp do + @downloader.stage + yield + end + else + HOMEBREW_CELLAR.cd do + @downloader.stage + yield + end end end def patch - return if patches.nil? + return if patches.nil? or pouring if not patches.kind_of? Hash # We assume -p1 @@ -629,6 +657,7 @@ EOF attr_rw :version, :homepage, :specs, :deps, :external_deps attr_rw :keg_only_reason, :fails_with_llvm_reason, :skip_clean_all + attr_rw :bottle, :bottle_sha1 attr_rw(*CHECKSUM_TYPES) def head val=nil, specs=nil diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 07584d3dd..d436fb853 100755 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -89,7 +89,7 @@ def install f else f.prefix.mkpath beginning=Time.now - f.install + f.install if not f.pouring FORMULA_META_FILES.each do |filename| next if File.directory? filename target_file = filename @@ -99,7 +99,7 @@ def install f f.prefix.install target_file => filename rescue nil (f.prefix+file).chmod 0644 rescue nil end - build_time = Time.now-beginning + build_time = Time.now-beginning if not f.pouring end end rescue Exception @@ -131,7 +131,7 @@ def install f begin require 'cleaner' - Cleaner.new f + Cleaner.new f if not f.pouring 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" |
