Fix SHA1 of distribute in pypy formula

The SHA1 added in commit 3c5ca25c in the batch conversion from MD5 to SHA1
(see #14653) did not match the tarball's SHA1 checksum.

Closes #14762.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
doctor: ignore case when checking PATH for config scripts

Fixes #14752.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Don't raise when expanding ORIGINAL_PATHS

File.expand_path raises ArgumentError when it is passed a path with a
nonexistent username, e.g.:

  $ PATH=~foo/bin:$PATH brew
  /usr/local/Library/Homebrew/global.rb:97:in `expand_path': user foo
  doesn't exist (ArgumentError)

However, `brew doctor` does its own expansion of PATH entries and
outputs warnings if this happens, so let's just ignore it here and
continue on our way.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Extend Set to allow repetition (*)

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Return the block value in ARGV.filter_for_dependencies

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Tab: provide an interface similar to BuildOptions

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>
Install receipt housekeeping

- Since using opt_prefix means we can find receipts for keg-only
  formulae, try it first and fall back on using linked_keg.
- Make the tab filename a constant instead of duplicating the string
  everywhere.
- Address a couple of other things that need cleanup.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
BuildOptions: simplify setting description

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
BuildOptions: check has_option? for universal and 32-bit

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Provide a common interface for Dependency and Requirement

Introduce a new Dependable module that provides useful interrogation
methods for Dependency and Requirement. These methods are mapped to
dependency tags in formula (:build, :optional, and :recommended).

Previously only Dependency objects recorded tags; this allows
Requirements to do the same.

Move Requirement subclasses to a separate file.
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: disambiguate show_header usage

show_header should default to false (we don't want to display it in the
case of installing a single formula without dependencies), but it only
worked this way by accident.

The assignment "show_header = true" creates a local variable named
show_header, and in the case where needed_deps is empty and this
assignment is not actually executed, the latter usage evaluates the
local variable instead of calling the method.

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.

`brew uninstall` learns to respect the lock as well, so that kegs in the
dependency tree of foo can't be removed when another process is
installing foo.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Respect operation lock in link and unlink

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

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Add support for optional and recommended deps

Optional deps are not installed by default but generate a corresponding
"with-foo" option for the formula. Recommended deps _are_ installed by
default, and generate a corresponding "without-foo" option.

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