Thursday, August 2, 2012

Mirroring a p2 repository

For builds or for resolving a target platform eclipse often needs to connect to remote update sites. If you are behind a proxy or on a slow connection this can be annoying. A solution to that could be a local mirror of an update site.

Eclipse provides two applications to do exactly that (executed on a shell):
<eclipse install dir>/eclipse -nosplash -verbose -consoleLog -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source <update site> -destination<local folder>
<eclipse install dir>/eclipse -nosplash -verbose -consoleLog -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source <update site> -destination<local folder>
The first one mirrors artifacts like, plugins, features, additional libraries and so on. The second one mirrors metadata like bundle dependencies or repository content overview.

You can add proxy settings by providing http.proxyHost / http.proxyPort properties to the command. To mirror the Juno repository to C:\p2\Juno you would use:
<eclipse install dir>/eclipse -Dhttp.proxyHost=proxy.nowhere.com -Dhttp.proxyPort=80 -nosplash -verbose -consoleLog -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source http://download.eclipse.org/releases/juno -destination file:/C:/p2/Juno/
<eclipse install dir>/eclipse -Dhttp.proxyHost=proxy.nowhere.com -Dhttp.proxyPort=80 -nosplash -verbose -consoleLog -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source http://download.eclipse.org/releases/juno -destination file:/C:/p2/Juno/

For details see the online documentation or the wiki entry.

9 comments:

  1. This works for composite repositories as the Juno release repository as well?
    I always assumed b3 or something similar is required to mirror more complex p2 repositories like the release repositoriy (which may contain multiple versions and link to different repositories of the various subprojects.)

    ReplyDelete
  2. I guess you've got to give it a try. I mirrored indigo and the subclipse update site this way.
    But beware, this might be a big download. (Indigo is ~4GB)

    ReplyDelete
  3. This works for composite repos (such as Juno) but the content of the various children repos are collapsed into one standard p2 repo.

    ReplyDelete
  4. Thank you for pointing that out!

    I'm glad I don't have to try and get b3 to run and can use common p2 features for mirroring now.

    ReplyDelete
  5. I must be doing something wrong... 4.2/Juno is only 1.9gb big - what am I missing?
    I created a mirror of http://download.eclipse.org/releases/juno/ and I tried to include everything (cf: http://paste.debian.net/hidden/578544a5/ ) but I guess I must've missed a few things.

    So far everything works well though... maybe it's this small due to pack200-compression of the jar-files?

    Thanks for your help!

    PS: Sorry for flooding your blog, if you mind I'll divert this conversation to a different place like the forums any time.

    ReplyDelete
    Replies
    1. 1.9GB is perfectly ok. I get the same result and to me it seems as everything is there. Remember that the indigo repository contains 2 updates, so a lot of jars exist in multiple versions there. This is not the case for juno yet, but will change when the service releases come out.

      Delete
    2. Thank you very much! I'm glad to hear that.

      Delete
    3. Actually there WAS something missing: we did not mirror metadata. So all the plugins were there, but you could not use it as a local update site. I updated the blog post accordingly

      Delete
  6. http://wiki.eclipse.org/Equinox_p2_Repository_Mirroring

    ReplyDelete