#!/bin/sh - # # checklibs -- Check for missing libraries # # Written for FreeBSD (tested on 4.x - 8.x), probably won't work elsewhere. # Usage: checklibs # # Copyright (C) 2006-2010 Oliver Fromme # All rights reserved. Standard 2-clause BSD license and disclaimer apply, # please refer to the file /usr/share/examples/etc/bsd-style-copyright on # FreeBSD or ask the author for a copy. # if [ $# -gt 0 ]; then echo "Usage: ${0##*/}" >&2 echo "Check for missing libraries." >&2 exit 1 fi existdirs() { tr " " '\n' | while read DIR; do if [ -d "$DIR" ]; then echo "$DIR" fi done } checkdirs() { echo "$@" | existdirs | xargs -J% find % -depth 1 -type f | xargs ldd 2>/dev/null | awk ' { if (NF == 1) { currfile = $1 sub(/:$/, "", currfile) } else if (/not found/) print currfile, "-->", $1 } ' } LIBDIRS=$(/sbin/ldconfig -r | sed -n 's/:/ /g;/earch director/s+^[^/]*/+/+p') BINDIRS=$(echo "$PATH" | tr : " ") EXTRA=$( for i in lib libexec; do echo /$i /usr/$i /usr/X11R6/$i /usr/local/$i done | existdirs | xargs -J% find % -type d ) for i in bin sbin; do EXTRA="$EXTRA /$i /usr/$i /usr/X11R6/$i /usr/local/$i" done EXTRA="$EXTRA /usr/games" DIRS=$(echo $LIBDIRS $BINDIRS $EXTRA | tr " " '\n' | sort -u) # For debugging only: Print list of directories that are being # checked for dynamically linked binaries and shared libraries: #echo "$DIRS" checkdirs $DIRS #--