Installing UNIX software on Mac OS X (10.4): Fink and DarwinPorts

From Elvanör's Technical Wiki
Jump to navigation Jump to search

Fink and MacPorts 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.

MacPorts

I find MacPorts easier to use than Fink. MacPorts repository contains less packages, but some packages in MacPorts are not available in Fink. On the whole, important packages (Apache, PHP, vsftpd) are in MacPorts.

MacPorts installs all software in /opt/local. Binaries install are not possible, everything is compiled from source. Note that when updating your packages, MacPorts does not delete the old package but just tags it as "unactive" and deactivates it.

Portfiles are located in /opt/local/var/db/dports/sources.

MacPorts 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

This last thing does not seem to work correctly (it won't delete old packages). I think it's better to do a simple "port upgrade installed" followed by

# port -f uninstall inactive

The -f is necessary.

  • Listing a package content:
# port contents port_name
  • Removing entirely a port (you must do this in order to rebuild fully a package)
# port clean --all port_name

Troubleshooting MacPorts

  • 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.
  • There is a very useful man page for port. However the MANPATH is not correctly set, so you may have to correct it.
  • WARNING: MacPorts does not seem to have any built-in support for configuration files! Thus you have to be very careful, your configuration files can be overriden when your ports are upgraded.
  • When manually compiling extensions for PHP (example: APC), it is very important that you use the phpize and php-config programs found in the MacPorts distribution. Using the ones provided by Apple will cause problems. One way is to remove these programs from /usr/bin.
  • When updating packages that provide a service or daemon, the launchd item provided by MacPorts will override the previous one. Thus it means that this item will have to be reactivated (using launchctl load -w). Else at the next reboot services will be unavailable.

Useful Links