portable_launcher.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. ldd -r "$here/linux-wallpaperengine.bin" "$here/linux-wallpaperengine-web-helper"
  32. exit
  33. fi
  34. exec "$here/linux-wallpaperengine.bin" "$@"