portable_launcher.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. # linux-wallpaperengine of the portable release (tools/package_release.sh --portable). Starts the engine with the
  3. # bundled lib/fallback/<soname> copies on the library path, only for sonames the system doesn't have.
  4. #
  5. # --check-libraries prints `ldd -r` of the engine and the web helper with that path and exits.
  6. here=$(dirname "$(readlink -f "$0")")
  7. system_has() {
  8. for ldconfig in /sbin/ldconfig /usr/sbin/ldconfig /usr/bin/ldconfig; do
  9. if [ -x "$ldconfig" ]; then
  10. "$ldconfig" -p 2>/dev/null | grep -q "^[[:space:]]*$1 (.*x86-64" && return 0
  11. break
  12. fi
  13. done
  14. for libdir in /lib64 /usr/lib64 /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib /lib; do
  15. [ -e "$libdir/$1" ] && return 0
  16. done
  17. return 1
  18. }
  19. fallback=
  20. for dir in "$here"/lib/fallback/*/; do
  21. [ -d "$dir" ] || continue
  22. soname=$(basename "$dir")
  23. system_has "$soname" || fallback="$fallback:${dir%/}"
  24. done
  25. if [ -n "$fallback" ]; then
  26. LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH}$fallback"
  27. LD_LIBRARY_PATH="${LD_LIBRARY_PATH#:}"
  28. export LD_LIBRARY_PATH
  29. fi
  30. if [ "$1" = --check-libraries ]; then
  31. helpers=
  32. for helper in "$here/linux-wallpaperengine-web-helper" "$here/linux-wallpaperengine-kwin-janitor"; do
  33. [ -e "$helper" ] && helpers="$helpers $helper"
  34. done
  35. # shellcheck disable=SC2086
  36. ldd -r "$here/linux-wallpaperengine.bin" $helpers
  37. exit
  38. fi
  39. exec "$here/linux-wallpaperengine.bin" "$@"