diff options
| author | Mike McQuaid | 2014-03-31 13:15:07 -0500 | 
|---|---|---|
| committer | Mike McQuaid | 2014-04-10 15:25:30 +0100 | 
| commit | dc29fe38384740e66484dff862593e962be12889 (patch) | |
| tree | c55c2f9b84ec43d466d76fb6cd7992072447f08e | |
| parent | 0993b2cba7a84315fda4d1ec0658708c415877fa (diff) | |
| download | homebrew-dc29fe38384740e66484dff862593e962be12889.tar.bz2 | |
Add hooks for pouring bottles.
This should give us a bit of control over what e.g. Boxen are doing
whilst at the same time stopping us from accidentally breaking each
other's stuff every so often.
I'm aware this may be somewhat controversial so I'm open to other
approaches.
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/hooks/bottles.rb | 31 | 
2 files changed, 38 insertions, 0 deletions
| diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index c6e179c60..e9c2d7638 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -11,6 +11,7 @@ require 'cleaner'  require 'formula_cellar_checks'  require 'install_renamed'  require 'cmd/tap' +require 'hooks/bottles'  class FormulaInstaller    include FormulaCellarChecks @@ -47,6 +48,8 @@ class FormulaInstaller    end    def pour_bottle? install_bottle_options={:warn=>false} +    return true if Homebrew::Hooks::Bottles.formula_has_bottle?(f) +      return false if @pour_failed      return true  if force_bottle? && f.bottle      return false if build_from_source? || build_bottle? || interactive? @@ -618,6 +621,10 @@ class FormulaInstaller    end    def pour +    if Homebrew::Hooks::Bottles.formula_has_bottle?(f) +      return if Homebrew::Hooks::Bottles.pour_formula_bottle(f) +    end +      if f.local_bottle_path        downloader = LocalBottleDownloadStrategy.new(f)      else diff --git a/Library/Homebrew/hooks/bottles.rb b/Library/Homebrew/hooks/bottles.rb new file mode 100644 index 000000000..de321c09a --- /dev/null +++ b/Library/Homebrew/hooks/bottles.rb @@ -0,0 +1,31 @@ +# Boxen (and perhaps others) want to override our bottling infrastructure so +# they can avoid declaring checksums in formulae files. +# Instead of periodically breaking their monkeypatches let's add some hooks that +# we can query to allow their own behaviour. + +# PLEASE DO NOT EVER RENAME THIS CLASS OR ADD/REMOVE METHOD ARGUMENTS! +module Homebrew +  module Hooks +    module Bottles +      def self.setup_formula_has_bottle &block +        @has_bottle = block +        true +      end + +      def self.setup_pour_formula_bottle &block +        @pour_bottle = block +        true +      end + +      def self.formula_has_bottle?(formula) +        return false unless @has_bottle +        @has_bottle.call formula +      end + +      def self.pour_formula_bottle(formula) +        return false unless @pour_bottle +        @pour_bottle.call formula +      end +    end +  end +end | 
