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.
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.
Otherwise you run the risk of not running the exact version / make of the utility you planned.
FixesHomebrew/homebrew#48
Really we need to do this formula too, so I guess a make and cmake function are on the way…
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.
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
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.
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.
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.
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.
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'.)
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.
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.
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.
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.
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.
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.
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.
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.
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.
ClosesHomebrew/homebrew#10
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.
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.