327 Commits

Author SHA1 Message Date
Jack Nagel
c53af42117 Allow env DSL to take a block
In addition to

  env :userpaths
  env :std

requirements can now do

  env do
    append 'PATH', '/some/path/to/bin'
    # and more
  end
2013-01-21 17:24:10 -06:00
Jack Nagel
58440a2c5b Make Formula#installed? more idiomatic 2013-01-17 21:30:23 -06:00
Jack Nagel
79295ecaf8 More robust way to avoid attempting to marshal Procs 2013-01-09 19:25:02 -06:00
Jack Nagel
003a9e7fd7 Don't store test Proc if we might need to marshall the formula
Procs cannot be marshalled, but formula objects may be as part of the
BuildError exception. If the formula object has a reference to a Proc,
this will fail.

Work around it by not storing the test Procs during installations.
2013-01-09 18:33:35 -06:00
Jack Nagel
967a60a054 Detect when tests are defined 2013-01-07 17:37:28 -06:00
Mike McQuaid
7473d2b12f Fix local bottle installation with hyphens. 2013-01-07 20:27:27 +00:00
Jack Nagel
1c99c68594 Allow tests to be specified in the DSL
Tests can now be specified as a block in the DSL. A temporary test
directory is set up automatically when calling Formula#test. The
semantics of the test remain the same: the block can either raise an
exception or return false to signal failure.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2013-01-06 21:22:31 -06:00
Jack Nagel
a358bee8e2 Clean up BuildEnvironment interface a bit 2012-12-26 14:37:02 -06:00
Jack Nagel
68d1dfe5d7 Revert "Add launchctl_instructions method"
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.
2012-12-16 19:56:15 -06:00
Lorenzo Manacorda
d23366ae9a Add launchctl_instructions method
Closes Homebrew/homebrew#16604.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2012-12-16 23:31:30 +00:00
Jack Nagel
8dafce0d95 Properly escape log filename
Closes Homebrew/homebrew#16485.
2012-12-11 14:01:36 -06:00
Mike McQuaid
c4fb2b73e2 Support installing bottles from local files. 2012-12-01 12:45:23 +00:00
Misty De Meo
9c294364c6 Fix Formula.factory for Formula subclasses
Fixes Homebrew/homebrew#16288.
2012-11-28 10:58:29 -06:00
Misty De Meo
a171ec18fe Formula.factory: raise on encountering non-Formula
Formula.factory naively assumed that any already-loaded constant
fed into it was a formula, with confusing results when trying to
`brew install` a name from the ruby stdlib.

Fixes Homebrew/homebrew#16284.
2012-11-28 10:01:00 -06:00
Mike McQuaid
faf51f254d Make generic caveats for launchd plist files. 2012-11-25 23:05:52 +00:00
Jack Nagel
c9ef48724c Remove outdated comment 2012-11-24 17:42:45 -06:00
Jack Nagel
bba85b4bd9 Formula#system: don't try to close a closed stream
The new formula debugger users continuations to jump back up the stack,
and thus anything that has the potential to be executed twice (i.e.
ensure blocks) needs to to be essentially idempotent.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-11-09 14:04:08 -06:00
Jack Nagel
45e208d26b Move conflict message into conflict class 2012-11-06 17:48:34 -06:00
Max Howell
beb5f97614 Fix build failure being non-verbose when --verbose 2012-10-31 11:28:29 -04:00
Adam Vandenberg
1b991c5aae formula: shorten path helpers 2012-10-28 08:54:54 -07:00
Camillo Lugaresi
18dbe47f9f debrew: formula debugging for homebrew
A new feature for easing the pain of working with complex formulas, or
formulas for large packages. When running brew in debug mode (-d), if an
exception propagates outside the formula's install method, you now get a menu
which lets you return to the point where the exception was raised and perfom
several useful actions, such as:
- printing a backtrace
- entering IRB to examine the context and test ruby code
- entering the debugger (if ruby-debug is available)
- entering a shell
- ignoring the exception or proceeding with the raise as normal

Signed-off-by: Max Howell <mxcl@me.com>

* Fixed conflict in build.rb.
* Removed old debug handling in Formula.brew.

Closes Homebrew/homebrew#10435.
2012-10-28 11:39:02 -04:00
Adam Vandenberg
4cbf036c17 Allow varags to skip_clean 2012-10-21 13:24:02 -07:00
Misty De Meo
bbfb6400c7 Manage Requirements using ComparableSet
ComparableSet only allows a single object of a given class,
choosing the object with the greatest value. This was mainly created
for Requirements, so that, e.g., two X11Dependencies of differing
strictness don't both end up in the same requirement set.

Fixes Homebrew/homebrew#15240.
2012-10-15 09:46:29 -05:00
Jack Nagel
35c47f81f2 Don't munge tapped formula names in Formula.factory
This started happening as a result of bbc167b, which avoids reloading
previously defined formulae. The exception alters its message if the
name parameter appears to be a tapped formula, but this is lost if we
only pass in the "stem" of the pathname.

Long-term this probably needs some restructuring, perhaps with a
separate exception for tapped formula, but for now this should re-enable
the more useful error message.

