gource: update patch comment
Only mark install as attempted if it was actually attempted

Commit 30a08f5cc707 ("Don't attempt installation multiple times") was
correct in raising FormulaInstallationAlreadyAttemptedError early enough
to prevent the other exceptions in #check_install_sanity from being
raised, but it should not have moved the point at which formulae are
added to the attempted set. Doing so prevents the installer from being
instantiated multiple times on the same formula, even if installation
was never attempted.

Put it back where it belongs.
Clean up Tab creation
Move option comparison into BuildOptions
Options can be used interchangeably with Strings

We want to be able to use Option objects in place of strings and have
this be transparent. Defining to_str means that methods like
Kernel#system and Kernel#exec will be able to perform an implicit
conversion.
Update multi_json to 1.5.0
Options can be dumped as JSON
BuildOptions: simplify setting description
BuildOptions: check has_option? for universal and 32-bit
Refactor option handling internals

Currently we handle options in several ways, and it is hard to remember
what code needs an option string ("--foo"), what needs only the name
("foo") and what needs an Option object.

Now that Option objects can act as strings and be converted to JSON, we
can start using them instead of passing around strings between Formula
objects, Tab objects, and ARGV-style arrays.

The Options class is a special collection that can be queried for the
inclusion of options in any form: '--foo', 'foo', or Option.new("foo").
Move BuildOptions to a separate file
Tests for BuildOptions
Make Formula#installed? more idiomatic
Tab#with? to mirror BuildOptions#with?

Eventually a common interface could be factored out into a module, but
for now this will suffice.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Formula#recursive_dependencies

This behaves like recursive_deps, but the resulting list consists of
Dependency objects instead of Formula objects. The list maintains the
installable order property of recursive_deps.

While in the area, add some comments clarifying the purpose of related
methods.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Dependency#to_formula and associated helpers

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
FormulaInstaller: factor out requirement checking

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
FormulaInstaller: factor out dependency installation

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
FormulaInstaller: skip build-time deps for bottles

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
FormulaInstaller: implement installation locks

FormulaInstaller now attempts to take a lock on a "foo.brewing" file for
the formula and all of its dependencies before attempting installation.

The lock is an advisory lock implemented using flock(), and as such it
only locks out other processes that attempt to take the lock. It also
means that it is never necessary to manually remove the lock file,
because the lock is not enforced by I/O.

The uninstall, link, and unlink commands all learn to respect this lock
as well, so that the installation cannot be corrupted by a concurrent
Homebrew process, and keg operations cannot occur simultaneously.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>