Skip to content
Snippets Groups Projects
Commit d121bcda authored by Misty De Meo's avatar Misty De Meo
Browse files

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: default avatarMisty De Meo <mistydemeo@gmail.com>
parent b3092ea3
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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
......
......@@ -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}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment