Created
January 25, 2016 22:23
-
-
Save Ram-Z/84fddff970d0d3eba51a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
version="0.1" | |
function usage () | |
{ | |
echo "Usage : $0 [options] [PATH] | |
Checks installed libraries for missing dynamic links. | |
Options: | |
-d,--depth Max depth to search | |
-h,--help Display this message | |
-v,--version Display script version" | |
} | |
checkso() { | |
for f in ${@}; do | |
if sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ldd $f | grep -q "not found"; then | |
echo "$(LC_ALL=C pacman -Qoq $f) $f seems broken!" | |
fi | |
done | |
} | |
# Parse arguments | |
declare -a args | |
while [[ $# > 0 ]]; do | |
opt="$1" | |
case $opt in | |
-d|--depth) depth=$2; shift 2 ;; | |
-h|--help) usage; exit 0 ;; | |
-v|--version) echo "$0 -- Version $version"; exit 0 ;; | |
-* ) | |
echo -e "\n Option does not exist : $opt\n" | |
usage; exit 1 ;; | |
*) args+=($opt); shift ;; | |
esac | |
done | |
path="${args[0]}" | |
declare -a findopts | |
[[ $depth ]] && findopts+=(-maxdepth "$depth") | |
sudo -v | |
echo "${findopts[@]}" | |
echo "Searching broken binaries...." | |
binpath=${path:-/usr/bin} | |
bins=( $(find "$binpath" "${findopts[@]}" -type f -executable) ) | |
checkso ${bins[@]} | |
echo " " | |
echo "Searching broken libs...." | |
libpath=${path:-/usr/lib} | |
libs=( $(find $libpath "${findopts[@]}" -name '*.so' -type f -executable) ) | |
checkso ${libs[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment