Rename bottle's revision to rebuild.

This commit is contained in:
Mike McQuaid 2016-08-18 17:32:35 +01:00
parent 5c7c9de669
commit 27ecf588c7
10 changed files with 46 additions and 37 deletions

View File

@ -20,8 +20,8 @@ BOTTLE_ERB = <<-EOS
<% elsif cellar != BottleSpecification::DEFAULT_CELLAR %>
cellar "<%= cellar %>"
<% end %>
<% if revision > 0 %>
revision <%= revision %>
<% if rebuild > 0 %>
rebuild <%= rebuild %>
<% end %>
<% checksums.each do |checksum_type, checksum_values| %>
<% checksum_values.each do |checksum_value| %>
@ -148,19 +148,19 @@ module Homebrew
return ofail "Formula has no stable version: #{f.full_name}"
end
if ARGV.include? "--no-revision"
bottle_revision = 0
if ARGV.include? "--no-rebuild"
rebuild = 0
elsif ARGV.include? "--keep-old"
bottle_revision = f.bottle_specification.revision
rebuild = f.bottle_specification.rebuild
else
ohai "Determining #{f.full_name} bottle revision..."
ohai "Determining #{f.full_name} bottle rebuild..."
versions = FormulaVersions.new(f)
bottle_revisions = versions.bottle_version_map("origin/master")[f.pkg_version]
bottle_revisions.pop if bottle_revisions.last.to_i > 0
bottle_revision = bottle_revisions.empty? ? 0 : bottle_revisions.max.to_i + 1
rebuilds = versions.bottle_version_map("origin/master")[f.pkg_version]
rebuilds.pop if rebuilds.last.to_i > 0
rebuild = rebuilds.empty? ? 0 : rebuilds.max.to_i + 1
end
filename = Bottle::Filename.create(f, Utils::Bottles.tag, bottle_revision)
filename = Bottle::Filename.create(f, Utils::Bottles.tag, rebuild)
bottle_path = Pathname.pwd/filename
tar_filename = filename.to_s.sub(/.gz$/, "")
@ -277,13 +277,13 @@ module Homebrew
bottle.cellar cellar
bottle.prefix prefix
end
bottle.revision bottle_revision
bottle.rebuild rebuild
sha256 = bottle_path.sha256
bottle.sha256 sha256 => Utils::Bottles.tag
old_spec = f.bottle_specification
if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
bad_fields = [:root_url, :prefix, :cellar, :revision].select do |field|
bad_fields = [:root_url, :prefix, :cellar, :rebuild].select do |field|
old_spec.send(field) != bottle.send(field)
end
bad_fields.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation
@ -309,7 +309,7 @@ module Homebrew
"root_url" => bottle.root_url,
"prefix" => bottle.prefix,
"cellar" => bottle.cellar.to_s,
"revision" => bottle.revision,
"rebuild" => bottle.rebuild,
"tags" => {
Utils::Bottles.tag.to_s => {
"filename" => filename.to_s,
@ -347,7 +347,7 @@ module Homebrew
end
bottle.cellar cellar
bottle.prefix bottle_hash["bottle"]["prefix"]
bottle.revision bottle_hash["bottle"]["revision"]
bottle.rebuild bottle_hash["bottle"]["rebuild"]
bottle_hash["bottle"]["tags"].each do |tag, tag_hash|
bottle.sha256 tag_hash["sha256"] => tag.to_sym
end
@ -368,7 +368,7 @@ module Homebrew
line = line.strip
next if line.empty?
key, value, _, tag = line.split " ", 4
valid_key = %w[root_url prefix cellar revision sha1 sha256].include? key
valid_key = %w[root_url prefix cellar rebuild sha1 sha256].include? key
next unless valid_key
value = value.to_s.delete ":'\""
@ -414,7 +414,7 @@ module Homebrew
(\n^\ {3}[\S\ ]+$)* # options can be in multiple lines
)?|
(homepage|desc|sha1|sha256|version|mirror)\ ['"][\S\ ]+['"]| # specs with a string
revision\ \d+ # revision with a number
rebuild\ \d+ # rebuild with a number
)\n+ # multiple empty lines
)+
/mx, '\0' + output + "\n")

View File

@ -14,3 +14,4 @@ require "compat/pathname"
require "compat/dependency_collector"
require "compat/language/haskell"
require "compat/xcode"
require "compat/software_spec"

View File

@ -0,0 +1,8 @@
class BottleSpecification
def revision(*args)
# Don't announce deprecation yet as this is quite a big change
# to a public interface.
# odeprecated "BottleSpecification.revision", "BottleSpecification.rebuild"
rebuild(*args)
end
end

View File

@ -952,7 +952,7 @@ module Homebrew
# Tap repository if required, this is done before everything else
# because Formula parsing and/or git commit hash lookup depends on it.
# At the same time, make sure Tap is not a shallow clone.
# bottle revision and bottle upload rely on full clone.
# bottle rebuild and bottle upload rely on full clone.
safe_system "brew", "tap", tap.name, "--full" if tap
if ARGV.include? "--ci-upload"

View File

