AppImageCommunity / pkg2appimage

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

Test whether system has all needed libraries #396

Open probonopd opened 4 years ago

probonopd commented 4 years ago

From time to time people ask for a check whether system has all needed libraries that we assume to come with the system.

This should do:

#!/bin/bash

wget -q -c "https://raw.githubusercontent.com/AppImage/pkg2appimage/master/excludelist"

cat > check.c <<\EOF
#include<stdio.h>

int main() {
    printf("All libraries present, check passed\n");
    return 0;
}
EOF

gcc check.c -o check

LIBS=$(cat excludelist | grep -v "^#" | cut -d "#" -f 1 | sort | uniq |tr '\n' ' ')
stringarray=($LIBS)
for LIB in "${stringarray[@]}" ; do
  if [ "$LIB" == "ld-linux.so.2" ] ; then continue ; fi
  echo patchelf --add-needed "$LIB" check
  patchelf --add-needed "$LIB" check
done

rm excludelist

./check

It could possibly be rewritten not to need patchelf, but this works for me.

Reference: https://github.com/KarlZeilhofer/kicad-appimage/issues/4#issuecomment-549031418

probonopd commented 4 years ago

If this does not pass on a mainstream Linux distribution, then likely the excludelist is wrong and a bug should be filed.