diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 88cfc58309..d474a6f65d 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 9f2c597678..87b380aa6c 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 10be6ff635..2f3b10322b 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 cb94fd40be..f01d14a831 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