formula_installer: use installed_* variables.

Also, report formulae installed on request. This is useful in
differentiating between those formulae that are popular because they
are widely requested and those that are popular because they are widely
depended on.
This commit is contained in:
Mike McQuaid 2017-01-09 21:07:55 +00:00
parent 44f1c9752a
commit 16293c0a68

View File

@ -36,6 +36,7 @@ class FormulaInstaller
mode_attr_accessor :build_from_source, :force_bottle
mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git
mode_attr_accessor :verbose, :debug, :quieter
mode_attr_accessor :installed_as_dependency, :installed_on_request
def initialize(formula)
@formula = formula
@ -50,6 +51,8 @@ class FormulaInstaller
@verbose = false
@quieter = false
@debug = false
@installed_as_dependency = false
@installed_on_request = true
@options = Options.new
@invalid_option_names = []
@requirement_messages = []
@ -250,6 +253,12 @@ class FormulaInstaller
category = "install"
action = ([formula.full_name] + options).join(" ")
Utils::Analytics.report_event(category, action)
if installed_on_request
category = "install_on_request"
action = ([formula.full_name] + options).join(" ")
Utils::Analytics.report_event(category, action)
end
end
@@attempted << formula
@ -287,6 +296,12 @@ class FormulaInstaller
brew_prefix = formula.prefix/".brew"
brew_prefix.mkdir
Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s)
keg = Keg.new(formula.prefix)
tab = Tab.for_keg(keg)
tab.installed_as_dependency = installed_as_dependency
tab.installed_on_request = installed_on_request
tab.write
end
build_bottle_postinstall if build_bottle?
@ -483,6 +498,8 @@ class FormulaInstaller
fi.build_from_source = ARGV.build_formula_from_source?(df)
fi.verbose = verbose? && !quieter?
fi.debug = debug?
fi.installed_as_dependency = true
fi.installed_on_request = false
fi.prelude
oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}"
fi.install
@ -809,6 +826,8 @@ class FormulaInstaller
tab.time = Time.now.to_i
tab.head = HOMEBREW_REPOSITORY.git_head
tab.source["path"] = formula.specified_path.to_s
tab.installed_as_dependency = installed_as_dependency
tab.installed_on_request = installed_on_request
tab.write
end