aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula.rb
diff options
context:
space:
mode:
authorMisty De Meo2012-01-22 22:32:15 -0600
committerMisty De Meo2012-01-25 21:45:19 -0600
commitd121bcdadae49e570de0a4fcf4c71499c5f2c846 (patch)
tree733834b0de1c624c26d2169a5fbc3ceea8bf6a69 /Library/Homebrew/formula.rb
parentb3092ea3f7e0540fef839a77d2b3afa9cfd64255 (diff)
downloadbrew-d121bcdadae49e570de0a4fcf4c71499c5f2c846.tar.bz2
Add `devel` to the DSL, + stable and bottle blocks
This commit adds a `devel` entry to the DSL, allowing formulae to specify an unstable branch. `devel` takes a block, which should contain standard `url` and `md5` fields (and `version`, if necessary). This must come after the standard DSL fields. This commit also migrates over all formulae currently using `devel` to the new syntax, as well as formulae which used `head` for non-VCS urls. The new syntax is also available for `stable` and `bottle`. `stable` is an option alongside the old syntax. `bottle` replaces the old syntax. Note that the @stable ivar in Formula has been renamed to @standard, and the @bottle ivar has been renamed to @bottle_url. Closes Homebrew/homebrew#9735. Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
Diffstat (limited to 'Library/Homebrew/formula.rb')
-rw-r--r--Library/Homebrew/formula.rb44
1 files changed, 34 insertions, 10 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index b4763f8fb..bae651bd3 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -100,19 +100,19 @@ class Formula
include FileUtils
attr_reader :name, :path, :url, :version, :homepage, :specs, :downloader
- attr_reader :stable, :unstable
- attr_reader :bottle, :bottle_sha1, :head
+ attr_reader :standard, :unstable
+ attr_reader :bottle_url, :bottle_sha1, :head
# 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_url'
set_instance_variable 'bottle_sha1'
set_instance_variable 'head'
set_instance_variable 'specs'
- set_instance_variable 'stable'
+ set_instance_variable 'standard'
set_instance_variable 'unstable'
if @head and (not @url or ARGV.build_head?)
@@ -120,10 +120,10 @@ class Formula
@version = 'HEAD'
@spec_to_use = @unstable
else
- if @stable.nil?
+ if @standard.nil?
@spec_to_use = SoftwareSpecification.new(@url, @specs)
else
- @spec_to_use = @stable
+ @spec_to_use = @standard
end
end
@@ -583,7 +583,7 @@ private
downloader = @downloader
# Don't attempt mirrors if this install is not pointed at a "stable" URL.
# This can happen when options like `--HEAD` are invoked.
- mirror_list = @spec_to_use == @stable ? mirrors : []
+ mirror_list = @spec_to_use == @standard ? mirrors : []
# Ensure the cache exists
HOMEBREW_CACHE.mkpath
@@ -731,7 +731,7 @@ EOF
class << self
# The methods below define the formula DSL.
- attr_reader :stable, :unstable
+ attr_reader :standard, :unstable
def self.attr_rw(*attrs)
attrs.each do |attr|
@@ -745,7 +745,7 @@ EOF
attr_rw :version, :homepage, :mirrors, :specs, :deps, :external_deps
attr_rw :keg_only_reason, :fails_with_llvm_reason, :skip_clean_all
- attr_rw :bottle, :bottle_sha1
+ attr_rw :bottle_url, :bottle_sha1
attr_rw(*CHECKSUM_TYPES)
def head val=nil, specs=nil
@@ -757,11 +757,35 @@ EOF
def url val=nil, specs=nil
return @url if val.nil?
- @stable = SoftwareSpecification.new(val, specs)
+ @standard = SoftwareSpecification.new(val, specs)
@url = val
@specs = specs
end
+ def stable &block
+ raise "url and md5 must be specified in a block" unless block_given?
+ instance_eval &block unless ARGV.build_devel? or ARGV.build_head?
+ end
+
+ def devel &block
+ raise "url and md5 must be specified in a block" unless block_given?
+ instance_eval &block if ARGV.build_devel?
+ end
+
+ def bottle url=nil, &block
+ if block_given?
+ eval <<-EOCLASS
+ module BottleData
+ def self.url url; @url = url; end
+ def self.sha1 sha1; @sha1 = sha1; end
+ def self.return_data; [@url,@sha1]; end
+ end
+ EOCLASS
+ BottleData.instance_eval &block
+ @bottle_url, @bottle_sha1 = BottleData.return_data
+ end
+ end
+
def mirror val, specs=nil
@mirrors ||= []
@mirrors << {:url => val, :specs => specs}