ctron / package-drone

An OSGI first software artifact repository – Moved to the Eclipse Foundation
https://github.com/eclipse/packagedrone
Eclipse Public License 1.0
39 stars 13 forks source link

OSGi R5 aspect does not list 'osgi.contract' capability for OSGi Frameworks #130

Closed JFingerle closed 9 years ago

JFingerle commented 9 years ago

I'm using a OSGi R5 Reposiotry provided by Package Drone and I'm trying to resolve a bundle (using bndtools) with the following requirement:

    <requirement namespace='osgi.ee'>
      <directive name='filter' value='(&amp;(osgi.ee=JavaSE)(version=1.5))'/>
    </requirement>

This requirement has to be satisfied by the OSGi framework bundle (in my case org.eclipse.osgi). My OBR provided by Package Drone contains the framework bundle but the resolution fails. This is because in the OBR R5 index the following section for the framework bundle is missing:

   <capability namespace='osgi.contract'>
      <attribute name='osgi.contract' value='OSGiFramework'/>
      <attribute name='version' type='Version' value='5.0.0'/>
   </capability>

If I add the section to the index the resolution works just fine.

The problem with fixing the issue (by adding the section to the index) is that the manifest of the framework bundles (Equinox, Felix etc.) do not explicitly contain this information. The index generator of bnd ("org.osgi.impl.bundle.repoindex.lib", former "bindex" bei Neil Bartlett) uses some custom logic to add the section with the correct OSGi version to the index. I'm not a fan of this approach but it seems there is no other way to do this (if one wants to add the correct OSGi version).

I'm proposing the following to implement this at Package Drone: If a framework bundle is detected by the OSGi R5 aspect the following capability will be added to the index

   <capability namespace='osgi.contract'>
      <attribute name='osgi.contract' value='OSGiFramework'/>
   </capability>

Please note that the 'Version' attribute is missing on purpose. The resolver does not care about the missing version and the resolution is successful (tested with the Apache Felix resolver used by bndtools). This means we could add this without the weird "package version" to "framework version" mapping.

After all I think we should try to integrate the "org.osgi.impl.bundle.repoindex.lib" library with Package Drone - this should solve all the hassle with generating a valid R5 index.

JFingerle commented 9 years ago

The capability could be declared by the framework bundles using the following section in the manifest file:

Provide-Capability: osgi.contract;
      osgi.contract=OSGiFramework;
      version="5.0.0"

This has been added with OSGi Core 4.3 (according to OSGi Enterprise R5 Release, slide "Common Namespaces"). Sadly even the latest Apache Felix framework bundle (5.0.1) is not using this in it's manifest. This means that the OBR index generator has to detect framework bundles and add the 'osgi.contract' section for now.

ctron commented 9 years ago

Actually P2 has a similar problem, which is also solved with a custom logic, which can be configured on a per-channel basis.

So doing the same for OBR and R5 would be fine.

ctron commented 9 years ago

Again to "bindex". I would like to use a more generic approach. But this would require:

I know that a few features are missing right now. Mostly stuff which is not supported by P2 anyway. And it has to be fixed. Because it should be supported!

But as of now "bindex" is not a drop-in replacement.

JFingerle commented 9 years ago

I fixed this on master (72016bb) and 0.10.x.-release (ecb36a7). The code from method "mapFrameworkPackageVersion" is taken from bnd/repoindex.