在Equinox中是否可以从包含的功能的p2.inf开始标记OSGi包? [英] In Equinox Is it possible to to mark an OSGi bundle as started from its containing feature's p2.inf?

查看:154
本文介绍了在Equinox中是否可以从包含的功能的p2.inf开始标记OSGi包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含几个软件包的Eclipse功能。我想告诉p2将其中一个包标记为在安装该功能时开始的。这样可以使用自己的META-INF / p2.inf捆绑包,

  instructions.configure = markStarted(started:true )

但是我想在功能级别而不是捆绑级别有问题是第三方,如果可能,我不想以任何方式修改它)。



一些研究使我得到了本文档,这表明应该可以将配置指令移动到包含功能的p2.inf。我已经尝试了所有明显的事情,如

  units.0.id =< bundle symbolic name> 
units.0.instructions.configure = \
org.eclipse.equinox.p2.touchpoint.eclipse.markStarted(started:true)

但到目前为止,我尝试过的任何排列都没有任何效果:因为没有发生任何事情,捆绑包没有标记为启动,没有报告错误)。



任何指针都将非常受欢迎。与Eclipse Equinox Galileo(3.5.2)有关的Helios的答案也将非常有用。

解决方案

单位。#。 p2.inf条目创建一个新的可安装单元,它们不会修改其他现有的IU。



您基本上必须创建一个完整的可安装单元片段 。该片段具有相关说明,并附加到您的包的IU。然后,您需要从您的功能添加一个要求到这个新的IU。



PDE / Build在构建产品时自动执行此操作。您可以通过创建一个小的rcp产品构建来看到生成的p2.inf,它具有您的捆绑包的起始级别。

产品构建中生成的p2.inf将是 buildDirectory /功能/ org.eclipse.pde.build.container.feature / product / p2.inf



这是一个从构建中修改的示例它为 org.eclipse.equinox.common 设置起始级别。 $ version $ 将被p2.inf所属功能的版本所取代。请注意hostRequirements,它指定了我们是一个片段的bundle。

 #创建IU片段的要求正在创建
requires.2.namespace = org.eclipse.equinox.p2.iu
requires.2.name = configure.org.eclipse.equinox.common
requires.2.range = [$ version $,$ version $]
requires.2.greedy = true

#创建一个名为configure.org.eclipse.equinox.common的$ I $单位
units.0 .id = config.asp $ b units.0.provides.1.name = configure.org.eclipse.equinox.common
units.0.provides.1.version = $ version $
units.0.instructions.install = installBundle(束:$ {工件});
units.0.instructions.uninstall = uninstallBundle(bundle:$ {artifact});
units.0.instructions.unconfigure = setStartLevel(startLevel:-1); markStarted(started:false);
units.0.instructions.configure = setStartLevel(startLevel:2); markStarted(started:true);
units.0.hostRequirements.1.namespace = osgi.bundle
units.0.hostRequirements.1.name = org.eclipse.equinox.common
units.0.hostRequirements.1。 range = [3.6.0.v20100503,3.6.0.v20100503]
units.0.hostRequirements.1.greedy = false
units.0.hostRequirements.2.namespace = org.eclipse.equinox。 p2.eclipse.type
units.0.hostRequirements.2.name = bundle
units.0.hostRequirements.2.range = [1.0.0,2.0.0]
units.0 .hostRequirements.2.greedy = false
units.0.requires.1.namespace = osgi.bundle
units.0.requires.1.name = org.eclipse.equinox.common
units.0.requires.1.range = [3.6.0.v20100503,3.6.0.v20100503]
units.0.requires.1.greedy = false

回答问题:


  1. 0, 2的



    这些数字有些随意,它们仅用于分隔一组属性(需要 units 或其他)。 需要这里使用'2'仅仅是因为我从pde.build生成的大型p2.inf中复制它,并忘记像我这样做的单位更改它。 0。


  2. 是否需要这些?



    是的。需要在type = bundle上的第二个 hostRequirements 。在Helios中,除了翻译片段,只有一个片段可以附加到IU。通常,默认IU可用于设置所有osgi包的默认启动级别。为了使我们的自定义片段被选择为默认的片段,它必须具有更高的特异性,这是满足主机要求的数量。



    对于安装



    units.0.instructions.install = installBundle(bundle:$ {artifact});
    units.0.instructions.uninstall = uninstallBundle(bundle:$ {artifact});



    instructions.install instructions.uninstall 指的是p2进程的阶段。 installBundle uninstallBundle 指的是OSGi意义上的安装/卸载。您的捆绑包必须安装到OSGi系统中,然后才能执行其他操作。这基本上将它添加到config.ini或org.eclipse.equinox.simpleconfigurator / bundles.info文件中。



    大多数p2安装将已经包含默认配置IU将安装并设置软件包的默认启动级别(4)。但是,目前只有一个配置片段可以应用于每个软件包,因此当您添加自己的软件包时,默认值不再适用于您的软件包。


  3. hostRequirements 。可安装的单元片段页面只是描述片段是什么,没有参考如何创建一个。 自定义元数据页面已经被提及,但未解释。



    文档中,维基上有一些内容是 p2类别接触点说明上的页面可能很有趣。有一些帮助 help.eclipse.org ,但是一般来说,我认为这是更为先进的。



