The form "attr :name, true" is deprecated and causes Ruby to emit a
warning in verbose mode. Using attr_{reader,writer,accessor} is more
clear anyway, so do so.
Expand requirements recursively while applying the same optional? and
recommended? filters that dependencies are run through. Options
generated by requirements are now checked against the correct list of
requirements, eliminating the temporary "best guess" logic in the
installer.
We skip build-time deps when installing from bottles. However, the
current logic only considers the root, rather than the actual dependent
formula. Given
A (bottled)
|__B (not bottled)
|__C (build-time)
C will be pruned from the effective dependency tree of A. This is wrong,
because C is required in order to build B.
Fix this by examining the current dependent rather than the root.
FixesHomebrew/homebrew#17356.
The array of options that is passed to the spawned build process is a
combination of the current ARGV, options passed in by a dependent
formula, and an existing install receipt. The objects that are
interacting here each expect the resulting collection to have certain
properties, and the expectations are not consistent.
Clear up this confusing mess by only dealing with Options collections.
This keeps our representation of options uniform across the codebase.
We can remove BuildOptions dependency on HomebrewArgvExtension, which
allows us to pass any Array-like collection to Tab.create. The only
other site inside of FormulaInstaller that uses the array is the #exec
call, and there it is splatted and thus we can substitute our Options
collection there as well.
Formulae can now pass build options to dependencies. The following
syntax is supported:
depends_on 'foo' => 'with-bar'
depends_on 'foo' => ['with-bar', 'with-baz']
If a dependency is already installed but lacks the required build
options, an exception is raised. Eventually we may be able to just stash
the existing keg and reinstall it with the combined set of used_options
and passed options, but enabling that is left for another day.
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.
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").
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.
- Name of the brewed formula in "Summary" heading.
- At the beginning of the summary line a 🍺 is given out
(but only on Lion or above). This acts as a nice
visual marker for the end of a brew-ing process.
- When brewing a dependency, the name is highlighted in green.
- `oh1` is bold, too (like ohai).
ClosesHomebrew/homebrew#16020.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
When a dependency of a formula specified on the command-line is also
specified, *after* the dependent formula, installation proceeds as part
of the dependent's dependency tree and then is attempted again because
the user asked for it explicitly. This results in the installer raising
a CannotInstallFormulaError because it has already been installed.
For example:
$ brew install graphviz pkg-config
==> Installing graphviz dependency: pkg-config
...
==> Installing graphviz
...
Error: pkg-config-0.27.1 already installed
We already have a mechanism for dealing with this, but it does not kick
in early enough. Move the installation attempt check into
FormulaInstaller#check_install_sanity and catch the exception in the
appropriate places.
FixesHomebrew/homebrew#16957.
This code makes assumptions about the existence of prefix which are
valid in the context of the installer, but not necessarily in the
context of `brew info`, thus `brew info` on an outdated formula errors
out.
This reverts commit e5b53dd64b769b67805d1054d906f7083939d905.
Only limited debugging functionality is available to things that involve
the Readline formula, but it is better than crashing outright.
c.f. Homebrew/homebrew#15776.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
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>
As discussed with mistym, it's not only compiled code that goes in
/usr/lib, but any types of libraries. As such, .pm was added to the
valid extensions list a while back. Unfortunately, .sh was not added,
even though configuration includes and platform function library shell
files are often put in /usr/lib as shellscript libraries. This patch
adds .sh to the list of valid library extensions.
ClosesHomebrew/homebrew#14993.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
All logs are now stored from each command executed in Formula.install.
Error output is truncated to five lines in an attempt to not overwhelm the user and to encourage users to read the error output and report the bug properly. Maybe we can get that figure up from 70% to 90%.
- Avoid ENOTDIR by ensuring that the directories we are checking are
actually directories.
- DRY up the check_PATH method; paths are already available via the
global ORIGINAL_PATHS.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>