From 2df6ad1beda5f29f6eaf6807ec4a53f59bb20260 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Sun, 13 Sep 2015 12:59:13 +0800 Subject: [PATCH] Formula#to_hash: add bottle info Closes Homebrew/homebrew#43848. Signed-off-by: Xu Cheng --- Library/Homebrew/formula.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a3f63f1bd0..3a00aae29a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1120,6 +1120,28 @@ class Formula { "option" => opt.flag, "description" => opt.description } end + hsh["bottle"] = {} + %w[stable devel].each do |spec_sym| + next unless spec = send(spec_sym) + next unless (bottle_spec = spec.bottle_specification).checksums.any? + bottle_info = { + "revision" => bottle_spec.revision, + "cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? \ + cellar.inspect : cellar, + "prefix" => bottle_spec.prefix, + "root_url" => bottle_spec.root_url, + } + bottle_info["files"] = {} + 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)}", + checksum.hash_type.to_s => checksum.hexdigest, + } + end + hsh["bottle"][spec_sym] = bottle_info + end + if rack.directory? rack.subdirs.each do |keg_path| keg = Keg.new keg_path