Installation and Use of homebrew
Feb 25 th, 2012
Mac OS X is a UNIX-based operating system and can install most of the software developed for Unix/Linux. However, it is not convenient to manually compile each software for the purpose of use, and it is not conducive to managing installed software, as a result, a software package management system similar to APT and Yum in Linux emerged, among which macports, Fink, and homebrew were the most famous.
I used to be a macports user, but after learning about homebrew, I immediately "quit. In fact, macports is also a very good solution, in addition to a feature that really makes me a headache. Macports has a principle that dependencies between software packages are all resolved within macports (/opt/local). No matter whether the system itself contains the required libraries, it will not be used. This makes macports too large and bloated, resulting in a large number of software package redundancy in the system, occupying a large amount of disk space, while a slightly larger software compilation time will be unbearable.
The homebrew principle is the opposite. It tries its best to use the various libraries provided by the system to shorten the Compilation Time of software packages. At the same time, it will hardly cause redundancy, the management of software packages is also clear and flexible. Another feature of homebrew is the use of ruby-defined software packages for installation and configuration (called formula), which is very simple to customize.
As for Fink, It is not discussed because it has not been installed and used. (From the Internet, Fink does not update software packages very timely due to manual maintenance issues .) For me, homebrew is well-developed. I am not interested in other software package management systems unless I find a major problem or a new breakthrough competitor.
The following describes how to install and use homebrew.
Homebrew Installation
First, make sure that your system meets the following requirements:
- Based on Intel CPU
- The operating system is Mac OS X 10.5 leopard or later.
- Installed version management tool git (Mac OS X 10.7 lion is pre-installed)
- Xcode development tool 1 is installed
- Java developer update2 installed
NOTE 1: In xcode 4.3, the command line compilation tool is optional and must be installed inPreferences
>Downloads
.
NOTE 2: (optional) homebrew does not rely on Java itself. Only Java is required for installation of some software packages.
Homebrew installation is very simple. Enter the following command in the terminal program.
ruby
-e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Because the installation address of homebrew may change, go to the official website to check the latest installation method.
Enter the root password during installation.
Homebrew usage
The executable command of homebrew is brew. The basic usage is as follows (take wget as an example ).
Search for software packages
brew
search wget
Install software package
brew
install wget
List Installed Software Packages
brew
list
Delete a software package
brew
remove wget
View software package information
brew
info wget
List dependencies of software packages
brew
deps wget
Update brew
brew
update
List outdated software packages (installed but not the latest version)
brew
outdated
Update outdated software packages (all or specified)
brew
upgrade
Orbrew
upgrade wget
Customize your own software packages
What should I do if the required software package cannot be found in homebrew? After all, homebrew is a new project and cannot meet the needs of everyone. Of course, we can compile and install the software package by ourselves, but the manually installed software package is not convenient to manage because it is not out of homebrew.
As mentioned above, homebrew's ruby-based software package configuration is very convenient. Next, let's talk about how to customize the software package (assuming the software package name is bar, from the foo site ).
First, find the source code of the software to be installed.
http://foo.com/bar-1.0.tgz
Create your own formula
brew
create http://foo.com/bar-1.0.tgz
Edit formula. After the previous step is successfully established, homebrew will automatically open the newly created formula for editing. You can also use the following command to open formula for editing.
brew
edit bar
The formula automatically created by homebrew already contains the basicconfigure
Andmake
install
Command, for most software, do not need to modify, just exit the edit.
Run the following command to install the custom software package:
brew
install bar
For other features of homebrew, such as submitting a custom software package to the official release, refer to the home page of the Homebrew project and its man page. You will find that homebrew is not only a "Homebrew", but also a "Homebrew ".