Managing Packages on Panther with DarwinPortsby Ernest E. Rothman, coauthor of Mac OS X Panther for Unix Geeks
One of the first things I started doing almost immediately after installing Mac OS X when it first came out in March 2001, was to begin downloading and building Unix-based open source applications. I was able to build quite a few applications by performing the usual configure/make/make install sequence.
As experienced Unix users know, there are problems with this approach. In particular, it's difficult to maintain software installed in this manner, track dependencies, and uninstall software. Additionally, if you build applications from source, you might want to package the resulting binaries for distribution so others can install the package, or you can reinstall it at a later time without needing to rebuild it from source, or you can install it on multiple machines. Simply creating a tarball containing binaries and a readme file stating which other packages must be installed first is not an efficient package management strategy. There are more effective strategies. Quite a few package management systems are available on Unix and Linux systems. Mac OS X is no exception.
Since the release of Mac OS X, it has become quite rich in packaging options. One particularly popular option is the Debian-based Fink package management system, which was started by Christoph Pfisterer in December 2000. Pfisterer left the project in 2002, but it has been continued by many other folks. Fink is now a mature and indispensable tool for Unix geeks who use Mac OS X. You'll find good documentation of Fink on its web site and a number of books, including the recent book I coauthored with Brian Jepson, Mac OS X Panther for Unix Geeks, that provide additional coverage. We actually devoted a whole chapter to Fink in this book. In this article I will give a brief introduction to DarwinPorts, another packagement system available on Mac OS X, limiting my discussion to DarwinPorts on Mac OS X 10.3.x (Panther).
Overview of DarwinPorts
The DarwinPorts project, started in 2002 and led by Landon Fuller, Felix Kronlage, Jordan Hubbard, and Kevin Van Vechten, is a package management system, similar to Fink and the FreeBSD ports collection. It automates the installation of open source Unix- as well as Aqua-based software on Mac OS X. Written primarily in Tcl (which is bundled with Mac OS X), DarwinPorts can also be embedded in other applications.
The DP-COCOA project, led by Ernest Prabhakar, provides a Cocoa-based framework for manipulating DarwinPorts. A graphical user interface called PortsManager is also under development, according to the DarwinPorts web site. DarwinPorts, as any sophisticated package management system will do, provides a way to uninstall packages that it installs, and track dependencies of these packages. This means that if you attempt to install package A, which depends on package B, DarwinPorts will first install package B. Similarly, if you attempt to uninstall package B while you have installed another package that depends on package B, DarwinPorts will let you know and give you the option to remove other packages that depend on the one that your attempting to remove.
DarwinPorts installs Unix-based packages in /opt/local by default so that your Mac OS X-installed system files in /usr won't be affected. DarwinPorts also allows you to build several Aqua-based applications from source, which are installed in /Applications/Darwinports. Additionally, various configuration files are installed in /private/etc/ports, required libraries are installed in /Library/Tcl/darwinports1.0 (assuming Mac OSX 10.3.x), and the DarwinPorts infrastructure and descriptions of ported applications reside in a selected user's home directory, for example, /Users/ernierothman/darwinports.
A more traditional Unix practice is to place locally installed software in /usr/local. On some systems, for example, Solaris, /usr/local, and /opt are used for locally installed software and optional software, respectively. Installing software in /opt/local takes the usual practices one step further and is regarded as a safer policy. If problems occur with DarwinPorts-installed packages, you can then delete the entire /opt/local directory tree without affecting your system. In this case you should also delete the /private/etc/ports and /Library/Tcl/darwinports1.0 directories.
When you build and install a package with DarwinPorts, it builds the
package(s) from source in a special workspace directory called work,
which you'll find within the ~/darwinports/dports/ directory. For example,
if you're building an application named greet--categorized as
a game--the application would be built in /Users/ernierothman/darwinports/dports/games/greet/work.
When you install greet, it will be installed in both the "destroot" directory
in /opt/local (or whatever you may have defined for
$prefix) via /usr/bin/install.
A receipt is made for the installation.
As an alternative to installation via /usr/bin/install, DarwinPorts can produce a .pkg (or .mpkg to include dependencies) package that can be subsequently installed via the Mac OS X Installer. It can also create an Internet-enabled disk image (.dmg) with a package installer. According to the DarwinPorts web site, a GUI-based Uninstaller application is under development. Design of this Uninstaller application will include the ability to uninstall Darwinports-installed packages, as well as support for the RPM package manager format.
You'll find detailed documentation on the installation (and use of) DarwinPorts, written by Michael A. Maibaum, on the DarwinPorts web site. Although the DarwinPorts web site should be checked for the most up-to-date information, I'll provide a brief description of the installation and use here.
Before installing DarwinPorts, you must install the developer tools, Xcode, which ships with Mac OS X. You will also need to install X11, which is an optional installation on the Mac OS X Panther CD collection, and the X11 SDK, which is an optional installation on the Xcode CD.
Installation of DarwinPorts is built around the Concurrent Versioning System (CVS), which is installed with Xcode. A word of caution is in order before you get started. DarwinPorts and Fink can co-exist on the same system, but if you've already installed Fink (say, in its default location /sw), there is a chance that the configure phase described below will identify the Fink-installed version of required software.
For example, if you've installed Tcl/tk with Fink, then there's a chance
that DarwinPorts will use the version of Tcl in /sw, rather than the
Mac OS X bundled Tcl in /usr/bin. If this happens and you later decide
to remove Fink, you'll mess up your DarwinPorts installation. To avoid
this potential problem, you may want to temporarily remove /sw/bin from
your path, (or, if you've added it to your .bashrc file, comment out
To install DarwinPorts, you should be logged in as an administrative user. In the following discussion, assume you're logged in as the administrative user ernierothman.
To download DarwinPorts and establish its infrastructure on your system, perform the following steps:
Change to your home directory:
Log into the OpenDarwin CVS server by entering the following command. When you're prompted for a password, press return:
cvs -d :pserver:firstname.lastname@example.org:/Volumes/src/cvs/od login
Checkout, that is, download DarwinPorts distribution files into a directory /Users/ernierothman/darwinports:
cvs -d :pserver:email@example.com:/Volumes/src/cvs/od co -P darwinports
The directory /Users/ernierothman/darwinports contains the port description files (also known as portfiles), and must be kept even after you've installed DarwinPorts.
As an alternative to downloading the Darwinports files via the CVS commands given above, you can download a nightly snapshot tarball. To install DarwinPorts from the nightly snapshot, download and unpack it in your home directory. This will create the /Users/ernierothman/darwinports directory. You can then proceed as outlined below. After you've downloaded DarwinPorts, you're ready to build and install it:
Change to the /Users/ernierothman/darwinports/base, known as the DarwinPorts infrastructure.
Perform the configure, make, make install sequence:
./configure make sudo make install
These commands build and install necessary files in /opt/local, /private/etc/ports, and /Library/Tcl/darwinports1.0.
As part of the installation of DarwinPorts, the file /private/etc/ports/sources.conf is created with the following line, which points to your local dports directory:
The local dports directory contains the ported software descriptions and related "Portfiles," which are Tcl scripts needed to build and install each port (i.e., ported software). According to documentation on the DarwinPorts web site, the sources.conf file is used to list the locations of both the local and remote port software hierarchies, although currently there is no remote dports repository.
The installation of DarwinPorts also installs the files /private/etc/ports/ports.conf and /private/etc/ports/prefix.mtree.
Since DarwinPorts software is installed in /opt/local you should add
/opt/local/bin to your path. Once you have performed these steps, you'll
have a working installation of DarwinPorts. If you want DarwinPorts
software to install software in a directory other than /opt/local, you
can edit the file /etc/ports/ports.conf and change the value of prefix
from /opt/local to the directory in which you want packages installed.
You could alternatively, run the configure command used in the build
of DarwinPort with the