Monday, May 15

Darwinports from source

I've used DarwinPorts for some time now (admittedly as a crutch from when I used FreeBSD as my desktop), but I hadn't installed anything new since I upgraded to my MacBook. It certainly has some rough edges, but it beats the heck out of tracking down the thirty dependencies for the latest software you want to install (in my case subversion).

I prefer to put all my darwinports stuff in a separate directory tree from the rest of the system (~/opt), that way I don't have to build anything as root and I can avoid the unpleasantness of darwinports trashing system software and vice versa. Basically avoiding running anything as root is a good thing[TM] in my book. The old version of dp I had installed was not a universal binary, so I needed to upgrade it. dp can be downloaded as a disk image, but I couldn't find any way to install it in a different location. So, I just downloaded the source and tried to build it myself.

Here's where the rough edges come in. dp configured just fine, but when I ran make I got the inexplicable error:

===> making install in config
/bin/sh: line 1: cd: config: No such file or directory
make: *** [install] Error 1

Now there was indeed a config directory sitting right there, so I rooted through the makefiles to find where it was trying to change to it, thinking it had changed directories somewhere else first or something. I found what I was looking for in the Mk/ I does your typical recursive make dance:

for subdir in config doc src portmgr; do echo ===\> making all in $subdir; ( cd $subdir && make DIRPRFX=$subdir/ all) || exit 1; done

I added some code above to echo the cwd and it showed it was in the right dir, but when I added cd config it blew up. I tried a few different things to no avail, then I remembered seeing something similar on our make system here at work when trying to build things on the Mac. It had something to do with the bourne shell the Mac uses, though I didn't remember what. So I figured, "let's try bash":

make SHELL=/bin/bash && sudo make install SHELL=/bin/bash

And voila! It works. I still don't know what gives with /bin/sh, but I'm off to the races...