Command line to find units in a p2 repository using p2 query language

守給你的承諾、 提交于 2019-12-30 07:13:29

问题


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)?


回答1:


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 be

eclipse -application org.eclipse.equinox.p2.director \
   -repository http://download.eclipse.org/releases/juno \
   -list 'Q:everything.select(x | x.id == "org.eclipse.sdk.ide")'

As 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):

eclipse -application org.eclipse.equinox.p2.director \
   -repository <URL of some small repository> \
   -list 'Q:everything.select(y | everything.select(x | x.properties ~= filter("(org.eclipse.equinox.p2.type.category=true)")).collect(x | x.requirements).flatten().exists(r | y ~= r))'



回答2:


p2diff tool written by Ian Bull is is well worth mentioning. His article provides an overview of the p2 API and introduces some of the key concepts that should be understood to work with the p2 API.



来源:https://stackoverflow.com/questions/18082719/command-line-to-find-units-in-a-p2-repository-using-p2-query-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!