AppImageCommunity / pkg2appimage

Tool and recipes to convert existing deb packages to AppImage
http://appimage.org
MIT License
694 stars 214 forks source link

Proposal for a better run-time handling of shared library versions #343

Open aferrero2707 opened 6 years ago

aferrero2707 commented 6 years ago

People testing my Rawtherapee and GIMP appimages on various Linux distributions have sometimes reported conflicts between bundled and system libraries, typically showing up as missing symbols. I am currently using CentOS7 for building my packages.

Generally speaking, there is often a need to decide at run-time wether to use the system or the bundled version of some specific library, whichever is newer. One known example is libstdc++, but there are other cases as well.

Another example is the fontconfig library. Currently I am bundling the library, as well as its dependency libfreetype, into the appimages. However, I want to use the system-provided /etc/fonts/fonts.conf file, so that I do not need to bundle fonts into the AppImage itself. Now the problem is that if the system fontconfig version is too new, the bundled library might give errors when parsing /etc/fonts/fonts.conf. In this case, the bundled libfontconfig should be skipped and the system one used instead. However, this might bring other issues with dependent libraries, like libfreetype: the system fontconfig library requires symbols that are not provided by the bundled libfreetype (because it is too old), and the system libfreetype should be used as well...

To solve this, I am developing some bash code that, for a given library, compares the versions of the system and bundled copies, and "disables" the bundled one when the system one is newer. The library version is extracted from the suffix of the dereferenced *.so* file name. For this to work, I had to introduce some changes into the way the libraries are bundled. In particular, I had to:

An example of how this mechanism is used can be fount in the {Rawtheapee AppRun script](https://github.com/aferrero2707/rt-appimage/blob/master/ci/AppRun#L5). With this, I was able to provide compatibility with "rolling" distributions like Sabayon and Majaro (in addition to "classical" ones like Debian stable/testing, Ubuntu and Fedora). However, I would like to have the opinion of the experts (pinging @probonopd and @TheAssassin in particular) regarding this. Of course, if you find this useful, feel free to integrate it in the default AppImage scripts...

Thanks!

probonopd commented 6 years ago

I guess we'd need collect empirical evidence, a.k.a. trial and error, as we have never experimented with this scheme.

While I am not opposed to "crude hacks", maybe there is a cleaner way to implement a similar scheme that does not need symlinks and such: Could we take the code of ld-linux.so and hack it into a custom AppRun that would compare the system version and the bundled version of each library and always load the newer one?