diff options
| author | Mike McQuaid | 2013-09-21 21:30:57 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2013-09-22 16:16:50 +0100 |
| commit | d090ba2a8da51e10f4efccdc80d06f2758b49bad (patch) | |
| tree | 86307a8b4db4796965b1b55ad612a4c07cb1c54b /Library | |
| parent | 76ef4e1d507eacd8744131139a0b025d65a1949a (diff) | |
| download | homebrew-d090ba2a8da51e10f4efccdc80d06f2758b49bad.tar.bz2 | |
bottle: allow writing/committing new bottles.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/bottle.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index c6d074750..3c6a825c6 100644 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -3,6 +3,7 @@ require 'bottles' require 'tab' require 'keg' require 'cmd/versions' +require 'utils/inreplace' require 'erb' class BottleMerger < Formula @@ -34,6 +35,10 @@ BOTTLE_ERB = <<-EOS EOS module Homebrew extend self + class << self + include Utils::Inreplace + end + def keg_contains string, keg quiet_system 'fgrep', '--recursive', '--quiet', '--max-count=1', string, keg end @@ -139,7 +144,26 @@ module Homebrew extend self BottleMerger.class_eval bottle_block end bottle = BottleMerger.new.bottle - puts bottle_output bottle if bottle + next unless bottle + output = bottle_output bottle + puts output + + if ARGV.include? '--write' + f = Formula.factory formula_name + formula_path = HOMEBREW_REPOSITORY+"Library/Formula/#{f.name}.rb" + inreplace formula_path do |s| + if f.bottle + s.gsub!(/ bottle do.+?end\n/m, output) + else + s.gsub!(/( (url|sha1|head|version) '\S*'\n+)+/m, '\0' + output + "\n") + end + end + + update_or_add = f.bottle.nil? ? 'add' : 'update' + + safe_system 'git', 'commit', formula_path, '-m', + "#{f.name}: #{update_or_add} bottle." + end end exit 0 end |
