Installing UNIX software on Mac OS X (10.4): Fink and DarwinPorts
Fink and DarwinPorts are two package managers (similar to Gentoo's Portage or Debian's apt-get), allowing you to install UNIX software on your Mac OS X installation.
Fink
Fink has the largest repository of UNIX packages for Mac OS X. There is a nice graphical installer available. Fink usage, however, is somewhat confusing to me.
Everything installed with Fink (including Fink itself) goes into the /sw directory. With Fink, you can install either from source or from a binary distribution. However, there are lots of packages not available in the binary distribution, so installing from source is recommended. To install binaries, use the apt-get tool.
Fink Usage
Note that, if properly setup, it is better to run Fink via an administrator account than via the root account. This is because Fink sets up the PATH environment variable correctly for the administrator but not for root.
Listing installed packages:
# fink list -i
Listing outdated packages:
# fink list -o
Updating Fink to a new version (this also updates the packages descriptions, like emerge --sync on Gentoo):
# fink selfupdate
Install a package:
# fink install packagename
Updating all outdated packages (similar to emerge world on Gentoo):
# fink update-all
Updating all outdated packages, using the binary distribution if possible:
# fink -b update-all
Listing all files in the system corresponding to a given package:
# dpkg -L packagename
Troubleshooting Fink
Coming from the Fink FAQ:
Q6.14: I can't install anything because I get "dpkg: parse error, in file `/sw/var/lib/dpkg/status'"! A: This means that somehow your dpkg database got corrupted, usually from a crash or some other unrecoverable error. You can fix it by copying the previous version of the database, like so: sudo cp /sw/var/lib/dpkg/status-old /sw/var/lib/dpkg/status You may need to re-install the last couple of packages you installed before the problem started occurring.
If you encounter a conflict while trying to run fink update-all, sometimes this can be solved by updating packages one at a time.
DarwinPorts
I find DarwinPorts easier to use than Fink. DarwinPorts repository contains less packages, but some packages in DarwinPorts are not available in Fink. On the whole, important packages (Apache, PHP, vsftpd) are in DarwinPorts.
DarwinPorts installs all software in /opt/local. Binaries install are not possible, everything is compiled from source. Note that when updating your packages, DarwinPorts does not delete the old package but just tags it as "unactive" and deactivates it.
DarwinPorts Usage
Updating the package tree (emerge --sync on Gentoo):
# port sync
Updating DarwinPorts:
# port selfupdate
Listing installed packages:
# port installed
Listing outdated packages:
# port outdated
Updating all outdated packages (similar to emerge world on Gentoo):
# port upgrade installed
Updating all outdated packages and deleting old packages (not just deactivating them):
# port -u upgrade installed
Troubleshooting DarwinPorts
If you encounter problem with port sync, try to run this command with sudo (eg sudo port sync). In fact, contrary to Fink it seems that port should always be ran as root.