checklib 709 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env sh
  2. # from https://github.com/cryptocoinjs/secp256k1-node/blob/25a4b6cb567b49a40f47f50c5ca9a756f5343e4d/utils/has_lib.sh
  3. check () {
  4. regex="lib$1.+(so|dylib)"
  5. # Add /sbin to path as ldconfig is located there on some systems - e.g. Debian
  6. # (and it still can be used by unprivileged users):
  7. PATH="$PATH:/sbin"
  8. export PATH
  9. # Try just checking common library locations
  10. for dir in /lib /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu; do
  11. if test -d $dir; then
  12. # shellcheck disable=SC2010
  13. ls $dir | grep -E "$regex" && return 0
  14. fi
  15. done
  16. return 1
  17. }
  18. check "$1" > /dev/null
  19. if test "$?" -eq 0; then
  20. echo true
  21. else
  22. echo false
  23. fi