Fixes Homebrew/homebrew#15374.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-09 14:49:38 -05:00
Max Howell
7a75915345 Only handle build-errors when it's a build-error
Refs Homebrew/homebrew#15164.
2012-09-28 09:37:38 -04:00
Jack Nagel
6ebcccdcc5 Make FileUtils extension available globally
Now that we are monkeypatching copy_metadata, we should load our
extension up front for consistency.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-09-27 16:22:01 -05:00
Misty De Meo
61ccf12e85 Don't set $VERBOSE when building nonverbosely
Setting $VERBOSE in the environment makes the haskell-platform build
fall down, which is surely one of the odder bugs I've run into.

See Homebrew/homebrew#15164.
2012-09-27 15:39:24 -05:00
Max Howell
5f8047e9a4 When builds fail verbosely, be verbose 2012-09-27 15:39:35 -04:00
Max Howell
a217b03952 Clean up and improve build-error output and logs
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%.
2012-09-25 11:31:56 -04:00
Misty De Meo
2f2645e962 info: Add JSON output
Output JSON with the --json=v1 option. Output is in an array, and
supports one or more formulae (or all, with the --all option).

Why 'v1'? The format is unstable, presumably we'll deprecate it
someday. It should be solid by Homebrew 1.0.

Closes Homebrew/homebrew#13299.
2012-09-17 20:01:37 -05:00
Adam Vandenberg
88ad4c061d Support env :std, :userpaths
Closes Homebrew/homebrew#14654.
2012-09-14 09:14:48 -07:00
Adam Vandenberg
22685cb89d Install plists by default 2012-09-09 13:02:48 -07:00
Adam Vandenberg
f4d967e96e allow skip_clean :la 2012-09-09 13:01:56 -07:00
Max Howell
04173d55c2 Hide --disable-debug from non verbose output also 2012-08-31 10:22:09 -04:00
Max Howell
d4503b1202 Fixes Homebrew/homebrew#14542; ocaml superenv issues
This patch removes most of the settings for CC, CXX etc. because we are trying to be minimal. Then we force the compiler to Homebrew's choice underneath in superenv. We however leave LD because we prefer that build-systems use the c-compiler for linking, it generally works better (copiously tested), however when the build-system explicitly calls ld, we respect that. This gets around the ocaml bug in question, since somehow clang was crashing during link, but the ld tool itself (which is kind of clang, kind of llvm-gcc) is okay with this.

Also moved the setting of O (so that cc-args are refurbished) into a make wrapper. Not sure if this matter much, but seems more consistent.
2012-08-30 20:02:29 -04:00
Max Howell
5790f4b523 Display skip-clean warning only before clean
Not anytime the formula loads.
2012-08-29 15:43:28 -04:00
Max Howell
4feb8e1cb4 Deprecate skip_clean :all
This was mostly used to prevent stripping. Now we don't strip. Force formula to remove this setting or be more specific about folders they don't want pruned.
2012-08-29 14:45:04 -04:00
Max Howell
65d195dcaa 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.
2012-08-29 12:41:34 -04:00
Max Howell
f02d81ecbf 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.
2012-08-29 12:41:33 -04:00
Adam Vandenberg
dfd35db4d1 Formula factory: add comment 2012-08-26 17:08:09 -07:00
Adam Vandenberg
f1d0f7adbb Formula factory: re-raise certain NameErrors.
Some name errors, such as NoMethodError, represent programming errors.
Re-raise them to get a usable error message.

Closes Homebrew/homebrew#14467.
2012-08-26 17:06:38 -07:00
Jack Nagel
fd151f8999 factory: always check const_defined? before requiring
Specifying dependencies with a URL works, even if by accident, but
factory is called repeatedly on this URL and this results in multiple
downloads of the same file.

Fix this by checking const_defined? here too, and DRY up the code a bit.

Fixes Homebrew/homebrew#14285.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-23 18:13:54 -05:00
Jack Nagel
5e0cbdab9b factory: rescue NameError
Due to the new const_defined? checks, passing certain names (such as
those that start with a digit) that are illegal constant names will
raise NameError. Catch this and error out gracefully, as we would have
previously.

Fixes Homebrew/homebrew#14342.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-21 15:55:20 -05:00
Max Howell
ee11f32fb7 conflicts_with message: recommend unlink
Yes uninstall works, but lets not push people towards that, they can presumably guess that, in the rare case they'd prefer that option.
2012-08-21 12:09:06 -04:00
Max Howell
9274f7cda1 Formula.Enumerable
Deprecated Formula.all, replaced usage with more appropriate enumerable options. Just check out how much nicer `brew audit` runs now.
2012-08-21 12:09:05 -04:00
Jack Nagel
35e32f352d factory: don't reload previously defined formulae
build.rb calls Formula.factory to get a usable Formula object to pass to
its install method. However, because the formula file is the actual
executing script, its class is already defined, and loading it again
causes the class to be re-evaluated, which, unfortunately, is not
idempotent.

This bug has existed for a very long time, and its side effects include
duplicate entries the deps array and mirrors array, among others.
Fortunately, the fix is very simple.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-19 12:04:44 -05:00
Jack Nagel
c6b3cd7cf4 Don't lie about upgrading up-to-date formulae
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>
2012-08-18 19:33:39 -05:00
Jack Nagel
329f0a8490 Replace version strings with Version objects 2012-08-18 11:12:08 -05:00
Jack Nagel
53cf970312 build: expand requirements recursively when modifying ENV
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-14 22:35:28 -05:00
Max Howell
b0e50ba13d Formula.select and Formula.installed 2012-08-13 10:14:59 -04:00