From 25df0c03d6abd79fbc103f3be9df38d48bd4f938 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Tue, 20 Sep 2016 14:42:29 -0700 Subject: [PATCH] Store the formula used to build the keg in the keg Store the formula used to build the keg inside the keg in a file named NAME/VERSION/.brew/NAME.rb after removing the bottle do ... end block. See https://github.com/Homebrew/brew-evolution/pull/6. Closes https://github.com/Homebrew/brew/issues/931. --- Library/Homebrew/cmd/list.rb | 2 ++ Library/Homebrew/formula_installer.rb | 6 ++++++ Library/Homebrew/test/test_formula_installer.rb | 1 + 3 files changed, 9 insertions(+) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 4fdd8a85e6..d2eebb5f1b 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -140,6 +140,8 @@ class PrettyListing # dylibs have multiple symlinks and we don't care about them (pnn.extname == ".dylib" || pnn.extname == ".pc") && !pnn.symlink? end + when ".brew" + # Ignore .brew else if pn.directory? if pn.symlink? diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 6e8f2e3b75..2e40e558d3 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -260,6 +260,12 @@ class FormulaInstaller compute_and_install_dependencies if not_pouring && !ignore_deps? build clean + + # Store the formula used to build the keg in the keg. + s = formula.path.read.gsub(/ bottle do.+?end\n\n?/m, "") + brew_prefix = formula.prefix/".brew" + brew_prefix.mkdir + Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s) end build_bottle_postinstall if build_bottle? diff --git a/Library/Homebrew/test/test_formula_installer.rb b/Library/Homebrew/test/test_formula_installer.rb index da0404c359..5b937d1df3 100644 --- a/Library/Homebrew/test/test_formula_installer.rb +++ b/Library/Homebrew/test/test_formula_installer.rb @@ -58,6 +58,7 @@ class InstallTests < Homebrew::TestCase bin = HOMEBREW_PREFIX+"bin" assert_predicate bin, :directory? assert_equal 3, bin.children.length + assert_predicate f.prefix/".brew/testball.rb", :readable? end end