MacOS – how to write a homebrew recipe

homebrewmacos

What are the key features of a homebrew recipe?

If I want to contribute a recipe, e.g. this one for udunits to the the hombrew-science repository, how would I convert a command-line script like this:

wget ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.1.24.tar.gz
tar -xvf udunits-2.1.24.tar.gz
cd udunits-2.1.24
./configure 
make 
make check
make clean

into a valid recipe?

Best Answer

This Homebrew README gives these steps (with links to more information):

Contributing

In short:

  1. Fork Homebrew.
  2. brew create http://example.com/foo-0.1.tar.gz
  3. git checkout -b foo
  4. git commit Library/Formula/foo.rb && git push
  5. Pull Request.

In long:

Homebrew formulas are written in Ruby (tested against Ruby 2.0.0). Knowledge of Ruby certainly helps, but you might be able to get a feel for how to do basic procedures like you outline above just by reading a few existing formulae.

Getting a formula accepted also requires a little knowledge of Git and GitHub pull requests, but is covered How to open a Homebrew pull request (and get it merged)