aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-09-10 19:47:22 +0800
committerXu Cheng2015-09-11 14:17:28 +0800
commit70f2b6f19582abada13a35a1d09d72a51aa2de5b (patch)
treeb7eab72c3acd11ac3ad603d5c055333c437491f4 /Library
parentfb1789ad3d0177b4a108636d76b5f3227faa1e08 (diff)
downloadbrew-70f2b6f19582abada13a35a1d09d72a51aa2de5b.tar.bz2
bottle: allow to keep old bottle specification
Closes Homebrew/homebrew#43766. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/bottle.rb39
1 files changed, 36 insertions, 3 deletions
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 6a9d031b3..e5bbdb44b 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -130,6 +130,8 @@ module Homebrew
if ARGV.include? "--no-revision"
bottle_revision = 0
+ elsif ARGV.include? "--keep-old"
+ bottle_revision = f.bottle_specification.revision
else
ohai "Determining #{f.full_name} bottle revision..."
versions = FormulaVersions.new(f)
@@ -201,6 +203,17 @@ module Homebrew
bottle.revision bottle_revision
bottle.sha256 bottle_path.sha256 => bottle_tag
+ old_spec = f.bottle_specification
+ if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
+ bad = [:root_url, :prefix, :cellar, :revision].any? do |field|
+ old_spec.send(field) != bottle.send(field)
+ end
+ if bad
+ bottle_path.unlink if bottle_path.exist?
+ odie "--keep-old is passed but at least one of fields are not the same"
+ end
+ end
+
output = bottle_output bottle
puts "./#{filename}"
@@ -221,6 +234,9 @@ module Homebrew
end
def merge
+ write = ARGV.include? "--write"
+ keep_old = ARGV.include? "--keep-old"
+
merge_hash = {}
ARGV.named.each do |argument|
bottle_block = IO.read(argument)
@@ -231,15 +247,32 @@ module Homebrew
merge_hash.each do |formula_name, bottle_blocks|
ohai formula_name
+ f = Formulary.factory(formula_name)
- bottle = BottleSpecification.new.extend(BottleMerger)
+ bottle = if keep_old
+ f.bottle_specification.dup
+ else
+ BottleSpecification.new
+ end
+ bottle.extend(BottleMerger)
bottle_blocks.each { |block| bottle.instance_eval(block) }
+ old_spec = f.bottle_specification
+ if keep_old && !old_spec.checksums.empty?
+ bad = [:root_url, :prefix, :cellar, :revision].any? do |field|
+ old_spec.send(field) != bottle.send(field)
+ end
+
+ if bad
+ ofail "--keep-old is passed but at least one of fields are not the same, skip it"
+ next
+ end
+ end
+
output = bottle_output bottle
puts output
- if ARGV.include? "--write"
- f = Formulary.factory(formula_name)
+ if write
update_or_add = nil
Utils::Inreplace.inreplace(f.path) do |s|