diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 2802132655..2370426620 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -216,6 +216,21 @@ class Formula active_spec == head end + # @private + def bottle_unneeded? + active_spec.bottle_unneeded? + end + + # @private + def bottle_disabled? + active_spec.bottle_disabled? + end + + # @private + def bottle_disable_reason + active_spec.bottle_disable_reason + end + # @private def bottled? active_spec.bottled? @@ -1592,8 +1607,14 @@ class Formula # sha256 "53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3" => :mavericks # sha256 "1121cfccd5913f0a63fec40a6ffd44ea64f9dc135c66634ba001d10bcf4302a2" => :mountain_lion # end - def bottle(*, &block) - stable.bottle(&block) + # + # For formulae which don't require compiling, you can tag them with: + #
bottle :unneeded+ # + # To disable bottle for other reasons. + #
bottle :disable, "reasons"+ def bottle(*args, &block) + stable.bottle(*args, &block) end # @private diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index 2430c31b09..c76ed39f3c 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -55,3 +55,23 @@ EOS end.strip end end + +# Used to annotate formulae that don't require compiling or cannot build bottle. +class BottleDisableReason + def initialize(type, reason) + @type = type + @reason = reason + end + + def unneeded? + @type == :unneeded + end + + def to_s + if @type == :unneeded + "This formula doesn't require compiling." + else + @reason + end + end +end diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index e8148322e3..d2c811b69f 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -63,13 +63,29 @@ class SoftwareSpec dependency_collector.add(@resource) end + def bottle_unneeded? + !!@bottle_disable_reason && @bottle_disable_reason.unneeded? + end + + def bottle_disabled? + !!@bottle_disable_reason + end + + def bottle_disable_reason + @bottle_disable_reason + end + def bottled? bottle_specification.tag?(bottle_tag) && \ (bottle_specification.compatible_cellar? || ARGV.force_bottle?) end - def bottle(&block) - bottle_specification.instance_eval(&block) + def bottle(disable_type = nil, disable_reason = nil, &block) + if disable_type + @bottle_disable_reason = BottleDisableReason.new(disable_type, disable_reason) + else + bottle_specification.instance_eval(&block) + end end def resource_defined?(name)