From d121bcdadae49e570de0a4fcf4c71499c5f2c846 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Sun, 22 Jan 2012 22:32:15 -0600 Subject: 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 --- Library/Homebrew/cmd/audit.rb | 8 ++++++- Library/Homebrew/cmd/install.rb | 2 +- Library/Homebrew/formula.rb | 44 +++++++++++++++++++++++++++-------- Library/Homebrew/formula_installer.rb | 6 ++--- 4 files changed, 45 insertions(+), 15 deletions(-) (limited to 'Library/Homebrew') diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index e980466da..5f4af55a2 100755 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -290,7 +290,7 @@ module Homebrew extend self ff.each do |f| problems = [] - if f.unstable and f.stable.nil? + if f.unstable and f.standard.nil? problems += [' * head-only formula'] end @@ -314,6 +314,12 @@ module Homebrew extend self problems += [' * invalid or missing version'] if f.version.to_s.empty? + problems << " * 'devel' block found before stable 'url'" if text =~ /devel.+(url '.+').+(url '.+')/m + + problems << " * 'devel' block found before 'head'" if text =~ /devel.+(head '.+')/m + + problems << " * Empty 'devel' block found" if text =~ /devel do\s+end/ + # Don't try remaining audits on text in __END__ text_without_patch = (text.split("__END__")[0]).strip() diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 735db6107..779482b7c 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -89,7 +89,7 @@ module Homebrew extend self next if f.installed? unless ARGV.force? # Building head-only without --HEAD is an error - if not ARGV.build_head? and f.stable.nil? + if not ARGV.build_head? and f.standard.nil? raise "This is a head-only formula; install with `brew install --HEAD #{f.name}`" end 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} diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index deee2b956..c5f0f999e 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -15,8 +15,8 @@ class FormulaInstaller @f = ff @show_header = true @ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive? - @install_bottle = !ff.bottle.nil? && !ARGV.build_from_source? && - Pathname.new(ff.bottle).version == ff.version + @install_bottle = !ff.bottle_url.nil? && !ARGV.build_from_source? && + Pathname.new(ff.bottle_url).version == ff.version end def install @@ -189,7 +189,7 @@ class FormulaInstaller def pour HOMEBREW_CACHE.mkpath - downloader = CurlBottleDownloadStrategy.new f.bottle, f.name, f.version, nil + downloader = CurlBottleDownloadStrategy.new f.bottle_url, f.name, f.version, nil downloader.fetch f.verify_download_integrity downloader.tarball_path, f.bottle_sha1, "SHA1" HOMEBREW_CELLAR.cd do -- cgit v1.2.3