Browse Source

Convert has_lib.sh to sh so it also works on BSD OSes

Passes http://www.shellcheck.net/

Ref. #754
master
hakkiplaten 8 years ago
committed by GitHub
parent
commit
87e15df48e
  1. 13
      util/has_lib.sh

13
util/has_lib.sh

@ -1,18 +1,19 @@
#!/bin/bash #!/bin/sh
has_ldconfig() { has_ldconfig() {
hash ldconfig 2>/dev/null hash ldconfig 2>/dev/null
} }
has_system_lib() { has_system_lib() {
local regex="lib$1.+(so|dylib)" regex="lib$1.+(so|dylib)"
# Add /sbin to path as ldconfig is located there on some systems - e.g. Debian # Add /sbin to path as ldconfig is located there on some systems - e.g. Debian
# (and it still can be used by unprivileged users): # (and it still can be used by unprivileged users):
PATH="$PATH:/sbin" PATH="$PATH:/sbin"
export PATH export PATH
# Try using ldconfig on linux systems
if $(has_ldconfig); then # Try using ldconfig on Linux systems
if has_ldconfig; then
for _ in $(ldconfig -p 2>/dev/null | grep -E "$regex"); do for _ in $(ldconfig -p 2>/dev/null | grep -E "$regex"); do
return 0 return 0
done done
@ -20,7 +21,7 @@ has_system_lib() {
# Try just checking common library locations # Try just checking common library locations
for dir in /lib /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu; do for dir in /lib /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu; do
test -d $dir && ls $dir | grep -E "$regex" && return 0 test -d "$dir" && echo "$dir"/* | grep -E "$regex" && return 0
done done
return 1 return 1
@ -52,7 +53,7 @@ case "$1" in
result=$? result=$?
;; ;;
*) *)
>&2 echo "Unknown library: $1" echo "Unknown library: $1"
exit 1 exit 1
esac esac

Loading…
Cancel
Save