Homebrew: Package Manager for OS X

Original author: Andre Arko
  • Transfer
All Unix package managers have certain flaws, and most Linux distributions try to work around these flaws in different ways. In this post I will talk about Homebrew , a new package manager aimed at ease of use.

Before Homebrew, there were several different attempts to create effective package managers for OS X. The two most popular ones ended up in Fink and Macports , but each of them still has its own sharp corners. In particular, in both, creating your own packages or ports is too complicated.

In Homebrew, creating new packages and working with them is easier than a steamed turnip. Let's get a look.

What does it do?


The basic idea is very simple. Homebrew simplifies and automates the monotonous steps of downloading and building packages. If you are tired of endless ./configure && make && make install, Homebrew will help.

Why is it?


As I noted above, there are already two solutions for OS X: Fink and MacPorts. If you have already installed one of them and are happy with everything, excellent. But if you have had bad experiences with them in the past, I highly recommend trying Homebrew. It is much easier with him. Plus, it’s easy to modify, because it consists of only a few hundred lines of Ruby code.

Homebrew does not impose any strict structure and paths. By default, it is installed in /usr/local, but you can put it anywhere. All packages are installed in a directory in a special “cellar”, for example Cellar/git/1.6.5.4/. After installation, Homebrew makes symlinks to standard Unix directories. Manual installation of some packages not from Homebrew gets along well with them.

This is rarely necessary, but packages can be installed directly from version control systems. If the package has a public git, svn, cvs or mercurial repository, you can always build the latest devel version right from there simple brew install.

By the way, installation takes less time, as Homebrew tries to avoid duplicate packages. For example, it does not put the next version of Perl as a dependency, since the system already has Perl ready and working. Plus, Homebrew is designed so that you don't have to use sudo when working with packages.

That sounds good. How to install it?


The first and only dependency of Homebrew is the OS X Developer Tools , which are available on any OS X installation disc and are available for free download from Apple.

The simplest is to install at /usr/local. This can be done very simply: That's it, the installation is complete. Let's check that everything works: There is a wiki on the Homebrew website where you can read all sorts of interesting things about integration with Rubygems, CPAN and Python EasyInstall . Keeping up with Homebrew updates is also quite simple: If you have git installed, you can update your Homebrew repositories at any time and install the latest packages.
# Присваиваем папку /usr/local себе, чтобы не использовать sudo
sudo chown -R `whoami` /usr/local
# Чиним права на mysql, если он у вас установлен
sudo chown -R mysql:mysql /usr/local/mysql
# Скачиваем и устанавливаем Homebrew с гитхаба
curl -L github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local



brew install wget
brew info git





brew install git
brew update




Creating your own packages is almost as easy. For example, if in the Homebrew there would be a package for the wget, its creation would look like this:
brew create ftp.gnu.org/gnu/wget/wget-1.12.tar.bz2

After you save the package, you can test: brew install -vd wget. If something is not working correctly and you need help setting up the package, there is a lot of documentation on the wiki . You can also see examples of creating packages such as git or flac .

If you have created a new package and want to share it with the community, this is also quite simple to do using the github gem. After you make a push, you need a Homebrew issue tracker

gem install json github
git add .
git commit -m "Added a formula for wget"
github fork
git push <ваш_логин_на_github> mastergitx


create a new ticket with the theme "New formula: <package_name>". If everything is in order there, your package will be added to the Homebrew main repository and will be available to all users.

Summary


Homebrew is a decent alternative to Fink and MacPorts. He himself and all the package scripts are written in Ruby, so adding new features and packages is very easy. If you need a flexible and convenient package manager, try Homebrew, and I think you will be pleasantly surprised.

Also popular now: