Transferring complete MacPorts prefix to other Mac (was: Two simple questions)

Ryan Schmidt ryandesign at macports.org
Mon May 9 03:16:58 PDT 2011


On May 8, 2011, at 12:59, Rodolfo Aramayo wrote:

> Say I set up a complex installation of MacPorts (i.e., tonos of different ports) using standard procedures (i.e., everything installed in the /opt/... directory) in an Intel iMac
> 
> My questions are:
> 
> 1. Can I now just copy that directory to another iMac having the same hardware architecture (i.e., from a i386 to another i386 or x86_64 to another x86_64)???
> 2. Can I do the same from a say i386 to x86_64??
> 
> I am asking this because I thought this to be possible (e.g., from i386 to i386) and things work, BUT I am observing an unusual number of failed port updates and crashes on those machines....and so I suspect something else is happening here...???

If you really want to, and know what you're doing, yes, you should be able to do this, if the arch and OS version match, but it would be a one-time operation; after the copy, the two MacPorts installs would be separate, and you would upgrade ports separately on each computer. You would also need to take special care to preserve the hardlinks that MacPorts uses, else you would end up taking up twice as much disk space as necessary on the target machine. You must also understand that MacPorts is not necessarily completely confined to the /opt/local prefix. Some ports may install things outside it (e.g. /Applications/MacPorts and /Library/Frameworks). So the question is why do you want to do this?

I recommend you simply install MacPorts on the second Mac and install the ports you want on it, completely separately from the first Mac.

However, if you're determined to try a wholesale copy of an existing MacPorts installation, I might do it this way. First, do some cleanup on the source Mac. Look at the list of inactive ports (port installed inactive) and see if there are any you still want. If so, activate them ("sudo port activate ...") and uninstall the rest ("sudo port uninstall inactive"). You should probably remove any incomplete build directories, and may want to remove some or all distfiles ("sudo port clean --all all" will do both). Now the simplest way to actually do the transfer would be to first deactivate all ports ("sudo port -f deactivate installed"). This will ensure that all ports are contained within /opt/local (specifically, within /opt/local/var/macports/software). Now you can transfer /opt/local to the other Mac (using a method that will preserve ownership, permissions and symlinks). You'll need to set up your PATH on the second Mac if you haven't already. Now you can "sudo port activate installed" on both Macs to re-activate everything and re-create the hardlinks wherever they go.

Yes you could copy a MacPorts installation from an i386 Mac running Snow Leopard to an x86_64 Mac running Snow Leopard but that would not be optimal because on the x86_64 Mac it would be better to build the software as x86_64. If you don't care that the software will not run as fast as it could on x86_64, or that you can't use more than 4GB of memory per program, then you can continue to maintain MacPorts as i386 on your x86_64 Mac if you wish. You'll want to set build_arch to i386 in macports.conf then, to prevent MacPorts from wanting to rebuild everything as x86_64 at its earliest opportunity.

Make sure Xcode is up to date as well.





More information about the macports-users mailing list