oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Managing Packages on Panther with DarwinPorts
Pages: 1, 2, 3

Installing Packages From Source

Installation of packages with DarwinPorts is performed with the port command. Although a man page is available for port (in /opt/local/man), I'll present a few examples of its basic use. The first thing you may want to do is to determine what software is available for installation via DarwinPorts. To view this list enter the command:

port list

or the command:

port search .+

Since the list is quite long, you may want to pipe this command through the more shell command. You can also use the port command to search for specific packages. For example, the command:

port search pine

will list the pine package, while the following command will list several packages, namely all available packages that contain the string kde.

port search kde

The port command can be used to install software. For example, to install pine, enter the following command:

sudo port install pine

Figure 4. Installing a port.

The installation of a software package may leave a number of intermediate files that were created during the build of the software. To delete these files, for example, in the build of pine, enter the command:

sudo port clean pine

To uninstall a particular port, use the port uninstall command. For example, to uninstall pine, enter the command:

sudo port uninstall  pine

To update a particular port it's necessary to first uninstall it, and subsequently install it.

To list your installed ports, enter the command:

port installed

Creating Packages in pkg Format

You can create a .pkg package installer using the port command with the package option, For example, to create a pkg installer for bvi enter the following command:

port package bvi

This command will download the source for bvi, build the application, and create a double-clickable package installer, bvi-1.3.1.pkg, in /Users/ernierothman/darwinports/dports/editors/bvi/work. The package will not be installed in this case. To install it (in /opt/local/), double-click bvi-1.3.1.pkg in the Finder, authenticate yourself as an administrative user, and install the package on your system as you would with any other .pkg package. When you install a package in this manner, the DarwinPorts database will not list it among its installed packages. That is, the 'port installed' command will not list it. If you enter the command 'port clean bvi', the installer bvi-1.3.1.pkg will be deleted.

Creating Packages in rpm Format

If you are planning to create packages in rpm format, the first thing you should do is to install rpm (via the 'sudo port install rpm' command). Once you have installed rpm, you can create rpm packages using the port command with the rpmpackage option, For example, to create an rpm for pine enter the following command:

sudo port rpmpackage pine

This command will create the rpm file in ${prefix}/src/apple/RPMS/${arch}, which in most cases will be /opt/local/src/apple/RPMS/ppc. You can safely clean up (via 'sudo port clean pine') after the rpm is created since the 'port clean' command will not remove the .rpm installer. Before installing rpm packages you need to create /etc/mnttab, which is the file that keeps track of which rpm packages are installed. This can be done in the usual way: 'touch /etc/mnttab'.

A summary of the use of the port command is given in Table 1.

Command Description
port list Lists available packages. Do this first.
port install foo Downloads, builds, and installs package foo.
port destroot foo Downloads, builds, and installs foo into an intermediate destination root, called a "destroot". This is useful in developing and testing new ports
port uninstall foo Deletes package foo.
port search foo Searches for available package foo.
port installed Lists all the installed packages.
port clean foo Cleans up intermediate files after installation of package foo.
port contents foo Lists all files installed with installation of package foo.
port deps foo Lists package foo's dependencies.
port variants foo Lists variants of package foo.
port package foo Build .pkg package installer for foo. (Does not install foo.)
port dmg foo Build an internet-enabled disk image containing an OS X .pkg package installer for foo. (Does not install foo.)
port rpmpackage foo Build rpm package installer for foo. (Does not install foo.)
Table 1 - Selected port commands

Installing Binary Packages

The DarwinPorts project provides pre-built binary packages in .pkg format, that is, for use with the Mac OS X Installer application. To install one of these binary packages, you must first download its installer. Select Go -> Connect to Server from the Finder's menu bar, and enter to mount the (remote) DarwinPorts binary packages folder as a WebDAV volume on your Desktop, as shown in Figure 5.

Figure 5: The DarwinPorts Binary Applications Volume.

Binaries may be provided as both individual packages (.pkg) and meta-packages (.mpkg). It is usually preferable to install a meta-package, if it is available, to ensure that dependencies are satisfied. These installers install Unix based packages into /opt/local. Currently, very few packages are available from

Updating DarwinPorts

To take advantage of the new and updated ports that are frequently added to the DarwinPorts distribution, you need to update your DarwinPorts installation. There are essentially two ways to update your DarwinPorts installation. One way is to change to the /Users/ernierothman/darwinports/dports directory and enter the the command:

cvs -z3 update -dP

After this command has completed its work, you should enter the the command:


to rebuild the index of available ports.

The other way to update your DarwinPorts installation is to reinstall the DarwinPorts infrastructure in /Users/ernierothman/darwinports. To accomplish this, change to the /Users/ernierothman/darwinports/base directory and enter the following commands:

cvs -z3 update -dP
make clean && make 
sudo make install

Creating DarwinPorts Packages

You can create your own DarwinPorts packages (i.e., ports) by identifying a source archive and creating a Portfile file in the appropriate subdirectory of the dports directory. For example, the Portfile for foo would be placed in /Users/ernierothman/darwinports/dports/games/foo.

To illustrate this process suppose you want to create a port named greet for the following program, which prints a greeting.

*   greet.c  - prints a friendly greeting
#include <stdio.h>
int main()
  printf("Greetings, Earthlings!\n");
  return 0;

Creating and Publishing the Tarball

The DarwinPorts package system needs a tarball that can be downloaded with the curl utility, so you should put the required files into a directory, such as greet-1.0. In this simple example, the directory greet-1.0 will contain greet.c, a man page greet.6, and the following makefile.

# Makefile for greet
	cc -o greet greet.c

Create a tarball greet-1.0.tar.gz containing these files and the top-level directory greet-1.0, obtain the md5 checksum of greet-1.0.tar.gz (you'll need this later), and put it somewhere where you can get it. In this example, you can move greet-1.0.tar.gz to the local /Users/Shared/greet/src directory. The curl utility can download this file with the following URL: file:///Users/Shared/greet/src/greet-1.0.tar.gz. (You could alternatively put greet-1.0.tar.gz on a public web server or FTP server.)

Pages: 1, 2, 3

Next Pagearrow