appimage-apprun.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. # Don't load swrast_dir for now, it is breaking new systems and this mechanism doesn't
  34. # work for detecting whether or not it is necessary.
  35. # if [ -e "./optional/swrast_dri/swrast_dri.so" ]; then
  36. # lib="$(PATH="/sbin:$PATH" ldconfig -p | grep "swrast_dri\.so ($libc6arch)" | awk 'NR==1{print $NF}')"
  37. # if [ "$lib" == "" ]; then
  38. # swrastpath=""
  39. # else
  40. # sym_sys=$(tr '\0' '\n' < "$lib" | grep -e '^GCC_[0-9]\\.[0-9]' | tail -n1)
  41. # sym_app=$(tr '\0' '\n' < "./optional/swrast_dri/swrast_dri.so" | grep -e '^GCC_[0-9]\\.[0-9]' | tail -n1)
  42. # if [ "$(printf "${sym_sys}\n${sym_app}"| sort -V | tail -1)" != "$sym_sys" ]; then
  43. # swrastpath="./optional/swrast_dri:"
  44. # fi
  45. # fi
  46. # fi
  47. if [ -n "$cxxpath" ] || [ -n "$gccpath" ] || [ -n "$swrastpath" ]; then
  48. if [ -e "./optional/exec.so" ]; then
  49. execpre=""
  50. export LD_PRELOAD="./optional/exec.so:${LD_PRELOAD}"
  51. fi
  52. export LD_LIBRARY_PATH="${cxxpath}${gccpath}${swrastpath}${LD_LIBRARY_PATH}"
  53. fi
  54. # disable parameter expansion to forward all arguments unprocessed to the VM
  55. set -f
  56. # run the VM and pass along all arguments as is
  57. 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 "$@"
  58. exit $?