I have an Eclipse feature which includes several bundles. I want to tell p2 to mark one of those bundles as started when the feature is installed. This is possible using the bundles own META-INF/p2.inf like so,

instructions.configure = markStarted(started: true)

but I want to do this at the feature-level rather than the bundle-level (the bundle in question is third-party, and I'd prefer not to modify it in any way, if possible).

Some research has led me to this document which suggests that it should be possible to move the configure instructions to the containing feature's p2.inf. I've tried all the obvious things like,

units.0.id = <bundle symbolic name>
units.0.instructions.configure = \
  org.eclipse.equinox.p2.touchpoint.eclipse.markStarted(started: true)

but so far none of the permutations I've tried have any effect: as in nothing happens, the bundle isn't marked as started and no errors are reported).

Any pointers would be very welcome. The is with Eclipse Equinox Galileo (3.5.2) ... answers relating to Helios would also be very useful.

解决方案

The "units.#." p2.inf entries create a new Installable Unit, they don't modify other existing IUs.

You basically have to create an entire Installable Unit fragment. The fragment has the relevant instructions and attaches to your bundle's IU. Then you need to add a requirement from your feature to this new IU.

PDE/Build does this automatically when building products. You could see the generated p2.inf by creating a little rcp product build which has a start level for your bundle.
The generated p2.inf in a product build will be buildDirectory/features/org.eclipse.pde.build.container.feature/product/p2.inf

Here is an example I modified from a build which sets the start level for org.eclipse.equinox.common. The $version$ will get replaced by the version from the feature that the p2.inf belongs to. Notice the "hostRequirements", which is specifying the bundle we are a fragment of.

#create a requirement on the IU fragment we are creating
requires.2.namespace=org.eclipse.equinox.p2.iu
requires.2.name=configure.org.eclipse.equinox.common
requires.2.range=[$version$,$version$]
requires.2.greedy=true

#create a IU frament named configure.org.eclipse.equinox.common
units.0.id=configure.org.eclipse.equinox.common
units.0.version=$version$
units.0.provides.1.namespace=org.eclipse.equinox.p2.iu
units.0.provides.1.name=configure.org.eclipse.equinox.common
units.0.provides.1.version=$version$
units.0.instructions.install=installBundle(bundle:${artifact});
units.0.instructions.uninstall=uninstallBundle(bundle:${artifact});
units.0.instructions.unconfigure=setStartLevel(startLevel:-1);markStarted(started:false);
units.0.instructions.configure=setStartLevel(startLevel:2);markStarted(started:true);
units.0.hostRequirements.1.namespace=osgi.bundle
units.0.hostRequirements.1.name=org.eclipse.equinox.common
units.0.hostRequirements.1.range=[3.6.0.v20100503,3.6.0.v20100503]
units.0.hostRequirements.1.greedy=false
units.0.hostRequirements.2.namespace=org.eclipse.equinox.p2.eclipse.type
units.0.hostRequirements.2.name=bundle
units.0.hostRequirements.2.range=[1.0.0,2.0.0)
units.0.hostRequirements.2.greedy=false
units.0.requires.1.namespace=osgi.bundle
units.0.requires.1.name=org.eclipse.equinox.common
units.0.requires.1.range=[3.6.0.v20100503,3.6.0.v20100503]
units.0.requires.1.greedy=false

Answers to questions:

  1. 0's, 1's, 2's

    These numbers are somewhat arbitrary, they serve only to separate one set of properties (requires or units or whatever) from another. The requires here used a '2' simply because I copied it from a large p2.inf that was generated by pde.build and forgot to change it like I did the units.0.

  2. Is all this necessary?

    Yes. The second hostRequirements on the type=bundle is needed. In Helios, with the exception of translation fragments, only one fragment can be attached to an IU. Generally a default IU is available that sets the default start level for all osgi bundles. In order for the our custom fragment to be chosen over the default one, it must have a higher "specificity" which is the number of satisfied host requirements.

    For "install"

    units.0.instructions.install=installBundle(bundle:${artifact}); units.0.instructions.uninstall=uninstallBundle(bundle:${artifact});

    The instructions.install and instructions.uninstall refer to phases of the p2 process. The installBundle and uninstallBundle refer to install/uninstall in the OSGi sense. Your bundle must be installed into the OSGi system before you can do anything else. This basically invovles adding it to the config.ini or org.eclipse.equinox.simpleconfigurator/bundles.info files.

    Most p2 installs will already contain a default configuration IU that will install and set the default start level (4) for bundles. However, currently only one configuration fragment can be applied to each bundle, so when you add your own like this the default no longer applied to your bundle.

  3. hostRequirements. The installable Unit fragments page just describes what a fragment is with no reference on how to create one. It is biefly mentioned on the Customizing Metadata page, but not explained.

    Documentation, there is a bunch of stuff on the wiki under the p2 category. the page on the touchpoint instructions might be interesting. There is some help on help.eclipse.org, but in general, I think this is a bit more advanced that what there is documentation for.

这篇关于在Equinox中是否可以从包含的功能的p2.inf开始标记OSGi包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