aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2013-02-09 19:06:54 -0800
committerMike McQuaid2013-03-01 17:49:09 +0000
commitf99e05bb49281765b153f798112e602602eb1e4e (patch)
tree8b846adfd25c0701420e169774437d2d3406360c /Library
parent01968160de98684ac95945640569f33ee26f9fa5 (diff)
downloadhomebrew-f99e05bb49281765b153f798112e602602eb1e4e.tar.bz2
Cleanup bottle DSL.
* Remove legacy url syntax. * Use revision instead of version. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/bottles.rb31
-rw-r--r--Library/Homebrew/cmd/bottle.rb14
-rw-r--r--Library/Homebrew/formula_support.rb11
-rw-r--r--Library/Homebrew/test/testball.rb5
4 files changed, 33 insertions, 28 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
index 88cfc5830..d474a6f65 100644
--- a/Library/Homebrew/bottles.rb
+++ b/Library/Homebrew/bottles.rb
@@ -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
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 9f2c59767..87b380aa6 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -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
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index 10be6ff63..2f3b10322 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -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)
diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb
index cb94fd40b..f01d14a83 100644
--- a/Library/Homebrew/test/testball.rb
+++ b/Library/Homebrew/test/testball.rb
@@ -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