on Feb 19th, 2009p2 in a non-eclipse system
Somebody asked me a great question the other day, can p2 be used in non-eclipse systems? This is a great question because I think it highlights the fact that we don’t always make newcomers aware of the great power contained in the Eclipse components. Most of the Eclipse bundles are not designed simply for the IDE. In fact, for almost all the bundles in the IDE, thought is given for how they can be generalized. The IDE is just an example of how the bundles can be used. When developing software using the Eclipse IDE keep this mind, and you will start to see reuse opportunities everywhere! Of course — getting back to the original question regarding p2 – the answer is a resounding YES!!!
In this particular case, the user wants to use p2 in their own OSGi based application. Not only is this possible, it is remarkably easy (and you can even use the Eclipse tooling to make it easier). For example, when you export a product, select the ”Generate metadata repository”. This will generate a p2 repository for your product, including Installable Units for all of your bundles and features.

Generate Metadata
Following from Kim’s Post, say you have a repository (or even a composite repository) that holds your bundles (we call these Installable Units), you can simply use the Director Application to provision these bundles into your system.
For example:
d:\builder\eclipse.exe
-application org.eclipse.equinox.p2.director.app.application -metadataRepository http://yourrepo.com -artifactRepository http://yourrepo.com -installIU yourIU -destination d:/yourapplication -profile SDKProfile -vmArgs -Declipse.p2.data.area=d:/yourapplication/p2
In this case, you are using the director application to install yourIU (likely a bundle or feature you created) in to your application. The profile option allows you to create a number of different profiles, each containing a different set of bundles. Finally, the p2 data area is the place on disk that holds all the p2 information (such as profile information).
In addition to the director application, you can even reuse the p2 bundles within your OSGi based application to provide automatic updates, customizable profiles and a wide range of other provisioning operations.
What’s even more powerful, is you can use p2 for non-osgi based systems. That’s right, you can install your favorite RPMs, Debs or even MSI (Windows Installer) based applications using p2.
With today’s historic visit in Ottawa (members of the Mozilla team traveling to Ottawa to meet with Boris and Simon), here is an interesting exercise: see if we can use p2 to manage firefox extensions.
Related posts:



I can imagine it’s a lot of fun making p2 manage rpms, debs and windows applications, but I have yet to find a single person who is happy with p2. The current “stable” version in 3.4.1 is just barely usable, because installations get broken all the time, bundles are not being found, or not being activated (with error messages that wouldn’t fit on the screen even if it was 100 times as high).
The list of open issues at speaks for itself, I guess.
@Carsten, I’ve met plenty of people happy with p2 as it’s given them a lot more flexibility. For example, WindRiver is now able to write installers that not only provision bundles with p2, but other native artifacts needed for their embedded tools. Sure, there are people that are unhappy, but that always happens with a technology change. It takes time for things to solidify. The best thing you can do is report bugs and enhancements.
Oh, your query is a bit bogus because it includes open enhancements, you should only query for open bugs if you were trying to prove a point. However, if you query JDT for open bugs, you would see a lot more and who complains about JDT
?
@zx, I don’t argue against the benefits of p2, it surely makes a lot of things possible that were in no way possible before. I’m only concerned about its current state. Most of Eclipse stands for exceptional quality, but this really critical component does not (yet). And last time I checked a 3.4.2 snapshot I feared that 3.4.2 won’t be much better in that regard. (So here I’m whining :-])
And sorry for my bug query including enhancements, I couldn’t find anything regarding “issue type” at the “Advanced Search” tab at https://bugs.eclipse.org/bugs/query.cgi. Maybe I’m blind, but I really couldn’t find it.
Hi zx,
You write: what’s even more powerful, is you can use p2 for non-osgi based systems.
It’s possible to use p2 to create non-osgi based projects in workspaces, to distribute workspaces contents from sites (workspaces provisioning)?.
And after download the workspace, use head-less pde-build to build it. Other question not for this thread would be… can I execute my custom builders with pde-build?
thks a lot,
Juan.
“That’s right, you can install your favorite RPMs, Debs or even MSI (Windows Installer) based applications using p2″
Kind of a pointless statement, unless you show how to do all this… (or link to where in the world one my learn something useable about this wonder tool). The docs currently in the wiki are either oriented towards Eclipse end-users, or for Eclipse insiders. Nothing for someone who’d want to use p2 in their own projects…
There are several resources that show how to use p2 in your own application. Susan (the extremely talented developer behind the new p2 UI) has documented how to use p2 in an RCP application [1] (as well as how to customize it).
[1] http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application
For non OSGi based system (RPMs, Debs, MSI, etc…), I was merely pointing out that this is possible. It requires writing custom touchpoints and is out of the scope of this particular post. If you are interested in this, take a look at the two touchpoint bundles (eclipse and native) to see how some of the standard operations are implemented.
If you are successful with this, please let us know. It would be great to start some documentation on this.
You must admit that developer-oriented documentation for p2 is near non-existent. Other than a glossary and a few cursory articles, pretty much zip and nada. There’s a lot of talk about a “Toast” demo application (including a pretty cool webcast), but the app is nowhere to be found.
P2 will come into its own when it’s properly documented, not before.
DR,
I agree that the developer documentation could use improvement, but the wiki page is full of useful information, the entire p2 teams worked hard this year on the help docs and Andrew Niefer, Jeff McAffer, and myself have been trying to give examples through our blogs.
A big part of the problem is that we (the p2 team) don’t know what help / support / documentation everyone needs. Judging from the p2-dev mailing list, there are a number of people / companies extending p2 for their purposes, so we must be doing something right.
If you have thoughts on what is needed, or can volunteer some time to put examples together, please let us know. I would love to grow the p2 community.
@DR: The Toast demo is becoming more complete and the source code is now available. There is now a preview for the upcoming book “Equinox and OSGi”. All of this can be found at http://equinoxosgi.org/
> A big part of the problem is that we (the p2 team) don’t know what help / support / documentation everyone needs.
@Ian: One solution to this big problem could be complete code and documentation for a simple OSGi bundle that provisions a feature using p2 (not via the command line). I tried a couple of months ago to do this with p2 but failed due to complexity and lack of documentation. I switched to using Apache Karaf’s implementation of features along with OBR to accomplish what p2 can do. Now that the source code to Toast is released, I’m returning to p2 and dissecting Toast to achieve this, but this will take awhile since it’s composed of over 60 projects.
Hi Ian,
I am trying to use the director application to provision bundles for my osgi application. This is my first encounter with P2 and i was hoping that the documentation would be useful and help my setup the runtime pretty smoothly. However i found a few things missing:
1. There are a lot of things that needs to be set up to use p2. For instance if my application only has osgi bundles i found no way to simple use them or group them other than first creating a feature. Now you also need reference to the metadata and artifact repositories which p2 uses which at present i do not know how to create.
2. There is often a reference to a profile. There is SDKProfile for eclipse SDK, there are other profiles as well which are then pointed to by the “eclipse.p2.profile” property. How to create a profile, is not documented. Also if i have to define the kernel layer of my system consisting of a combination of core osgi equinox and felix bundles then does one create a profile for the kernel layer or does one create a feature, is not clear
In general what is missing are the steps to create a p2 driven osgi runtime.
Best Regards,
madhav