In our OSGi code, we are using Bundle-NativeCode manifest headers to choose what native libraries to load for Windows or Linux.
The problem arises when one of the libraries we need to use depends on a specific version of an already installed library (GLIBC is currently at version 2.12 in Ubuntu and 2.11 in Debian). Is there a way to identify the installed Linux flavor, or at least the version of a specific library with the Bundle-NativeCode properties? Do you know any other way around this? (please note that osname and osversion only give us “Linux” and the linux kernel version respectively, which is not enough)
Thanks!
No, the OSGi native code filtering does not provide that level of dependency for externally sourced packages. Other than trying to include the specific version of your dependency in the bundle as well (which of course wouldn’t work with glibc) you can’t achieve this through the Native-Code alone.
One alternative is to not use the Native-Code and instead use your bundle to load the fragment code on demand, by using a different name. So you have Linux\Glibc\211 and Linux\Glibc\212, and then based on the runtime of your bundle’s startup, can manually call the
System.loadLibrary()yourself.