Homebrew/homebrew — pull request #31199 by jacknagel (2014-07-29 02:03:39+00:00)
Title: Simplify implementation of DATA patches

Background: the `DATA` constant is defined at the top level, and it is only defined if the executing script has an `__END__`. Under normal execution, the executing script is `brew.rb`. To support embedded patches, we `exec` the formula file, so that `DATA` points at the patch, and use an `at_exit` hook to actually run the build.

The `exec` forces us to do a lot of extra work. For example, we have to perform dependency expansion twice, since we don't share any data with the main process. We also have to worry about things like repopulating `ARGV` correctly. These things have been the source of countless bugs. I want to remove the need for the `exec` so that we don't have to do all this extra work. I estimate there are about 300 lines of code that can be straight up deleted if we don't `exec`.

Step one is decoupling us from Ruby's implementation of `DATA`. Instead of relying on Ruby to populate the `DATA` constant, we can just pass in the path to the formula file and read the patch from that file. (Actually, we already do this in `unpack`.)