Skip to content

Proposal to modify handling of blacklisted shared libraries #224

Closed

Description

@aferrero2707

Today I got a report from a gentoo user that my GIMP appimage fails to load properly due to missing libp11-kit.so.0.

This library is part of the blacklisted ones, and is supposed to be provided by the base system. However, it seems that the corresponding package is not strictly necessary on a base gentoo system.

So I was wondering if it would be possible to foresee a different way of handling blacklisted libraries. Instead of completely deleting the blacklisted library files, they could be moved to a special library folder in the appimage , and then libraries searched in this order:

  • first in the standard library folders in the appimage
  • then in the library folders in the base system
  • finally in the special blacklisted folder

This way, blacklisted libraries would be taken from the appimage only if not available in the base system.

Would this make sense?

Activity

  1. probonopd commented on Aug 30, 2016

    @probonopd
    Member

    Sure it could bue done. But using this line of reasoning, where would it end? Would you include every dependency down to glibc in each AppImage?

    I'd rather say (most) AppImages should target the default installation of mainstream desktop distributions, which all seem to come with libp11-kit.so.0 out of the box.

  2. aferrero2707 commented on Aug 31, 2016

    @aferrero2707
    Author

    I did a test of moving the blacklisted libraries instead of deleting them, by using the following function in the Recipe:

    move_blacklisted()
    {
      mkdir -p ./usr/lib-blacklisted
      BLACKLISTED_FILES=$(wget -q     https://github.com/probonopd/AppImages/raw/master/excludelist -O - | sed '/^\s*$/d' | sed '/^#.*$/d')
      echo $BLACKLISTED_FILES
      for FILE in $BLACKLISTED_FILES ; do
        FOUND=$(find . -type f -name "${FILE}" 2>/dev/null)
        if [ ! -z "$FOUND" ] ; then
          echo "Deleting blacklisted ${FOUND}"
          #rm -f "${FOUND}"
          mv "${FOUND}" ./usr/lib-blacklisted
        fi
      done
    }
    

    This adds an extra 3.5MB to the appimage.

    Then I have introduced a wrapper script in the appimage that sets the LD_LIBRARY_PATH in this way before calling the real executable:

    HERE="$(dirname "$(readlink -f "${0}")")"
    DEFAULT_LIB_PATHS=$(ld --verbose | grep SEARCH_DIR | sed -e 's/\"=//g' | tr -d '\"' | tr -d ')' |   sed -e 's/SEARCH_DIR(//g' | tr -s ' ;' ':')
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DEFAULT_LIB_PATHS:$HERE/../lib-blacklisted
    

    This way, libraries are first searched in the standard appimage folders, then in the system folders, and finally in the appimage folder containing the blacklisted libraries. So blacklisted libraries in the appimage are used only if the corresponding system libraries are not present.

    From my initial tests this seems to work as expected, but it needs more testing on various systems.

    Do you see any possible bad side effect in doing this?

  3. probonopd commented on Aug 31, 2016

    @probonopd
    Member

    Didn't test the above yet, but might lead to crashes if glibc, ld-linux.so and related low level libraries are not handled properly. See https://github.com/probonopd/AppImages/blob/master/recipes/sigil/Recipe for an example that bundles everything down to glibc. The result, if done properly, should be that the app runs even on ancient distributions (older than the build system).

  4. aferrero2707 commented on Aug 31, 2016

    @aferrero2707
    Author

    I definitely see your point, however the sigil recipe is try to address a different problem, which is to completely ignore the system libraries and only use those provided in the appimage, right?

    My goal is slightly different: still use the system libraries if present, and revert to appimage libraries if system libraries are absent.

    In the specific case discussed here, some gentoo system is built without libp11-kit.so.0, while other low-level libraries are present. Then, since the base system does not depend on libp11-kit.so.0, using the version provided by the appimage should be safe and not leading to crashes, as far as I understand.

    It is basically a question wether to try supplying missing libraries from the appimage itself, or ask the users to install some additional base packages. Which solution will be more simple and less error-prone, I still do not know...

  5. probonopd commented on Aug 31, 2016

    @probonopd
    Member

    Bundle everything (like in the Sigil example) is the safest, bundle everything except the blacklisted ones is less safe and more of trial-and-error, and you suggested model of match-and-mix is probably the most crash-prone if not tested in all possible combinations properly. Although I have not experimented with it so far.

  6. aferrero2707 commented on Aug 31, 2016

    @aferrero2707
    Author

    I was intuitively expecting the opposite: bundling everything being the most crash-prone solution, but then I have to admit I'm quite out of my "comfort zone" on this topic.

    In the GIMP appimage case, bundling everything would be definitely feasible, since the size overhead is negligible and I already have a wrapper script where I can set the paths properly, following the Sigil example.

    But now I'm wondering: why do you blacklist and remove libraries for most of the packages?

    Thanks for all your explanations!

  7. probonopd commented on Aug 31, 2016

    @probonopd
    Member

    Why do you blacklist and remove libraries for most of the packages?

    So that we don't ship libraries that can reasonably expected to already be on the target systems, like glibc or GTK+. Some people might call that bloat, using additional download bandwidth, storage, and RAM. But if the additional overhead is relatively small compared to the overall app, it might not be as bad as it sounds. Still, I'd say that Gentoo user can get the one missing lib from the distro.

  8. probonopd commented on Nov 5, 2016

    @probonopd
    Member

    Is this still of concern? Is there any action/change still needed?

  9. aferrero2707 commented on Nov 10, 2016

    @aferrero2707
    Author

    I think we can close this for the moment, as I have not enough test cases to verify if my proposal is more or less error-prone than the standard solution... to which I will stick for the time being.

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions