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>
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.
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.
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.
The recent fix that prevents "-v" from triggering source downloads
exposed a different bug that allowed the build script to download the
bottled package instead of the source package; fix the logic.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
When building software "linking step did not complete" sounds
like ld failed. Let's be clear about this.
ClosesHomebrew/homebrew#14407.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Usually, the "foo-version already installed" error is printed by
FormulaInstaller. However, if an up-to-date formula that has outdated
deps is passed on the command line, we proceed to upgrade the deps and
then print a message saying that the formulae given on the command line
is already installed.
Catch this earlier, when the outdated list is being populated, print an
appropriate message, and skip the up-to-date formula.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
In FormulaInstaller#install, needed_deps is created without first
filtering ARGV for flags like --HEAD. In practice, this means that
sometimes needed_deps will contain dependencies that are actually
already installed; --HEAD causes Formula#installed_prefix to differ and
thus checking Formula#installed? will result in false negatives.
This can trigger weird bugs; for example, Homebrew/homebrew#10380, where the "Installing
foo" header is displayed even though no dependencies were previously
installed.
Fix this by filtering ARGV before testing for installed dependencies,
and do the same for requirements to maintain symmetry, and because some
requiremnts check Formula#installed? as well.
FixesHomebrew/homebrew#10380.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Currently FormulaInstaller "forgets" about the requirements of
dependencies, as dependencies are recursively expanded by the first
FormulaInstaller instance, and then ignored by subsequent instances to
prevent duplicate installation attempts. These requirements then have
their messages displayed, but the fatal check is skipped and thus no
exception is raised.
Now that we have Formula#recursive_requirements, we can mirror what we
are doing with dependencies and recursively expand requirements up
front.
While at it, fix a bug in determining Requirement equality that resulted
in unique requirements being eliminated from a formula's set of
recursive requirements.
FixesHomebrew/homebrew#12290.
FixesHomebrew/homebrew#14084.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>