Cleanup bottle DSL.
* Remove legacy url syntax. * Use revision instead of version. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
161104cae7
commit
360af367a8
@ -2,22 +2,25 @@ require 'tab'
|
||||
require 'macos'
|
||||
require 'extend/ARGV'
|
||||
|
||||
def bottle_filename f, bottle_version=nil
|
||||
def bottle_filename f, bottle_revision=nil
|
||||
name = f.name.downcase
|
||||
version = f.stable.version
|
||||
bottle_version ||= f.bottle.revision.to_i
|
||||
"#{name}-#{version}#{bottle_native_suffix(bottle_version)}"
|
||||
bottle_revision ||= f.bottle.revision.to_i
|
||||
"#{name}-#{version}#{bottle_native_suffix(bottle_revision)}"
|
||||
end
|
||||
|
||||
def install_bottle? f
|
||||
return true if ARGV.include? '--install-bottle' and MacOS.bottles_supported?(true)
|
||||
return true if f.downloader and defined? f.downloader.local_bottle_path \
|
||||
and f.downloader.local_bottle_path
|
||||
not ARGV.build_from_source? \
|
||||
and MacOS.bottles_supported? \
|
||||
and f.pour_bottle? \
|
||||
and f.build.used_options.empty? \
|
||||
and bottle_current?(f)
|
||||
|
||||
return false if ARGV.build_from_source?
|
||||
return false unless MacOS.bottles_supported?
|
||||
return false unless f.pour_bottle?
|
||||
return false unless f.build.used_options.empty?
|
||||
return false unless bottle_current?(f)
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def built_as_bottle? f
|
||||
@ -45,18 +48,18 @@ def bottle_file_outdated? f, file
|
||||
bottle_ext && bottle_url_ext && bottle_ext != bottle_url_ext
|
||||
end
|
||||
|
||||
def bottle_new_version f
|
||||
def bottle_new_revision f
|
||||
return 0 unless bottle_current? f
|
||||
f.bottle.revision + 1
|
||||
end
|
||||
|
||||
def bottle_native_suffix version=nil
|
||||
".#{MacOS.cat}#{bottle_suffix(version)}"
|
||||
def bottle_native_suffix revision=nil
|
||||
".#{MacOS.cat}#{bottle_suffix(revision)}"
|
||||
end
|
||||
|
||||
def bottle_suffix version=nil
|
||||
version = version.to_i > 0 ? ".#{version}" : ""
|
||||
".bottle#{version}.tar.gz"
|
||||
def bottle_suffix revision=nil
|
||||
revision = revision.to_i > 0 ? ".#{revision}" : ""
|
||||
".bottle#{revision}.tar.gz"
|
||||
end
|
||||
|
||||
def bottle_native_regex
|
||||
|
||||
@ -13,19 +13,21 @@ module Homebrew extend self
|
||||
return ofail "Formula not installed with '--build-bottle': #{f.name}"
|
||||
end
|
||||
|
||||
directory = Pathname.pwd
|
||||
bottle_version = bottle_new_version f
|
||||
filename = bottle_filename f, bottle_version
|
||||
bottle_revision = bottle_new_revision f
|
||||
filename = bottle_filename f, bottle_revision
|
||||
bottle_path = Pathname.pwd/filename
|
||||
sha1 = nil
|
||||
|
||||
HOMEBREW_CELLAR.cd do
|
||||
ohai "Bottling #{f.name} #{f.version}..."
|
||||
# Use gzip, faster to compress than bzip2, faster to uncompress than bzip2
|
||||
# or an uncompressed tarball (and more bandwidth friendly).
|
||||
safe_system 'tar', 'czf', directory/filename, "#{f.name}/#{f.version}"
|
||||
safe_system 'tar', 'czf', bottle_path, "#{f.name}/#{f.version}"
|
||||
sha1 = bottle_path.sha1
|
||||
puts "./#{filename}"
|
||||
puts "bottle do"
|
||||
puts " version #{bottle_version}" if bottle_version > 0
|
||||
puts " sha1 '#{(directory/filename).sha1}' => :#{MacOS.cat}"
|
||||
puts " revision #{bottle_revision}" if bottle_revision > 0
|
||||
puts " sha1 '#{sha1}' => :#{MacOS.cat}"
|
||||
puts "end"
|
||||
end
|
||||
end
|
||||
|
||||
@ -83,7 +83,7 @@ class Bottle < SoftwareSpec
|
||||
# TODO: Can be removed when all bottles migrated to underscored cat symbols.
|
||||
attr_reader :cat_without_underscores
|
||||
|
||||
def initialize url=nil, version=nil
|
||||
def initialize
|
||||
super
|
||||
@revision = 0
|
||||
@cat_without_underscores = false
|
||||
@ -98,8 +98,6 @@ class Bottle < SoftwareSpec
|
||||
case val
|
||||
when nil
|
||||
@#{cksum}[MacOS.cat]
|
||||
when String
|
||||
@#{cksum}[:lion] = Checksum.new(:#{cksum}, val)
|
||||
when Hash
|
||||
key, value = val.shift
|
||||
@#{cksum}[value] = Checksum.new(:#{cksum}, key)
|
||||
@ -115,12 +113,13 @@ class Bottle < SoftwareSpec
|
||||
}
|
||||
end
|
||||
|
||||
def url val=nil
|
||||
val.nil? ? @url : @url = val
|
||||
def revision val=nil
|
||||
val.nil? ? @revision : @revision = val
|
||||
end
|
||||
|
||||
# Used in the bottle DSL to set @revision, but acts as an
|
||||
# Used in the old bottle DSL to set @revision, but acts as an
|
||||
# as accessor for @version to preserve the interface
|
||||
# TODO: Can be removed when no bottles are using `version` any more.
|
||||
def version val=nil
|
||||
if val.nil?
|
||||
return @version ||= Version.parse(@url)
|
||||
|
||||
@ -131,8 +131,9 @@ class ExplicitVersionSpecTestBall < Formula
|
||||
|
||||
bottle do
|
||||
version '1'
|
||||
url 'file:///foo.com/test-0.3.lion.bottle.tar.gz'
|
||||
sha1 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d'
|
||||
sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard
|
||||
sha1 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' => :lion
|
||||
sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountain_lion
|
||||
end
|
||||
|
||||
def initialize name=nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user