wiki:howto/ShareArchives

Version 1 (modified by alex.malinovich@…, 16 years ago) (diff)

Original writeup

<- Back to the HOWTO section

Sharing Archives

  • Audience: Users who want to share binary archives between machines
  • Requires: MacPorts >= ?? (whenever archive support was added)

Introduction

For those of you fortunate enough to have access to more than one Mac to work from, here's a quick way to save yourself a lot of compiling time. What we're basically going to do here is configure macports to use the archive system, and then copy over archives as we need them. (Or, you can use rsync to always keep the two in sync.) The other thing we'll also go over is how to share archives between two machines that use a different architecture.

Common Configuration Steps

Enable Archive Mode

For starters, lets edit your macports.conf file and enable archive mode. Your macports.conf is found in ${prefix}/etc/macports/macports.conf. For most people, this will be /opt/local/etc/macports/macports.conf. Edit this file in your editor of choice and look for "portarchivemode". It will probably be set to "no" by default. Change it to a "yes" and then save the file.

Share archives between identical architectures

If you're using two machines that are both the same architecture (i386 or powerpc) then you have it relatively easy. Lets say that you want to copy a compiled copy of sqlite3 over to your other machine. We'll use the terms 'source' and 'target' to describe the two machines here. The source is the one that already has it installed.

Build the archive on the source machine

sudo port archive sqlite3

Install the archive on the target machine

Now if you look on your source machine in ${prefix}/var/macports/packages/darwin/${arch} (where ${arch} is either i386 or powerpc) you should find a file named 'sqlite3-x.x.x_x.i386.tgz'. (The x's are the version number.) Copy that file to the same location on your target machine. Now on the target do:

sudo port unarchive sqlite3

followed by:

sudo port install sqlite3

And you're done! Easy huh? :)

Note: AFAIK the unarchive step should not be necessary, but I've been unable to get it to work without it. If you have more information on this please feel free to post it here.

Share archives between different architectures

WARNING!!''' Sharing archives between different architectures could, in theory, seriously b0rk your system! You have been warned!

Now, here's the fun part. Say you have an i386 machine and a powerpc machine. Chances are that the i386 machine is a fair bit faster. But you can't share binaries between them... or can you? Thanks to the +universal variant, it's possible. Here's a good primer on howto/buildUniversal building universal binaries?.

Unfortunately, just doing this is not enough. The archive system still knows where the archive was built, so by default a powerpc system will not use an i386 archive and vice versa. So what do we do? Well, we start with the simple steps. We'll be using the same example as above (sqlite3) going from a source i386 machine to a target powerpc machine.

Build the archive on the source machine

sudo port archive sqlite3 +universal

Install the archive on the target machine

Now we're going to copy the file to the same location on the target machine. On our source machine we're going to find the file /opt/local/var/macports/packages/darwin/i386/sqlite3-x.x.x_x+universal.i386.tgz We're going to copy that file to the target machine. But the target won't have the appropriate directory, since it's a different architecture. So we're going to copy it into /opt/local/var/macports/packages/darwin/powerpc/ instead.

You'll also notice that the archive has the architecture in the name. So we'll need to change that as well. Just rename the file and change i386 to powerpc.

Finally, we can proceed with the installation:

sudo port unarchive sqlite3 +universal

followed by:

sudo port install sqlite3 +universal

Note that we're specifying the variant in both cases. Otherwise the commands wouldn't find the archive file and this wouldn't work. (Because the archive file has +universal in the name.)

So that's it! Enjoy! :) <- Back to the HOWTO section