537 Commits

Author SHA1 Message Date
Max Howell
4ce19ae2d7 Better error message if exec fails 2009-12-12 16:23:04 +00:00
Ben Olive
5131475ae1 Comments reflect actual patch level of 1.
Updated comments to match new default patch level from revision 4fe374d
2009-12-05 18:05:20 +00:00
Max Howell
4cea6157a1 include FileUtils into Formula
Thus mv, rm etc, functions are almost as handy as pure shell scripting, without issues related to spaces in filenames.
2009-12-01 12:07:34 +00:00
Adam Vandenberg
224beabdd5 Refactor formula_test. 2009-11-19 14:13:31 -08:00
Adam Vandenberg
7366a41268 New command 'brew deps [formula]'
Where brew info will show the next-level-down dependencies, brew deps
will show all of the formulae that a given formula depends on.
2009-11-19 14:03:07 -08:00
Adam Vandenberg
95e398ab13 Add alias support to formulae
* brew install will find an aliased formula
* aliases are searched against
* warn when creating a new formula that has an existing alias.

If Subversion has an alias "svn", then warn when the user tries to
create a new formula "svn". The formula can still be created, though
the user should make sure it's not a duplicate of the existing
aliased one.

Subversion and Objective-Caml formulas get some alises here, so we have
something to test against.
2009-11-19 14:03:07 -08:00
Adam Vandenberg
af29299f37 Add brew command 'uses'
'uses' shows the formulas that depend on a formula given on the
command-line.
2009-11-19 14:03:07 -08:00
Adam Vandenberg
ed4992f467 Add a Formulary class for managing the Formulae
These methods could be static on Formula, but splitting them out makes
it clear to formular authors that these functions don't have anything
to do with writing new formulas.
2009-11-19 14:03:07 -08:00
Max Howell
4bd32c615e Fix system() exception showing regression
Rather than showing a backtrace that says "couldn't find command blah". Admittedly it's possible that the error will be something else, but unlikely. And this is neater.

Ideally we'd push the bt through an error pipe like we do with install.rb. And I guess we'll do this eventually.
2009-11-11 19:42:35 +00:00
Max Howell
75c7c942a1 Don't ignore interupts during Formula.system
As I understand it (I tested too), signal propogation is handled by the parent Ruby process. However this was working mostly anyway. So I don't fully understand what is going on. However this seems to not hang in Process.wait where it was before for one test case.
2009-11-09 17:55:13 +00:00
Max Howell
fe15b9b003 Reap the process or make zombies 2009-11-08 15:21:15 +00:00
Max Howell
22afc5e1c7 Use our own popen implementation in Formula.system
The rationale here is that the --verbose mode had a bug where it didn't escape its parameters properly. Which caused ocassionally cryptic issues.
2009-11-08 15:21:09 +00:00
Max Howell
1e879eaee8 Propagate exit status in ExecutioError exception 2009-11-07 18:22:36 +00:00
Max Howell
a4e86bb326 Move BuildError and ExceutionError to global.h
More sensible, and fixes brew
2009-11-07 18:22:35 +00:00
Max Howell
fc9ea77bb3 Better md5 mismatch exception 2009-10-24 16:20:11 +01:00
Max Howell
3d36b01da3 Camelcase class names around the . from filenames
Eg. shell.fm -> ShellFm
2009-10-19 13:48:34 +01:00
Max Howell
92964742aa Allow svn+http:// urls 2009-10-19 04:02:49 +01:00
Jannis Leidel
ef02031d7c Fix Homebrew/homebrew#52: Add ability to checkout a branch or tag.
GitDownloadStrategy and MercurialDownloadStrategy
now can be used like this:

  head 'git://server/repo.git', :branch => 'stable'
  head 'hg://server/repo/', :tag => '1.0.4'
