Homegrown destroot, maybe chroot?

Ryan Schmidt ryandesign at macports.org
Sat Mar 10 20:06:11 PST 2007

This question isn't about using MacPorts but about how MacPorts does  
something that I want to do elsewhere. How does it do the destroot  

I have some software I would like to build. It happens to be  
Graphviz. There are a dozen other packages on which Graphviz depends.  
Ultimately they need to go into a location under /usr/local which  
would require root access, but I would like to build them in a user- 
writable temporary location first.

If I'm not mistaken, MacPorts accomplishes its destroot phase by  
using, usually

make install DESTDIR=/foo

where /foo is the destroot directory of the work directory. The  
software gets installed in /foo/opt/local/whatever. Then, later,  
during the install phase, everything from /foo gets merged with the  
real /opt/local. Right? Right.

What if I have multiple packages I want to install in the temporary  
directory before installing? Say I want to install libpng, which  
depends on zlib. But if zlib is only in the temporary destroot  
directory, the libpng build won't find it there when I've told it the  
dependencies are to be found in /usr/local. And if I instead tell  
libpng to link with zlib in the temporary destroot, won't that be the  
location where libpng forever looks for zlib, even after I've tried  
to install everything in /usr/local?

Is there a way to make this work? Maybe something I need to do in  
addition to setting DESTDIR during make install? Or is there a  
different option? It occurs to me to try to use a chroot, but I've  
never used one before. Does that sound like a good thing to try --  
make a chroot which contains an empty /usr/local directory, links  
(hard links?) to /usr/bin, /usr/X11R6, /System, and other things the  
build is likely to need, and do the build in there, letting it think  
it's writing to the real /usr/local when it's really not? Any other  
suggestions for building multiple packages in a temporary directory  
before installation?

Thanks for any insight you can offer.

The ultimate goal, in case you're wondering, is that I would like to  
do a complete build of Graphviz -- from decompressing the source  
archives, all the way up to creating a disk image containing an  
installer package -- without requiring root access. Running the  
installer package would require root access, but I don't want the  
build system to require root.

More information about the macports-dev mailing list