⬆️ ⬇️

Homebrew: Package Manager for OS X

All package managers in Unix have certain drawbacks and most Linux distributions try to get around these disadvantages in different ways. In this post, I’ll talk about Homebrew , a new package manager aimed at ease of use.



Before Homebrew, there were several different attempts to create efficient package managers for OS X. The two most popular ones resulted in Fink and Macports , but each of them still had its sharp corners. In particular, in both the creation of its own packages or ports is too complex.



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



What does it do?



The basic idea is very simple. Homebrew simplifies and automates the monotonous actions of downloading and building packages. If you are bored with 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 - great. But if you’ve had a bad experience with them in the past, I strongly recommend trying Homebrew. With it is much easier. 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 or 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 “basement” (cellar), for example Cellar/git/1.6.5.4/ . After installing Homebrew makes symlinks to standard Unix directories. Manual installation of some packages not from Homebrew gets on well with them.



This is rarely needed, 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 with a simple brew install .



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



Sounds good. How to install it?



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



The simplest is to install in /usr/local . This can be done quite simply:

# /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




All installation is complete. Let's check that everything works:

brew install wget

brew info git




The Homebrew website has a wiki where you can read all sorts of interesting things about integrating with Rubygems, CPAN, and Python EasyInstall .



Monitoring Homebrew updates is also quite simple:

brew install git

brew update




If you have git installed, you can update the Homebrew repositories at any time and install the latest versions of the packages.



Creating your packages is almost as easy. For example, if Homebrew did not have a package for wget, creating it would look something like this:

brew create ftp.gnu.org/gnu/wget/wget-1.12.tar.bz2



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



If you created a new package and want to share it with the community, this is also quite simple with the github gem.



gem install json github

git add .

git commit -m "Added a formula for wget"

github fork

git push <___github> mastergitx




After you push, you need to create a new ticket in the Homebrew issue tracker with the theme “New formula: <package_name>”. If everything is fine there, your package will be added to the Homebrew main repository and available to all users.



Results



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

Source: https://habr.com/ru/post/84217/



All Articles