62 Commits

Author SHA1 Message Date
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
Étienne Barrié
3809c0b419 Add support for SHA256 2009-09-07 16:10:50 +02:00
Max Howell
680e201923 Fix double newline after Interrupt
Seems to be an issue with Ruby system() call doing a double fork.
2009-09-05 20:46:07 +01:00
Ask Solem
21df479f1b Thrift formula
Thrift is a software framework for scalable cross-language services
development. It combines a powerful software stack with a code generation
engine to build services that work efficiently and seamlessly between C++,
Java, Python, PHP, and Ruby. Thrift was developed at Facebook and released as
open source.
2009-09-03 16:34:35 +01:00
Ben Alpert
b71b8e3972 Dict.org client formula
Added Formula::etc()

Added Pathname::write() convenience function which can write a string out to
the file it points too, raising if it would have to overwrite.
2009-09-01 11:15:25 +01:00
Max Howell
4d63b87e0a Change license to BSD
I confirmed this change with all relevant contributors first.
2009-08-31 16:09:17 +01:00
Max Howell
145e33abdf Better cache names for accessory-formula
Because formula don't get named unless the brew kit instantiates them accessory formula were getting named "__UNKNOWN__". Which sucks.

This isn't ideal for me as I made the naming use @name and @version to ensure unique naming. Now it is possible to have name clashes in the cache. So I need to solve it better at some point.
2009-08-30 16:11:44 +01:00
Max Howell
a1d31fabad FIX GithubGistFormula (fixes Homebrew/homebrew#20) 2009-08-30 15:32:15 +01:00
Adam Vandenberg
a67cf9bef2 Clarify --debug behavior.
Add a note that 'exit 1' will abort the installation in --debug mode.

Signed Off By: Max Howell <max@methylblue.com>

I ammended the text slightly and made the lines all 78 chars wide maximum.
2009-08-29 14:12:31 +01:00
Max Howell
f0c7e944bb Support optional HEAD builds for any formula
A formula can have just a @head url or the user can specify to install HEAD
with --head. We support subversion and git checkouts.

The version is set to HEAD for head builds.

Next step is making brew update handle these installs correctly.
2009-08-24 01:04:54 +01:00
Adam Vandenberg
4c2d4c8560 Add path for 'libexec'. 2009-08-24 01:04:53 +01:00
Max Howell
b6ccdad53e Proper validation of Formula.name and version 2009-08-24 01:04:53 +01:00
Max Howell
72bde8c583 Move download strategies into their own file 2009-08-24 01:04:53 +01:00
Max Howell
c532d11e7a Refactor away AbstractFormula
We'd gotten to the stage where Formula was so lean, it was pointless to
separate it.
2009-08-24 01:04:48 +01:00
Max Howell
b115f26870 GitDownloadStrategy
Untested
2009-08-24 01:03:30 +01:00
Adam Vandenberg
57a86034a3 Support building from Subversion repositories
Adds a new DownloadStrategy that checks files out from Subversion to the
cache, then exports over to the temp folder for the build.

To use checkout with the svn:// protocol or reimplement download_strategy and
return SubversionDownloadStrategy.
2009-08-24 01:03:30 +01:00
Adam Vandenberg
0eaf4bbcd9 Factor out downloading from Formula
This patch adds a ArchiveDownloadStrategy that handles downloading
tarbarlls and decompressing them into the staging area ready for brewing.

Refactored safe_system and curl into utils.rb

Signed-off-by: Max Howell <max@methylblue.com>

Modifications to Adam's original patch:

I reverted objectification of checksum verification because I couldn't think
of any other download validation methods that might be useful to us in the
future, so allowing such flexibility had no advantages. If we ever need this
to be OO we can add it. But for now less complexity is preferable.

I removed the @svnurl class member. Instead download_strategy is autodetected
by examining the url. The user can override the download_strategy in case this
fails. Thus we already can easily add support for clones of git repositories.
2009-08-24 01:03:23 +01:00
Adeel Ahmad Khan
1c55642645 Link binaries in sbin as well as bin.
Signed-off-by: Max Howell <max@methylblue.com>
2009-08-12 23:55:57 +08:00
Max Howell
a2066af2fd Allow user to specify patch level
The default is p0, but if you return a Hash instead of an array from patches you can specify patch level. See the comment documentation.

Closes Homebrew/homebrew#10
2009-08-11 18:16:12 +01:00
Max Howell
480bfa3793 CTRL-C for a child process should interrupt brew too 2009-08-10 18:17:11 +01:00
Max Howell
dd7bdce89c Abort debug install if exit is not zero 2009-08-10 18:16:47 +01:00
Max Howell
760c083c0c Refactor
Large refactor to Formula, mostly improving reliability and error handling but
also layout and readability.

General improvements so testing can be more complete.

Patches are automatically downloaded and applied for Formula that return a
list of urls from Formula::patches.

Split out the brew command logic to facilitate testing.

Facility from Adam Vandenberg to allow selective cleaning of files, added
because Python doesn't work when stripped.
2009-08-10 18:11:17 +01:00
Adam Vandenberg
cae0e78e60 Pull USERAGENT used by curl into constant 2009-08-10 16:15:24 +01:00
Adam Vandenberg
fea89daae6 Extract 'verify_download_integrity' method
In order to support more than just MD5 verification, extract 'verify_download'
into a separate method.
2009-08-10 16:14:43 +01:00
Max Howell
182ce1eff6 Formula::std_cmake_parameters
Because cmake syntax is batshit-insane, this stops people having to memorize
which parameters to supply, and thus prevents error.

I didn't do the same for Autotools deliberately as I have found that
which parameters are supported is somewhat inconsistent. Plenty don't even
support --disable-debug, thus I want the parameters getting used in the
contributors face so they can easily diagnose what is going on.
2009-08-06 20:25:59 +01:00
Max Howell
33b90794e1 HOMEBREW_CACHE is now a Pathname object
This is consistent with the other HOMEBREW_* path constants
2009-08-04 00:40:12 +01:00