p2 has a query language that allows to run queries on the content of a p2 repository. However all examples in the documentation assume that the query language is used from within Java, e.g.
IQuery<IInstallableUnit> q = QueryUtil.createMatchQuery("this.id == $0", id);
metadataRepository.query(q);
How can I execute a query from the command line (without writing my own Java application)?
The p2 director application has an option to list or query the content of the given p2 repositories. With
-list
you'd get all units, and with-list Q:<p2 QL collection query>
you can query for a subset.The expression needs to be a collection query, so instead of the match query in the example given above, you need to use the equivalent collection query. Also, placeholders like
$1
must be replaced by the actual values.Example: The command line to look for the all
org.eclipse.sdk.ide
units in the Juno release train repository would beAs a more useful example, you could use this command to find all units which are shown in categories in the p2 user interface (although I wouldn't try a large repository, the query seems to be quite slow):