Hack 88 Easily Install Unix Applications on Mac OS X


figs/moderate.gif figs/hack88.gif

Many Mac users often seem a little surprised when I tell them I run XChat and other Unix applications on Mac OS X alongside native Aqua applications (such as Safari, Finder, and iPhoto). What they don't realize is that it's simple to install such applications thanks to the Fink and DarwinPorts projects. This hack is dedicated to installing and using DarwinPorts.

This hack assumes you have a basic understanding of Terminal.app and the underlying Unix bits of Mac OS X. You also need to have the Developer Tools installed.

8.13.1 Installing DarwinPorts

Before you can use DarwinPorts, you must install the build system and the actual ports tree. The easiest way to accomplish this is by using CVS. Before checking the project out of CVS, you'll need to decide where you'd like it to exist on your hard drive. I usually use ~/work.

Open Terminal.app (or an xterm if you have X11 installed), and change to the directory where you'll install DarwinPorts. Then type the following commands at the prompt (when the server asks for a password, just press Return):

% alias dcvs cvs -d \     :pserver:anonymous@anoncvs.opendarwin.org:/Volumes/src/cvs/od % dcvs login % dcvs co -P darwinports

You should now see a bunch of output scrolling past in the terminal window. If you do, good; the project is checking out of CVS and onto your hard disk. If you don't, double-check the three commands just shown to make sure you typed everything correctly. Once you've fetched the project, it's time to install it.

Run ls in the terminal window; you should see a darwinports directory. cd to it and rerun ls:

% cd darwinports % ls CVS  Makefile  README  README.fr  base  doc  dports  www

At this point, it's a very good idea to read the README file.

The next step is to build and install the applications that will allow you to install various ports. From the darwinports directory:

% sudo -s <enter your password> # make && make install && make clean

By default, DarwinPorts uses /opt/local as its prefix. To change that to something else, edit /etc/ports/ports.conf.

Next, open /etc/ports/sources.conf and change the file:// line to point to the proper location on your system. For example:

file:///Users/jim/work/darwports/dports

Now that everything is configured, add the directory containing DarwinPorts binaries to your shell's path. If you're using tcsh (the default shell on Mac OS X 10.2 and earlier), add the following to your ~/.cshrc file:

set path = ($path /opt/local/bin)

If you're using bash, as Mac OS X 10.3 does, add the following line to your ~/.bashrc file:

export PATH=$PATH:/opt/local/bin

In order for your shell to recognize the new path, either start a new shell or source your configuration file:

% source ~/.cshrc $ source ~/.bashrc

8.13.2 Finding Ports to Install

Before you can install a port, you'll need to make sure it exists in the ports tree. This can be done in one of two ways. The first is using port search, which is very simple to use. For example, to look for xchat:

% port search xchat irc/xchat       1.8.11  IRC client with gtk and text interfaces irc/xchat2      2.0.1   IRC client for gtk2

The alternative is to use the web-based interface found on the DarwinPorts web site. You can view by category and search from this interface, but because the PortIndex file it uses isn't always up-to-date, you may have better luck with the port command.

8.13.3 Installing Ports

Now that we've found something to install, it's time to learn how to install it. If you've ever worked with the FreeBSD ports collection, this section should look very familiar to you.

Sticking with XChat as our example, we have two options. We can install the xchat port, which uses GTK+ version 1, or the xchat2 port, which uses GTK+ Version 2. For the sake of example, we'll choose xchat2.

There are also two ways to install the port. The first way is to change to the port's directory and run port install:

% cd /path/to/darwinports/dports/irc/xchat2 % sudo -s <enter your password> # port install && port clean

The second method can be run from anywhere on the filesystem:

% sudo -s <enter your password> # port install xchat2 && port clean xchat2

As long as you have your path set properly and the port you're trying to install is in the PortIndex, installation should proceed normally.

8.13.4 Updating the Ports Tree

Since the ports developers frequently add new ports and update existing ports, you'll want to keep your ports tree up-to-date. Doing so is fairly simple:

% cd /path/to/darwinports % cvs -q up -Pd

If you notice changes to the base directory, you'll want to rebuild the DarwinPorts base system as well. This is done using the same commands used to install it initially:

% cd /path/to/darwinports % sudo -s <enter your password> # make && make install && make clean

As you'd expect, the port command has other options, such as uninstall, fetch, extract, and build, to name a few. Check the port manpage for a full explanation of each option and more information.

At the time of writing, there are over 750 ports in the DarwinPorts tree and that number is growing daily. If your favorite application isn't already available in the ports tree, you can either create a port of it or join the DarwinPorts mailing list and request that someone else create a port of it.

8.13.5 See Also

  • man port

  • http://www.bsdnews.org/01/darwinports.php (the original article on BSDnews)

  • The DarwinPorts web site (http://darwinports.opendarwin.org/)

  • The DarwinPorts web interface to the ports collection (http://darwinports.opendarwin.org/ports/)

  • The DarwinPorts mailing list (http://www.opendarwin.org/mailman/listinfo/darwinports/)

  • The Fink web site (http://fink.sourceforge.net/)



BSD Hacks
BSD Hacks
ISBN: 0596006799
EAN: 2147483647
Year: 2006
Pages: 160
Authors: Lavigne

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net