January 14, 2011

How to Install MacPorts

The MacPorts project let's you bring Linux to your Mac. You could download the source code for your favorite Linux programs and compile them, but MacPorts brings the simplicity of installing to your Linux programs. Before installing MacPorts, or Fink, which we'll cover in a later article, you need to install the Apple Xcode Developer Tools, see my previous post for installation instructions.

Start by downloading the DMG image for the MacPorts version you need. Be sure to download the right one, because there is a different version for Snow Leopard, Leopard and Tiger. Follow the prompts to install the MacPorts program on your computer.

MacPorts can update itself and programs you install with a simple command. Let's start by opening a Terminal window, it's in the Utilities folder located inside the Applications folder. Double-click it to open a Terminal window that should be familiar to any Linux user.

Start by updating MacPorts itself, this will update the program and the catalogue of available programs. Type sudo port -v selfupdate to update MacPorts. The MacPorts program is command-line only, but don't worry, the commands are simple, and the program takes care of any dependencies.

Finding your favorite program is very easy. You can use the online search function at MacPorts, or you can type port search programname. For example, you can see if the mutt email client is available by typing port search mutt. This will return any programs with mutt in the name or description.

Once you've got the name of the program you want to install, just type sudo port install program. For example, to install the development version of mutt I'd type sudo port install mutt-devel. You don't have to worry about dependencies or required libraries, MacPorts will take care of that for you.

You can update all your MacPorts installed applications by typing sudo port upgrade outdated. Be sure to use the sudo port -v selfupdate command first to update MacPorts before upgrading your applications. This way you'll get the latest version.

If you do plan to compile programs yourself, either because it's not available in MacPorts, or for another reason, you can also use MacPorts to install dependencies for that program if they're available. Stay tuned, the my next post will cover installing Fink, a program similar to MacPorts.

No comments:

Post a Comment