diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb index 8808a2602d7d91316c45632d2dd0804cca00ff62..f5d091227edf0165da863dd040af6f7ff77f5709 100644 --- a/Library/Homebrew/cmd/postinstall.rb +++ b/Library/Homebrew/cmd/postinstall.rb @@ -7,7 +7,10 @@ module Homebrew module_function def postinstall - ARGV.resolved_formulae.each { |f| run_post_install(f) if f.post_install_defined? } + ARGV.resolved_formulae.each do |f| + ohai "Postinstalling #{f}" + run_post_install(f) + end end def run_post_install(formula) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 4ff5d3175fa72a453ac0837e83b0c75f45de1b78..17a34dd1370de58c706ba62300beebdb0fdc8f98 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1004,11 +1004,6 @@ class Formula # Can be overridden to run commands on both source and bottle installation. def post_install; end - # @private - def post_install_defined? - method(:post_install).owner == self.class - end - # @private def run_post_install @prefix_returns_versioned_prefix = true @@ -1025,6 +1020,11 @@ class Formula ENV.clear_sensitive_environment! + Pathname.glob("#{bottle_prefix}/{etc,var}/**/*") do |path| + path.extend(InstallRenamed) + path.cp_path_sub(bottle_prefix, HOMEBREW_PREFIX) + end + with_logging("post_install") do post_install end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 1d8346f131098e5b92b9f62dd7453662ec67264e..db9115aae54f8f25b0dae9df14aa2baaf6178272 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -564,13 +564,11 @@ class FormulaInstaller fix_dynamic_linkage(keg) end - if formula.post_install_defined? - if build_bottle? - ohai "Not running post_install as we're building a bottle" - puts "You can run it manually using `brew postinstall #{formula.full_name}`" - else - post_install - end + if build_bottle? + ohai "Not running post_install as we're building a bottle" + puts "You can run it manually using `brew postinstall #{formula.full_name}`" + else + post_install end caveats @@ -832,12 +830,6 @@ class FormulaInstaller skip_linkage = formula.bottle_specification.skip_relocation? keg.replace_placeholders_with_locations tab.changed_files, skip_linkage: skip_linkage - Pathname.glob("#{formula.bottle_prefix}/{etc,var}/**/*") do |path| - path.extend(InstallRenamed) - path.cp_path_sub(formula.bottle_prefix, HOMEBREW_PREFIX) - end - FileUtils.rm_rf formula.bottle_prefix - tab = Tab.for_keg(keg) CxxStdlib.check_compatibility( diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index 2309c36fb104ad5e162d1ca7267bc74281ee5698..1f98ca525bb7fb9622faacda26a1b210db172e69 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -10,7 +10,6 @@ RSpec::Matchers.alias_matcher :supersede_an_installed_formula, :be_supersedes_an RSpec::Matchers.alias_matcher :have_changed_alias, :be_alias_changed RSpec::Matchers.alias_matcher :have_option_defined, :be_option_defined -RSpec::Matchers.alias_matcher :have_post_install_defined, :be_post_install_defined RSpec::Matchers.alias_matcher :have_test_defined, :be_test_defined RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle @@ -624,23 +623,6 @@ describe Formula do expect(f.desc).to eq("a formula") end - specify "#post_install_defined?" do - f1 = formula do - url "foo-1.0" - - def post_install - # do nothing - end - end - - f2 = formula do - url "foo-1.0" - end - - expect(f1).to have_post_install_defined - expect(f2).not_to have_post_install_defined - end - specify "#test_defined?" do f1 = formula do url "foo-1.0"