appimage-apprun.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. # Cribbed from https://github.com/darealshinji/AppImageKit-checkrt/blob/master/AppRun.sh
  3. # some magic to find out the real location of this script dealing with symlinks
  4. DIR=`readlink "$0"` || DIR="$0";
  5. DIR=`dirname "$DIR"`;
  6. cd "$DIR"
  7. DIR=`pwd`
  8. cd - > /dev/null
  9. cxxpre=""
  10. gccpre=""
  11. execpre=""
  12. libc6arch="libc6,x86-64"
  13. if [ -n "$APPIMAGE" ] && [ "$(file -b "$APPIMAGE" | cut -d, -f2)" != " x86-64" ]; then
  14. libc6arch="libc6"
  15. fi
  16. cd "${DIR}/usr"
  17. if [ -e "./optional/libstdc++/libstdc++.so.6" ]; then
  18. lib="$(PATH="/sbin:$PATH" ldconfig -p | grep "libstdc++\.so\.6 ($libc6arch)" | awk 'NR==1{print $NF}')"
  19. sym_sys=$(tr '\0' '\n' < "$lib" | grep -e '^GLIBCXX_3\.4' | tail -n1)
  20. sym_app=$(tr '\0' '\n' < "./optional/libstdc++/libstdc++.so.6" | grep -e '^GLIBCXX_3\.4' | tail -n1)
  21. if [ "$(printf "${sym_sys}\n${sym_app}"| sort -V | tail -1)" != "$sym_sys" ]; then
  22. cxxpath="./optional/libstdc++:"
  23. fi
  24. fi
  25. if [ -e "./optional/libgcc/libgcc_s.so.1" ]; then
  26. lib="$(PATH="/sbin:$PATH" ldconfig -p | grep "libgcc_s\.so\.1 ($libc6arch)" | awk 'NR==1{print $NF}')"
  27. sym_sys=$(tr '\0' '\n' < "$lib" | grep -e '^GCC_[0-9]\\.[0-9]' | tail -n1)
  28. sym_app=$(tr '\0' '\n' < "./optional/libgcc/libgcc_s.so.1" | grep -e '^GCC_[0-9]\\.[0-9]' | tail -n1)
  29. if [ "$(printf "${sym_sys}\n${sym_app}"| sort -V | tail -1)" != "$sym_sys" ]; then
  30. gccpath="./optional/libgcc:"
  31. fi
  32. fi
  33. if [ -e "./optional/swrast_dri/swrast_dri.so" ]; then
  34. lib="$(PATH="/sbin:$PATH" ldconfig -p | grep "swrast_dri\.so\ ($libc6arch)" | awk 'NR==1{print $NF}')"
  35. sym_sys=$(tr '\0' '\n' < "$lib" | grep -e '^GCC_[0-9]\\.[0-9]' | tail -n1)
  36. sym_app=$(tr '\0' '\n' < "./optional/swrast_dri/swrast_dri.so" | grep -e '^GCC_[0-9]\\.[0-9]' | tail -n1)
  37. if [ "$(printf "${sym_sys}\n${sym_app}"| sort -V | tail -1)" != "$sym_sys" ]; then
  38. swrastpath="./optional/swrast_dri:"
  39. fi
  40. fi
  41. if [ -n "$cxxpath" ] || [ -n "$gccpath" ] || [ -n "$swrastpath" ]; then
  42. if [ -e "./optional/exec.so" ]; then
  43. execpre=""
  44. export LD_PRELOAD="./optional/exec.so:${LD_PRELOAD}"
  45. fi
  46. export LD_LIBRARY_PATH="${cxxpath}${gccpath}${swrastpath}${LD_LIBRARY_PATH}"
  47. fi
  48. # disable parameter expansion to forward all arguments unprocessed to the VM
  49. set -f
  50. # run the VM and pass along all arguments as is
  51. LD_LIBRARY_PATH="$DIR/usr/lib:${LD_LIBRARY_PATH}" "${DIR}/usr/bin/perl-local" -I"${DIR}/usr/lib/local-lib/lib/perl5" "${DIR}/usr/bin/slic3r.pl" --gui "$@"
  52. exit $?