Produce good error messages for bad tarballs
Record HEAD SHA and date of installs in receipt
Create active symlinks for installed formula

Similar to the LinkedKegs record, we write a symlink for installed kegs to PREFIX/opt.

Unlike the linked-keg record, unlinking doesn't remove the link, only uninstalling, and keg-only formula have a record too.

The reason for this addition is so that formula that depend on keg-only formula can build against the opt directory and not the cellar keg. Thus surviving upgrades.

To enforce this fix_install_names and built were adapted to use the opt path.

Standard kegs also create an opt symlink so that caveats can now refer to the opt directory and thus provide steps that survive upgrades too.

Thus the choice of /opt. It is short, neat and the right choice: POSIX dictates that opt is for stand-alone prefixes of software.
Figure out if we can cleanup keg-only kegs
Use opt paths in keg-only messages
superenv: build-environments that just work

1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.

Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.

The previous ENV-system is still available when --env=std is specified.

superenv applies to Xcode >= 4.3 only currently.
Force --env=std for stuff using scons, etc.

Python et al, require stdenv because otherwise pip, gem, etc. don't work. Can be fixed, just I'm not doing it now.

We want a DSL to do this but I couldn't be bothered to make that work etc. I want to commit. Apologies.
Support HOMEBREW_MAKE_JOBS
Superenv wrapper for sed

Fixes Mountain Lion specific sed issue.

Provided scripts don't use the full-path to see we are fine. They never do though, that would assume too much.
Allow eg. `brew --env libxml2`

Example useful usage:

    eval $(brew --env gettext) && clang -Wl,-t -lssl 2>/dev/null
Much better CTRL-C handling

Let's not show weird error messages when user interrupts during various stages of brew initialization.

Tested by doing `for x in $(brew search); do brew install $x; done` and pressing CTRL-C at random short intervals.
If installed but not linked, say so

Rationale: if ack is unlinked but installed, typing ack does nothing, but then user tries to install and it says it is already installed. What gives? The user thinks.

Formula ending up unlinked can happen due to failures during the link phase and we recommend unlinking formula for conflicts. So common enough to justify this amendment.
Ensure mktemp cleans up after itself

Ignore interrupts.
Attempt to fix opt link if absent

This is mainly to prevent errors when users for the transitionary period where most installed kegs do not have an opt link.
Make `brew --prefix` very fast

Because people use this in .bash_profile etc. We should be as fast as possible.
Always find git and svn without trying hard

Two wrapper scripts that find git and svn using the ENV variables we support and then searching through the PATH and looking inside Xcode.app if necessary.

Now just calling git or svn in Homebrew code will find and exec the right tool and we can stop fussing.

Apologies to @adamv who is probably unimpressed that the cmds directory has non-commands in it now. If it's consolation these are temporary pending some more work on superenv whereby some more directories are created under the superenv root.
Speed up brew instantiation

Adding MacOS.dev_tools_path to our PATH was slow. We no longer need to do this because of the previous commit making a script wrapper for git and svn. It was slow because the function calls out to lots of slow utilities to determine this path.
Warn user if they set CFLAGS, etc. with superenv

Since we remove some CFLAGS under their noses, this would otherwise be quite confusing.

Notably, this will now trigger in numerous formula. Sucks.
If exception has no message raise again

Shows full backtrace, which is useful. Now blank "raise" statements are the equivalent of admitting programmer error. The backtrace will be useful.
Doctor suggest `git clean -f` if unstaged files

This is safe, I tested various scenarios, including Homebrew installed in ~. The only files that are removed are unexpected files in Homebrew's already managed directories.