I had been experiencing a LOT of trouble with MacPorts on OS X after upgrading to Snow Leopard. As it turns out, I apparently was bitten by the perennial case-insensitive filesystem, which of course is the default option when one installs OS X (or has it installed for them via Apple).
So I followed the instructions on Konstantin Läufer’s Blog: Prerequisites for Building OpenWRT SDK on Snow Leopard with a slight amendment, given that I was completely unwilling to change the host filesystem for no particularly compelling reason. (Yes, I am a Unix guy, but I really don’t care about case-sensitivity when I am not doing programming.)
Enter disk images, which is perhaps one of the best OS X features that is taken for granted and can be a true life saver at times. With an disk image, you can create a filesystem that differs from the host as an read-write image, mount it, and use it from the OS or any application–seamlessly. So here are the steps to get /opt/local to live inside a case-sensitive filesystem but be exposed through the host filesystem (so that MacPorts can be maintained properly):
- Launch Disk Utility (Applications -> Utilities -> Disk Utility)
- At your discretion, create either a regular read/write image or sparseimage. Sparse images are the preferred option, especially if you want room for growth. Make sure you enable the case-sensitive option, which is needed for MacPorts (at this time).
- I suggest putting the image somewhere intelligent like your home directory -> Disk Images (create a folder). You may also want to turn off backups of this directory in Time Machine, if you are updating MacPorts frequently. It is easy to put an entire folder under an exclusion list in Time Machine.
- When you created the disk image in step 2, you likely gave it a name. I named my image MacPorts. Upon creation, the image should mount automatically and will stay mounted until you unmount it. In my case, I see the following when I go into Terminal:
/dev/disk3s2 on /Volumes/MacPorts (hfs, local, nodev, nosuid, journaled, noowners, mounted by gkt)
- So by way of example, I did the following. You may opt to do something different, depending on your needs:
mkdir -p /Volumes/MacPorts/opt/local
Make sure /opt does not exist. (I will let you decide how to do this!)
ln -s /Volumes/MacPorts/opt /opt - At this point /opt/local is living on your disk image. You may now proceed with the MacPorts installation on Snow Leopard.