2009-10-19 04:02:48 +01:00
Max Howell
53d6f617d7 Allow formula names with '+' in them
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
2009-10-19 04:02:48 +01:00
Max Howell
ca1a6492bc s/require 'brewkit'/require 'formula'/g
brewkit.rb changes ENV destructively, so lets not do that everytime a formula
is required. Now it's possible for other tools to require a formula
description without worrying about side-effects.
2009-10-15 16:48:03 +01:00
Max Howell
ceef7729e0 Modernise the GRC formula somewhat
This was one of the first ones I wrote, so it lacks some of our more recent touches.
2009-10-03 15:23:45 +01:00
Max Howell
c130cf3e71 HttpDownloadStrategy renamed CurlDownloadStrategy
Because people didn't realise it was actually curl and thus supports eg. ftp too.
2009-10-02 20:01:23 +01:00
Max Howell
5f0d2dc032 Formula.etc is now HOMEBREW_PREFIX/etc
You generally don't want to have to copy the configuration to a new directory when you upgrade.
2009-10-02 16:30:33 +01:00
Adam Vandenberg
e66364502d Add SourceForge pattern to SubversionDownloadStrategy 2009-10-01 10:23:02 -07:00
Max Howell
db2ccd294d Formula.var is now HOMEBREW_PREFIX/var 2009-10-01 15:17:31 +01:00
Austin Ziegler
668e3ee080 Adding CVS and Mercurial download strategies. 2009-09-30 18:52:12 +01:00
Max Howell
9d3ddfb466 Var goes back in the keg. Fixes Homebrew/homebrew#67
I'm not sure about this still, as if you uninstall mysql do you want to lose
all the var stuff it created? Maybe. Probably not.

But there were issues unresolved having it in the unversioned-keg. So I'd
rather look at this again later, and fix the bugs without hacks for now.
2009-09-30 01:24:49 +01:00
Max Howell
98081ce26a Don't fail when cleaning if skip_clean_paths is empty 2009-09-29 23:52:21 +01:00
Andre Arko
cacf8d8aa4 Allow skip_clean as a class method
Pass in a list of any files that you don't want cleaned
with a path relative to the cellar. e.g. `strip_paths ['bin/znc']`
It's backwards compatible with def strip_clean?, at least for now.

The znc formula is updated as an example.
2009-09-29 23:34:16 +01:00
Andre Arko
64bab9d746 eval bad 2009-09-29 23:34:16 +01:00
Max Howell
3971a5666c Oops. Don't raise for homepages. Silly. 2009-09-26 02:20:00 +01:00
Max Howell
4b5d39feab Throw if no homepage set
That'll teach you!
2009-09-25 19:22:02 +01:00
Adam Vandenberg
b2a857da54 Add better error message for misnamed formula class. 2009-09-25 19:20:59 +01:00
Max Howell
44a1fa418e Use full paths to all system utilities
Otherwise you run the risk of not running the exact version / make of the utility you planned.

Fixes Homebrew/homebrew#48

Really we need to do this formula too, so I guess a make and cmake function are on the way…
2009-09-24 18:26:24 +01:00
Clinton R. Nixon
2668e2aeff DRYed up "@foo=self.class.foo unless @foo" statements
Using the example from the existing code:

  CHECKSUM_TYPES.each do |type|
    if !instance_variable_defined?("@#{type}")
      class_value = self.class.send(type)
      instance_variable_set("@#{type}", class_value) if class_value
    end
  end

I extracted that block into a method 'set_instance_variable' which I
then used in all places where this behavior was being used.
2009-09-24 18:26:16 +01:00
Clinton R. Nixon
44a3d59630 Added small DSL for formulas
You can now use "url", "version", "homepage", and any checksums as
class methods, like so:

    class Dos2unix <Formula
      url 'http://www.sfr-fresh.com/linux/misc/old/dos2unix-3.1.tar.gz'
      md5 '25ff56bab202de63ea6f6c211c416e96'
      homepage 'http://www.sfr-fresh.com/linux/misc/'
    end

The previous usage ("@url = 'http://example.com/tarball.tgz'") still
works, maintaining compatibility with previous formulas.

"dos2unix.rb" is translated into the new format as an example.
2009-09-23 14:51:11 -04:00
Max Howell
3094a162ac Don't always say "Patching" 2009-09-21 23:51:31 +01:00
Max Howell
e9701dbc81 Merge branch 'deps'
Conflicts:
	Library/Formula/imagemagick.rb
	Library/Formula/taglib.rb
	Library/Homebrew/brew.h.rb
	Library/Homebrew/formula.rb
	bin/brew
2009-09-21 18:46:28 +01:00
Max Howell
77dd27e8e6 Dependency resolution with fancy syntax
Is it a DSL? No. But people call it that apparently.

To add a dependency:

class Doe <Formula
  depends_on 'ray'
  depends_on 'mee' => :optional
  depends_on 'far' => :recommended
  depends_on Sew.new
end

Sew would be a formula you have defined in this Formula file. This is useful,
eg. see Python's formula. Formula specified in this fashion cannot be linked
into the HOMEBREW_PREFIX, they are considered private libraries. This allows
you to create custom installations that are very specific to your formula.

