Couldn't make this atomic, apologies.
Fixes a few things, like deps failing to build not aborting the install.
--force now works properly again.
Overall more robust code. I went back over it all and gave it a lot of
thought.
Cleaner separation of logic. Less code in brew, now the only code there is
ARGV handling, and basic sanity checks.
Not extending ARGV or ENV in global now as that would propagate to other tools
or utilities you may write.
This rewrite attempts to sort out where the Prefix, Cellar, and
Repository are relative to the real and symlinked 'brew' command.
Also included is a --config option which dumps all of these variables.
Any top-level script must define a "BREW_FILE" that gives the path
to brew as it exists in the path. 'brew' itself just uses __FILE__ and
install.rb does a `which brew` (there may be a better way?)
The Prefix is always relative to the location of brew as it exists in
the path. Thus, whether or not /usr/local/bin/brew is a symlink or real
file, the Prefix is always /usr/local. If you have brew in some other
prefix, such as /nonstandard/bin/brew, then '/nonstandard/ will be
managed by brew instead.
The Repository, Cellar, and "Library/Homebrew" required code is always
found relative to the "real" path or brew. If brew is a real file in
/usr/local/bin/brew, then everything else will be found in /usr/local
and we'll expect a /usr/local/.git
Otherwise, we dereference brew's symlink and look for everything else
relative to that path instead.
Using an error pipe.
The use of ENV[HOMEBREW_ERROR_PIPE] feels wrong, but I wasn't sure how else to
proxy the file descriptor to the child process since the fork immediately
calls exec.
I found yet another instance where the escaping wasn't perfect, so got fed up and just did it in Ruby. I hope this works for all existing usage. It should.
The bonus here is that you can use RegExps now.
During the link step, if the destination symlink already exists, unlink it, and create a directory instead, then relink the original contents. Then continue linking the formula in question.
FixesHomebrew/homebrew#62
Ruby throws if CWD doesn't exist, even when you aren't doing anything related to the CWD. Sucks. So at least show the user a friendly error message rather than looking broken.
GitDownloadStrategy and MercurialDownloadStrategy
now can be used like this:
head 'git://server/repo.git', :branch => 'stable'
head 'hg://server/repo/', :tag => '1.0.4'
HFS+ handles the + fine. However the Ruby class name needs a s/+/x/g.
I acknowledge that supporting + will make it harder to port to certain other
filesystems. However that's your challenge! :D
Since plenty of formula don't require it, I don't want to insist on gcc being installed. A better check is if gcc is required then check for version 4.2, which is all we support.
However I can't easily do that. So I'm risking bug reports from people who didn't read the installation instructions and didn't install the right Xcode. But they deserver derision :P