@ -1330,7 +1330,7 @@ class Formula
next unless spec.bottle_defined?
bottle_spec = spec.bottle_specification
bottle_info = {
"revision" => bottle_spec.revision,
"rebuild" => bottle_spec.rebuild,
"cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? \
cellar.inspect : cellar,
"prefix" => bottle_spec.prefix,
@ -1340,7 +1340,7 @@ class Formula
bottle_spec.collector.keys.each do |os|
checksum = bottle_spec.collector[os]
bottle_info["files"][os] = {
"url" => "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.revision)}",
"url" => "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.rebuild)}",
checksum.hash_type.to_s => checksum.hexdigest,
}
end
@ -1789,7 +1789,7 @@ class Formula
# root_url "https://example.com" # Optional root to calculate bottle URLs
# prefix "/opt/homebrew" # Optional HOMEBREW_PREFIX in which the bottles were built.
# cellar "/opt/homebrew/Cellar" # Optional HOMEBREW_CELLAR in which the bottles were built.
# revision 1 # Making the old bottle outdated without bumping the version/revision of the formula.
# rebuild 1 # Making the old bottle outdated without bumping the version/revision of the formula.
# sha256 "4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865" => :el_capitan
# sha256 "53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3" => :yosemite
# sha256 "1121cfccd5913f0a63fec40a6ffd44ea64f9dc135c66634ba001d10bcf4302a2" => :mavericks

View File

@ -53,7 +53,7 @@ class FormulaVersions
formula_at_revision(rev) do |f|
bottle = f.bottle_specification
unless bottle.checksums.empty?
map[f.pkg_version] << bottle.revision
map[f.pkg_version] << bottle.rebuild
end
end
end

View File

@ -214,17 +214,17 @@ end
class Bottle
class Filename
attr_reader :name, :version, :tag, :revision
attr_reader :name, :version, :tag, :rebuild
def self.create(formula, tag, revision)
new(formula.name, formula.pkg_version, tag, revision)
def self.create(formula, tag, rebuild)
new(formula.name, formula.pkg_version, tag, rebuild)
end
def initialize(name, version, tag, revision)
def initialize(name, version, tag, rebuild)
@name = name
@version = version
@tag = tag
@revision = revision
@rebuild = rebuild
end
def to_s
@ -237,14 +237,14 @@ class Bottle
end
def suffix
s = revision > 0 ? ".#{revision}" : ""
s = rebuild > 0 ? ".#{rebuild}" : ""
".bottle#{s}.tar.gz"
end
end
extend Forwardable
attr_reader :name, :resource, :prefix, :cellar, :revision
attr_reader :name, :resource, :prefix, :cellar, :rebuild
def_delegators :resource, :url, :fetch, :verify_download_integrity
def_delegators :resource, :cached_download, :clear_cache
@ -257,14 +257,14 @@ class Bottle
checksum, tag = spec.checksum_for(Utils::Bottles.tag)
filename = Filename.create(formula, tag, spec.revision)
filename = Filename.create(formula, tag, spec.rebuild)
@resource.url(build_url(spec.root_url, filename))
@resource.download_strategy = CurlBottleDownloadStrategy
@resource.version = formula.pkg_version
@resource.checksum = checksum
@prefix = spec.prefix
@cellar = spec.cellar
@revision = spec.revision
@rebuild = spec.rebuild
end
def compatible_cellar?
@ -292,12 +292,12 @@ class BottleSpecification
DEFAULT_CELLAR = "/usr/local/Cellar".freeze
DEFAULT_DOMAIN = (ENV["HOMEBREW_BOTTLE_DOMAIN"] || "https://homebrew.bintray.com").freeze
attr_rw :prefix, :cellar, :revision
attr_rw :prefix, :cellar, :rebuild
attr_accessor :tap
attr_reader :checksum, :collector
def initialize
@revision = 0
@rebuild = 0
@prefix = DEFAULT_PREFIX
@cellar = DEFAULT_CELLAR
@collector = Utils::Bottles::Collector.new

View File

@ -3,8 +3,8 @@ require "formula"
require "software_spec"
class BottleFilenameTests < Homebrew::TestCase
def fn(revision)
Bottle::Filename.new("foo", "1.0", :tag, revision)
def fn(rebuild)
Bottle::Filename.new("foo", "1.0", :tag, rebuild)
end
def test_prefix_suffix

View File

@ -288,7 +288,7 @@ class IntegrationCommandTests < Homebrew::TestCase
def test_bottle
cmd("install", "--build-bottle", testball)
assert_match "Formula not from core or any taps",
cmd_fail("bottle", "--no-revision", testball)
cmd_fail("bottle", "--no-rebuild", testball)
setup_test_formula "testball"
@ -298,7 +298,7 @@ class IntegrationCommandTests < Homebrew::TestCase
FileUtils.ln_s "not-exist", "symlink"
end
assert_match(/testball-0\.1.*\.bottle\.tar\.gz/,
cmd_output("bottle", "--no-revision", "testball"))
cmd_output("bottle", "--no-rebuild", "testball"))
ensure
FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"]
end

View File

@ -173,7 +173,7 @@ class BottleSpecificationTests < Homebrew::TestCase
def test_other_setters
double = Object.new
%w[root_url prefix cellar revision].each do |method|
%w[root_url prefix cellar rebuild].each do |method|
@spec.send(method, double)
assert_equal double, @spec.send(method)
end