在 Equinox 中,是否可以将 OSGi 包标记为从包含功能的 p2.inf 开始?

发布于 2024-09-06 11:07:33 字数 709 浏览 2 评论 0原文

我有一个 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 相关的答案也将非常有用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花坊 2024-09-13 11:07:33

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

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

PDE/Build 在构建产品时会自动执行此操作。您可以通过创建一个小的 rcp 产品构建来查看生成的 p2.inf,该构建具有捆绑包的启动级别。
产品构建中生成的 p2.inf 将是 buildDirectory/features/org.eclipse.pde.build.container.feature/product/p2.inf

这是我从构建中修改的一个示例,其中设置org.eclipse.equinox.common 的启动级别。 $version$ 将被 p2.inf 所属功能的版本替换。请注意“hostRequirements”,它指定了我们所属的包的片段。

#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

问题答案:

  1. 0、1、2

    这些数字有些随意,它们仅用于将一组属性(requiresunits 或其他)与另一组属性分开。这里的 requires 使用了“2”,只是因为我从 pde.build 生成的大型 p2.inf 中复制了它,并且忘记像对units.0 那样更改它。

  2. 这一切有必要吗?

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

    对于“安装”

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

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

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

  3. 主机要求。可安装的单元片段页面仅描述片段是什么,没有提及如何创建片段。 自定义元数据页面上曾提到过这一点,但没有解释。

    文档,wiki 上的 p2 类别 下有很多内容。 接触点说明上的页面可能会很有趣。 help.eclipse.org,但总的来说,我认为这比文档中的内容更高级。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文