MacDevCenter    
 Published on MacDevCenter (http://www.macdevcenter.com/)
 See this if you're having trouble printing code examples


Installing Fink on Mac OS X

by Koen Vervloesem
09/30/2005

At its heart, Mac OS X is a Unix operating system. This means that plenty of Unix open source software compiles and runs on it. However, compiling software can be tedious, especially if it has many dependencies, or if it hasn't been tested on Mac OS X. You have to perform the usual configure/make/make install process and hope it all works fine. Maybe you have to tamper with the makefile or even the source code. Moreover, you'll need to make sure all libraries used by the software are installed.

The Fink project, which began in December 2000, has two goals. It aims to port all this software to Mac OS X ("porting") and makes it available for install ("packaging"). As a full package management system, based on Debian's apt system, it installs and uninstalls packages, tracks dependencies, installs the packages that are needed, updates the packages, etc. Bottom line: installing Unix software on Mac OS X with Fink is a piece of cake (most of the time). There can be challenges, however, and I'll cover those in a minute.

Fink isn't the only package management system available for Mac OS X. The DarwinPorts project, started in 2002, has similar goals. While DarwinPorts has fewer packages available than Fink, the available ones tend to get updated more frequently. The two package management systems can even coexist on the same system. So it's perfectly possible to use Fink for the packages it contains, while using DarwinPorts for the packages missing in Fink, but listed in DarwinPorts.

In June 2003, Fink, Gentoo Linux, and DarwinPorts announced the formation of a cooperative development alliance, the MetaPkg initiative. Their projects would share information to avoid duplication of effort and facilitate the development of the different projects. However, since the announcement, no substantial information seems to have been added to the website. This doesn't mean Metapkg is dead. Developers of Gentoo, Fink, and DarwinPorts frequent each other's chat rooms and are working together daily. The power of Metapkg really lies in the charter the different partners signed.

In July 2004, the Gentoo GNU/Linux project released their Portage package manager for Mac OS X. Gentoo for Mac OS X, as the project is called, hasn't been able to get a big fanbase, partly because many of the packages aren't tested. This could change in the future, but for now it seems Gentoo for Mac OS X can't beat the two other package managers.

Reasons to Use Fink

Related Reading

Mac OS X Tiger for Unix Geeks
By Brian Jepson, Ernest E. Rothman

Fink has some attractive features. First of all, installing software with Fink is plain easy. If you want to install a package, Fink searches which other packages have to be installed to let the package work, downloads all packages, and installs them. Uninstalling or updating a package is as easy.

Maybe you're worried that Fink tinkers with Mac OS X. Keep in mind that you can use Fink safely because it doesn't alter anything in the operating system. All packages and Fink-related files get into their own directory: /sw. For example, executables go into /sw/bin and configuration files in /sw/etc. The whole Fink distribution with all packages can be uninstalled by deleting this directory. After that, Mac OS will still function properly. (Of course, if you used Fink-installed programs in scripts, these won't work anymore.)

Fink has a coherent collection of packages. Installed files all come in a standard place on your hard disk. Binaries, man pages, documentation, configuration files--all go in an easy to find place. If you update a package, its documentation and man pages get updated too. There's no need to download the documentation separately, with the chance of getting documentation for a different version of the software.

Reasons Not to Use Fink

For all of its great features, Fink isn't always the perfect solution to install Unix software on your Mac. First of all, it has the tendency to install its own versions of libraries, headers, and programs that are already on a standard Mac OS X installation. So if you have installed a lot of programs with Fink, you end up with a considerable amount of duplicate system software, with minor version differences. This could get you into trouble if you inadvertently use the wrong version.

Most of the time, package installation with Fink is simple. But things can go wrong. I have been a Fink user for many years now, and I've occasionally encountered problems. Sometimes packages didn't compile, other times the download servers were down, or the versions of the software I wanted to install were too old. But keep in mind, if all else fails, you can compile the software yourself.

I mentioned earlier that Fink and DarwinPorts can coexist peacefully. Most of the time, this is true. But I've run across some rough ground here too. For example, if you install Fink first, and then DarwinPorts, the last one will most likely choose to use the Fink version of some required libraries instead of the Mac OS X bundled version. If you remove Fink afterwards, your DarwinPorts installation will stop working.

Binary and Source Packages

You can install a package in two forms: source or binary. A binary package contains precompiled programs, ready to run. Installing a binary package with Fink simply means downloading and extracting the program. You can use it immediately.

Alternatively, a source package contains the source code of the program and Fink-specific patches and build instructions. Installing a source package means compiling the source code and creating the executable. Of course this requires more time than installing a binary package.

Installing Fink and FinkCommander

As with the binary and source packages, you can also install Fink in two ways: a binary release or a source release. But there really isn't a big difference. You always have the option to build a package from source or install a downloaded binary package.

On the Fink website, you can find detailed information on the installation. Here, I'll provide you with a brief description of the installation of the binary release. The installer is a DMG disk image. Tiger users install the Fink 0.8.0 release, Panther users install 0.7.2. Mount the disk image and double-click the enclosed installer package. The instructions on screen will guide you through the installation.

At the end, the installer launches the pathsetup utility to add some necessary commands to your shell's configuration files. If this doesn't work for some reason, you can configure this manually by putting the following line in the file .profile in your home directory:

. /sw/bin/init.sh

Read Fink's documentation for more information.

FinkCommander provides an easy to use graphical user interface for Fink. A version of FinkCommander is included in the binary distribution of Fink. Just drag the FinkCommander application in the FinkCommander folder of the Fink disk image to your Applications folder. If you want the newest version of FinkCommander, you can download it from the FinkCommander homepage.

Fink and FinkCommander are now installed. The next step is to scan the Fink packages and create an index. To do this, start FinkCommander and select the menu item Scanpackages in the Source menu. Since this is the first time you've used FinkCommander after installing, it'll tell you it doesn't have the correct permissions and needs a self-repair. Then it asks for your Administrator's password twice. When the self-repair process is done, you have to run the Scanpackages command again. After this you have to run the index command in the menu Source -> Utilities -> Index.

figure 1
Figure 1. Scan the Fink packages.

figure 2
Figure 2. Self-repair succeeded.

figure 3
Figure 3. The Fink packages are scanned now.

FinkCommander gives some output in the lower half of its window. This is in fact the output of Fink. What we have just done is equivalent to running "fink scanpackages; fink index" in a Terminal.app window.

First you should update the package descriptions to the newest version. In FinkCommander this can be done in the menu Binary -> Update descriptions. After that you update the fink package by selecting the fink package in the list of packages and clicking on Binary -> Install.

The same can be done in Terminal.app with the commands "sudo apt-get update ; sudo apt-get install fink."

By now Fink and FinkCommander are ready to use. But first, we need to change some settings in the FinkCommander preferences. In the Fink tab, check "Use unstable packages" and "Use unstable cryptography packages." Click on "OK." The Administrator's password is required. After indexing and rebuilding the package table, the number of packages shown by FinkCommander has been doubled. Besides the stable packages of Fink's default install, we can also install the "unstable" packages, which are not as unstable as the name seems to imply.

figure 4
Figure 4. Use unstable packages.

If you don't use FinkCommander, you can also make the necessary changes to use unstable packages in /sw/etc/fink.conf. Change the following line:

Trees: local/main stable/main stable/crypto

to:

Trees: local/main stable/main stable/crypto unstable/crypto unstable/main

Installing Binary Packages

Fink uses the Debian package management utility apt for installing binary packages. If you want to install a binary package, you can select it in FinkCommander and click on the menu item Binary -> Install, or on the leftmost icon in the icon bar. If you want more information about the package first, you can click on Apple-I or the "I" icon while the package is selected.

figure 5
Figure 5. Read more information about the package.

If you choose to install a binary package in FinkCommander, chances are that you'll get the message, "Fink is waiting for a response." FinkCommander communicates with Fink and displays its output in the lower part of its main window. Fink can also ask questions. For example, you might want to install extra required or suggested packages. If so, FinkCommander displays a message asking you to type an answer or select the default answer.

figure 6
Figure 6. Fink is waiting for a response.

If the package is installed, the status column in the FinkCommander window gets updated. The columns "Installed," "Latest," and "Binary" display the version of the installed package, the latest available source version, and the latest available binary version, respectively. If you install a binary package, it's possible the installed version is outdated. Mostly, the source versions of the packages are newer than the binary versions.

figure 7
Figure 7. The package libxslt has been installed.

Finally, removing a package is easy: select the package and choose the menu item Binary -> Remove.

You can also install packages directly with the command-line programs of Fink in Terminal.app. For example, in order to find all packages that have something to do with DocBook, you use the command "apt-cache search":

figure 8
Figure 8. Search packages with the command "apt-cache search."

Installing a package is possible with the command "apt-get install":

figure 9
Figure 9. Install packages with the command "apt-get install."

You can install more than one package at the same time. Just specify all the names of the packages with a space between them. Besides, you have to execute the apt-get install command with sudo because a normal user doesn't have the permissions to install software. If you didn't execute sudo within the last five minutes or so, you'll have to supply the password of the account you're logged in with.

If a binary version of the package doesn't exist, it's possible that Fink has a source version of it. Since you can't install it with apt-get, you have to use the fink command to install the package from source, as explained in the next section. If the fink command doesn't have the package listed either, it isn't even available in the collection of source packages.

If apt-get can't find a package to install, it outputs the following message:

figure 10
Figure 10. The package isn't available as a binary package.

A list of installed packages can be generated by the command "dpkg -l":

figure 11
Figure 11. A list of installed packages.

Removing a binary package can be done with the command "apt-get remove":

sudo apt-get remove libxslt

Installing Packages from Source

If you want to install packages from source, you need Apple's XCode Tools. You can find them on the developer site of Apple. (You have to register on ADC for the Apple Developer Connection Online Program.) After installing Xcode Tools, you'll have GNU development tools like the compiler gcc available on your system. Now you can install Fink packages from source.

If you also want to install X11 programs with Fink from source, you have to install the X11 Software Development Kit. On Tiger, this is installed by default when you install the Xcode Tools. On Panther, however, it isn't installed by default. You can find the package X11SDK.pkg on the Panther Xcode CD. You have to choose a custom install in the Xcode installer and select the X11 SDK, or install it by double-clicking the package in the Finder.

If you have Xcode Tools and, optionally, X11SDK installed, you can install packages from source in FinkCommander. Just select the package and choose the menu item Source -> Install, or click on the second leftmost icon in the icon bar (a text ".h" with a green plus sign). Note that for packages where a binary install isn't available, the icon and menu item are grayed out.

You can follow the process of configuring, compiling, and installing the package in the lower half of the FinkCommander window:

figure 12
Figure 12. The package fop has been installed from source.

Removing a package installed from source can be done in the menu item Source -> Remove.

You don't need FinkCommander for this. You can use the "fink" command in Terminal.app. To list all packages with a specified string in their name, you can use the command "fink list." Moreover, if you want to search all package descriptions as well as package names for a string, you can use the command "fink apropos." An example:

figure 13
Figure 13. Search packages with the commands "fink list" and "fink apropos."

If you want to install a package in Terminal.app, you can use the command "fink install." Just as with the binary equivalent, "apt-get install," you can install more than one package at a time by specifying the names of all packages. You also have to execute the fink install command with sudo. For example:

sudo fink install lftp-ssl

Removing a package goes as simple as this:

sudo fink remove lftp-ssl

Updating Fink

If you've been using Fink for some time, you have to make sure you download the newest listing of available packages from time to time. In FinkCommander, you can update the list of available binary packages in the menu item, Binary -> Update descriptions, like you did after the installation.

In Terminal.app you can do the same with the command "sudo apt-get update":

figure 14
Figure 14. Update the list of packages with the command "apt-get update."

The update process merely updates the list of packages. If you want to upgrade the installed packages to the newest version, you have to select Binary->Dist-upgrade packages in FinkCommander or execute sudo apt-get upgrade in Terminal.app. This can take a while if you have a lot of packages installed.

For source packages, the same process can be done using the menu items Source->Selfupdate followed by Source->Update-all in FinkCommander. In Terminal.app, the same can be done with "fink selfupdate; fink update-all."

Besides, if you want to upgrade a specific package, just install it.

Final Thoughts

Fink and FinkCommander can be used to install lots of Unix programs on Mac OS X. This article showed you the basics of Fink's capabilities. For more information, see the documentation of Fink on the website. You can indeed do a lot more things with Fink and FinkCommander to manage your Unix applications.

Koen Vervloesem has a master's degree in computer science and has been freelancing as an IT journalist since 2000, primarily for Dutch IT magazines.


Return to the Mac DevCenter

Copyright © 2009 O'Reilly Media, Inc.