Using MacPorts
MacPorts provides a UNIX package management system (similar to FreeBSD ports) that enables you to easily install and update Open Source software on your Mac. As the list of packages shows, MacPorts offers every major Open Source command-line and desktop software product.
MacPorts relies on the presence of a C compiler, so you must install XCode Tools before you can use it.
Download and install the MacPorts package, and then amend your PATH setting. You need to add both of the directories where it installs utilities: /opt/local/bin, and /opt/local/sbin. To do this, edit the PATH line in the .profile file within your home directory to read:
export PATH=$HOME/.gem/ruby/1.8/bin:/opt/local/bin:/opt/local/sbin:$PATH
Once you have installed MacPorts, use the facilities of the port command to install, upgrade, and remove UNIX software. As always, you must prefix commands that actually modify the system with sudo.
The essential facilities are:
MacPorts only actually handles product dependencies when specifically told to do so, with the -R option. For example, to install the Git version control system (git-core) and all of the required dependencies with MacPorts, use this command:
sudo port install -R git-core
MacPorts must download, install, and compile several dependencies, as well as the Git utility itself. The whole process takes several minutes to complete, even on a modern computer, so once you enter the command, leave the terminal alone and do something else until it has finished.
To upgrade all of the software managed by MacPorts:
sudo port upgrade installed
To upgrade MacPorts itself:
sudo port -v selfupdate
If you are going to carry out multiple commands, use the port interactive shell. Type port to enter the shell, and exit to close the shell.
For a complete list of the available commands, refer to the man page for port:
man port
All original content is © 2010, Stuart Ellis.
This material is provided under the Creative Commons Attribution-Share Alike 3.0 License.