Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] Querying remote p2 repositories

HI,
answers inline...


On Jul 27, 2012, at 16:27, Kopecz, Klaus wrote:

Hi Henrik,
I'm a little confused what the "p2 area" actually means. My assumption was that it corresponds to the "p2" folder an Eclipse installation again containing core/engine/repository folders with cached data etc. Does your comment mean that I can refer also to an empty folder when instantiating the ProvisioningAgent like IProvisioningAgent agent = agentProvider.createAgent(new URI("file:/myEmptyFolder")); ?
If this would be fine for the agent, I could create the Repository Manager and proceed ...

IIRC, one p2-agent = one p2 area - i.e. the p2 api operates in a context. Don't know what is needed to initiate such an area though - have not written such code myself.

Interesting that you mention b3 aggregator (I'm heavily using it and praising it all the time ...). A very basic task of b3 is to read metadata from remote repositories, but I guess it's done also using a p2 agent? Or would I be able to reuse a "simpler" read API from B3?

It uses a separate p2 agent afaik (or it would screw up its own configuration). You can probably look at the code in the b3 aggregator.
You can use a simpler read api in b3. I have written such code - e.g. "load this repository into a model", then get information from the EMF model.
It is quite easy actually.

The use case behind my question is that I'm creating .product files (product configuration files) out of (well-controlled) p2 repositories. The products are then materialized with Tycho. Unfortunately, .product files must contain a list of all installable units which makes up the product. For me the p2 repository is the main unit of granularity and whenever something changes with this p2 repo, this shall be reflected automatically within my next product build. 

Seems like the B3 aggregator "load repository" and then picking up the information you need would work just fine. You could even go fancy, and write a snapshot of the model, and compare with a freshly loaded repository (EMF compare could probably be used for that - or write something since you are probably not interested in comparing everything). You do however need to be familiar with the structure of a p2 repo/meta-data, the model itself does not really help you with that (i.e. the semantics of what is described). It is however *way* easier to write code against than the alternatives. Note that you do not need the entire b3 aggregator, just a couple of EMF bundles as you are only interested in reading (possibly writing) p2 repositories. 

... Therefore, I'm extracting all features from a content.xml and populate the .product file before building the product.
Don't know what you have to jump through such hoops with Tycho. We are using Buckminster to build products, never have to do something similar. Just rematerialize and build - always built with the latest bundles satisfying the constraints from the given repositories. We do use feature based product builds, as the Eclipse tooling for bundle based products is quite bad. (cloudsmith / geppetto @ github is a good example on multi platform build with Buckminster and feature based product builds btw). Saying this if you can do something similar with Tycho.

Hope that helps you.
Regards
- henrik

Regards,
Klaus

From: p2-dev-bounces@xxxxxxxxxxx [mailto:p2-dev-bounces@xxxxxxxxxxx] On Behalf Of Henrik Lindberg
Sent: Freitag, 27. Juli 2012 15:54
To: P2 developer discussions
Subject: Re: [p2-dev] Querying remote p2 repositories

You were on the right track - what you want is a "p2 area" that is used for the purpose of answering your queries. You want that to be separate from the "p2 area" used in the application that wants the answers to those queries - or you will pollute the runtime with queried meta data (caches etc.). This way you can decide if you want to keep the cached data for the next invocation (able to answer queries faster if nothing has changed in the repositories you are querying etc).

Not sure if there is any command line "p2 query" utilities around.

One approach is to use the b3 aggregator project's EMF model of p2 repositories (it can load p2 repositories using the p2 api's, it allows manipulation of the repository and you can write it out again as a p2 repository. But guess this is just as difficult in your Maven/Tycho context as using a p2 agent and a p2 query. OTOH, the b3 aggregator is a tool for performing slicing/dicing/validation/aggregation/mirroring and reauthoring of p2 repositories - maybe what you want to do falls into this category? 

Hope that helps.

Regards
- henrik

Henrik Lindberg
henrik.lindberg@xxxxxxxxxxxxxx



On Jul 27, 2012, at 15:42, Kopecz, Klaus wrote:


I'm looking for a simple way to query a remote p2 repository (simple and/or composite). The p2-API documentation at help.eclipse.org indicates that this can be done in the context of having a ProvisioningAgent representing the "p2 area" of an Eclipse installation.
My context is different. I want to query a p2 repository in the context of a Maven/Tycho build and therefore cannot refer to any profile or "p2 area". Therefore, I'm looking for some basic p2 infrastructure which can read (or even query) the metadata of a remote repository basically by providing the URL. While I could write some stuff to read and analyze a remote content.xml file, things get more complex if I want to abstract from having simple and/or composite repositories which differ in their file layouts and decomposition into multiple metadata sources. Having something which could do this abstraction for me would be helpful.
Thanks for any suggestions ...
_______________________________________________
p2-dev mailing list
p2-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/p2-dev

_______________________________________________
p2-dev mailing list
p2-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/p2-dev


Back to the top