aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/formula_installer.rb2
-rw-r--r--Library/Homebrew/tab.rb55
2 files changed, 20 insertions, 37 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 3c8066120..1c312ddfa 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -243,7 +243,7 @@ class FormulaInstaller
raise "Empty installation" if Dir["#{f.prefix}/*"].empty?
- Tab.for_install(f, args).write # INSTALL_RECEIPT.json
+ Tab.create(f, args).write # INSTALL_RECEIPT.json
rescue Exception => e
ignore_interrupts do
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 15f2911d9..ab0706fdd 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -1,18 +1,22 @@
require 'ostruct'
-
require 'formula'
require 'vendor/multi_json'
# Inherit from OpenStruct to gain a generic initialization method that takes a
# hash and creates an attribute for each key and value. `Tab.new` probably
# should not be called directly, instead use one of the class methods like
-# `Tab.for_install`.
+# `Tab.create`.
class Tab < OpenStruct
- def self.for_install f, args
- sha = `cd '#{HOMEBREW_REPOSITORY}' && git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle
+ FILENAME = 'INSTALL_RECEIPT.json'
+
+ def self.create f, args
+ sha = HOMEBREW_REPOSITORY.cd do
+ `git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle
+ end
+
Tab.new :used_options => args.used_options(f),
:unused_options => args.unused_options(f),
- :tabfile => f.prefix + "INSTALL_RECEIPT.json",
+ :tabfile => f.prefix.join(FILENAME),
:built_as_bottle => !!args.build_bottle?,
:tapped_from => f.tap,
:time => Time.now.to_i, # to_s would be better but Ruby has no from_s function :P
@@ -22,50 +26,29 @@ class Tab < OpenStruct
def self.from_file path
tab = Tab.new MultiJson.decode(open(path).read)
tab.tabfile = path
- return tab
+ tab
end
def self.for_keg keg
- path = keg+'INSTALL_RECEIPT.json'
+ path = keg.join(FILENAME)
if path.exist?
- self.from_file path
+ self.from_file(path)
else
- begin
- self.dummy_tab Formula.factory(keg.parent.basename)
- rescue FormulaUnavailableError
- Tab.new :used_options => [],
- :unused_options => [],
- :built_as_bottle => false,
- :tapped_from => "",
- :time => nil,
- :HEAD => nil
- end
+ self.dummy_tab
end
end
def self.for_formula f
- f = Formula.factory f unless f.kind_of? Formula
- path = f.linked_keg/'INSTALL_RECEIPT.json'
-
- if path.exist?
- self.from_file path
- else
- # Really should bail out with an error if a formula was not installed
- # with a Tab. However, there will be lots of legacy installs that have no
- # receipt---so we fabricate one that claims the formula was installed with
- # no options.
- #
- # TODO:
- # This isn't the best behavior---perhaps a future version of Homebrew can
- # treat missing Tabs as errors.
- self.dummy_tab f
- end
+ f = Formula.factory(f)
+ path = [f.opt_prefix, f.linked_keg].map{ |pn| pn.join(FILENAME) }.find{ |pn| pn.exist? }
+ # Legacy kegs may lack a receipt. If it doesn't exist, fake one
+ if path.nil? then self.dummy_tab(f) else self.from_file(path) end
end
- def self.dummy_tab f
+ def self.dummy_tab f=nil
Tab.new :used_options => [],
- :unused_options => f.build.as_flags,
+ :unused_options => (f.build.as_flags rescue []),
:built_as_bottle => false,
:tapped_from => "",
:time => nil,