bottle: move bottle output to ERB.
This commit is contained in:
parent
5de0b4964a
commit
fd34bd6b90
@ -3,6 +3,7 @@ require 'bottles'
|
|||||||
require 'tab'
|
require 'tab'
|
||||||
require 'keg'
|
require 'keg'
|
||||||
require 'cmd/versions'
|
require 'cmd/versions'
|
||||||
|
require 'erb'
|
||||||
|
|
||||||
class BottleMerger < Formula
|
class BottleMerger < Formula
|
||||||
# This provides a URL and Version which are the only needed properties of
|
# This provides a URL and Version which are the only needed properties of
|
||||||
@ -12,34 +13,34 @@ class BottleMerger < Formula
|
|||||||
def self.reset_bottle; @bottle = Bottle.new; end
|
def self.reset_bottle; @bottle = Bottle.new; end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
BOTTLE_ERB = <<-EOS
|
||||||
|
bottle do
|
||||||
|
<% if prefix.to_s != '/usr/local' %>
|
||||||
|
prefix '<%= prefix %>'
|
||||||
|
<% end %>
|
||||||
|
<% if cellar.is_a? Symbol %>
|
||||||
|
cellar :<%= cellar %>
|
||||||
|
<% elsif cellar.to_s != '/usr/local' %>
|
||||||
|
cellar '<%= cellar %>'
|
||||||
|
<% end %>
|
||||||
|
<% if revision > 0 %>
|
||||||
|
revision <%= revision %>
|
||||||
|
<% end %>
|
||||||
|
<% checksums.keys.each do |checksum_type| %>
|
||||||
|
<% checksum, osx = checksums[checksum_type].shift %>
|
||||||
|
<%= checksum_type %> '<%= checksum %>' => :<%= osx %>
|
||||||
|
<% end %>
|
||||||
|
end
|
||||||
|
EOS
|
||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def keg_contains string, keg
|
def keg_contains string, keg
|
||||||
quiet_system 'fgrep', '--recursive', '--quiet', '--max-count=1', string, keg
|
quiet_system 'fgrep', '--recursive', '--quiet', '--max-count=1', string, keg
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_output bottle
|
def bottle_output bottle
|
||||||
puts "bottle do"
|
erb = ERB.new BOTTLE_ERB
|
||||||
prefix = bottle.prefix.to_s
|
erb.result(bottle.instance_eval { binding }).gsub(/^\s*$\n/, '')
|
||||||
puts " prefix '#{prefix}'" if prefix != '/usr/local'
|
|
||||||
cellar = if bottle.cellar.is_a? Symbol
|
|
||||||
":#{bottle.cellar}"
|
|
||||||
elsif bottle.cellar.to_s != '/usr/local/Cellar'
|
|
||||||
"'bottle.cellar'"
|
|
||||||
end
|
|
||||||
puts " cellar #{cellar}" if cellar
|
|
||||||
puts " revision #{bottle.revision}" if bottle.revision > 0
|
|
||||||
Checksum::TYPES.each do |checksum_type|
|
|
||||||
checksum_os_versions = bottle.send checksum_type
|
|
||||||
next unless checksum_os_versions
|
|
||||||
os_versions = checksum_os_versions.keys
|
|
||||||
os_versions.map! {|osx| MacOS::Version.from_symbol osx }
|
|
||||||
os_versions.sort.reverse.each do |os_version|
|
|
||||||
osx = os_version.to_sym
|
|
||||||
checksum = checksum_os_versions[osx]
|
|
||||||
puts " #{checksum_type} '#{checksum}' => :#{osx}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
puts "end"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_formula f
|
def bottle_formula f
|
||||||
@ -70,6 +71,8 @@ module Homebrew extend self
|
|||||||
cellar = HOMEBREW_CELLAR.to_s
|
cellar = HOMEBREW_CELLAR.to_s
|
||||||
tmp_cellar = '/tmp/Cellar'
|
tmp_cellar = '/tmp/Cellar'
|
||||||
|
|
||||||
|
output = nil
|
||||||
|
|
||||||
HOMEBREW_CELLAR.cd do
|
HOMEBREW_CELLAR.cd do
|
||||||
ohai "Bottling #{filename}..."
|
ohai "Bottling #{filename}..."
|
||||||
# Use gzip, faster to compress than bzip2, faster to uncompress than bzip2
|
# Use gzip, faster to compress than bzip2, faster to uncompress than bzip2
|
||||||
@ -106,7 +109,8 @@ module Homebrew extend self
|
|||||||
bottle.sha1 sha1 => bottle_tag
|
bottle.sha1 sha1 => bottle_tag
|
||||||
|
|
||||||
puts "./#{filename}"
|
puts "./#{filename}"
|
||||||
bottle_output bottle
|
output = bottle_output bottle
|
||||||
|
puts output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -126,7 +130,7 @@ module Homebrew extend self
|
|||||||
BottleMerger.class_eval bottle_block
|
BottleMerger.class_eval bottle_block
|
||||||
end
|
end
|
||||||
bottle = BottleMerger.new.bottle
|
bottle = BottleMerger.new.bottle
|
||||||
bottle_output bottle if bottle
|
puts bottle_output bottle if bottle
|
||||||
end
|
end
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user