More features to come, like specifying versions
2009-09-21 18:27:48 +01:00
Max Howell
ee2b521ca8 Solving the GNU GetText issues
GNU GetText breaks eg. Ruby 1.9 builds, and some other formula I have been building too. But it is required by eg. glib. So to solve this we are going to by default not symlink gettext into the Homebrew prefix.

Formula that depend on GetText will have the gettext paths added to the brewing environment automatically. Neat.
2009-09-17 22:01:27 +01:00
Max Howell
c71d4ad2bc Default to patch level 1
Having gone through our patches it's clear that p1 is more standard.

Also fixed a bug where returning DATA outside of an array would fail to patch.
2009-09-16 17:08:32 +01:00
Max Howell
c28bd7b571 Allow formulae to use __END__
For this to work the "running script" must be the formulae file. Making this
so wasn't so hard, there is now an install.rb script which is included with
the -r flag to the ruby executable. An at_exit handler calls the install
function.

Having the install logic in its own file made it feel like there was so much
space that I added extra error handling. So there is something to be said for
separating functionality out into its own files.

Still the error handling sucks, we'll need to marshall the exception back to
the bin/brew command. Which is another PITA.

Still overall I think this will prove worthwhile. But if it doesn't we'll
revert.

As a first usage, you can put a diff after __END__ and return DATA from
Formula::patches to make Homebrew aware of it.
2009-09-16 14:49:06 +01:00
Max Howell
fd5ed391be Support patching using diffs on local filesystem 2009-09-16 14:49:05 +01:00
Brian Smyth
0a2cdea5fd Teach patch to uncompress patches if necessary.
This change also eliminates the somewhat duplicate codepath if patches
returns and Array rather than a Hash.
2009-09-16 14:49:05 +01:00
Clinton R. Nixon
6ee6bee01f Clean up indentation
Signed-off-by: Max Howell <max@methylblue.com>

I didn't commit it all, apologies. But I just can't read the sections nearly as easily if you indent private and protected. If it's a Ruby convention it frankly seems at odds with the rest of Ruby spacing conventions.
2009-09-14 20:33:46 +01:00
Max Howell
46ac04e410 Formula::var
Points to eg. Cellar/wget/var rather than Cellar/wget/1.1.5/var

Discussion: 1689bbc326f1201ea979178ebcadba344abf2568
2009-09-14 20:33:46 +01:00
Max Howell
f0f59659dd Overriding Object.class was not my intention
Renamed to Formula::class_s.
2009-09-11 17:42:53 +01:00
Max Howell
0a31190fdc Dependency resolution
Specify dependencies in your formula's deps function. You can return an Array,
String or Hash, eg:

    def deps
      { :optional => 'libogg', :required => %w[flac sdl], :recommended => 'cmake' }
    end

Note currently the Hash is flattened and qualifications are ignored. If you
only return an Array or String, the qualification is assumed to be :required.

Other packaging systems have problems when it comes to packages requiring a
specific version of a package, or some patches that may not work well with
other software. With Homebrew we have some options:

1.  If the formula is vanilla but an older version we can cherry-pick the old
    version and install it in the Cellar in parallel, but just not symlink it
    into /usr/local while forcing the formula that depends on it to link to
    that one and not any other versions of it.
2.  If the dependency requires patches then we shouldn't install this for use
    by any other tools, (I guess this needs to be decided on a per-situation
    basis). It can be installed into the parent formula's prefix, and not
    symlinked into /usr/local. In this case the dependency's Formula
    derivation should be saved in the parent formula's file (check git or
    flac for an example of this).

Both the above can be done currently with hacks, so I'll flesh out a proper
way sometime this week.
2009-09-10 19:23:03 +01:00
Adam Vandenberg
c3169b5600 Display exit code when nonzero.
Brew fails if a tool (make, or whatever) doesn't return an exit code
of 0. This patch displays the non-zero code on failure, so we can
better diagnose what caused the build to fail (or if we need to add
that exit code as exception 'success code'.)
2009-09-10 18:17:15 +01:00
Max Howell
c92e566976 We should certainly have a Formula::share()
I removed this months back as I found it confusing, does it mean:

prefix+'share' or prefix+'share'+name()

But honestly, it's obvious, it's the former. It's the same as the other path
functions.
2009-09-10 17:21:14 +01:00