5
# given a path, this scripts searches for ELF binaries and libraries
6
# and generates package dependency file entries according to ther dependencies
8
# Usage: elfdepend <ELF-binary>|<directory>
10
# 2002/11 Stefan.Radman@CTBTO.ORG
12
# /var/sadm/install/contents format:
14
# /dev d none 0775 root sys SUNWcsr SUNWcsd
15
# path type class mode owner group packages
16
# /etc/.login f renamenew 0644 root sys 516 37956 904647695 SUNWcsr
17
# /etc/acct/holidays e preserve 0664 bin bin 289 22090 904647603 SUNWaccr
18
# path type class mode owner group x x x packages
19
# /bin=./usr/bin s none SUNWcsr
20
# path=link type class packages
21
# /devices/pseudo/clone@0:hme c none 11 7 0600 root sys SUNWcsd
22
# path type class x x owner mode packages
24
# types e (sed), v (volatile) have same format like type f (file)
25
# type l (hardlink) has same format like type s (symlink)
28
LAST_CHANCE=/opt/OSS/lib
31
find $1 -type f -exec file {} \;
32
elif [ -x "$1" ] ; then
35
echo 1>&2 "usage: $0 <directory>|<ELF executable>"
37
fi | awk '$2 == "ELF" { print }' | cut -d: -f1 |\
40
ldd "$elf" | while read lib x path
42
[ -z "$path" ] && continue
43
if [ "$path" = '(file not found)' ]
45
if [ -x $LAST_CHANCE/$lib ]
47
path="$LAST_CHANCE/$lib"
49
echo "# $prog: $lib $x $path"
54
# need symlink handling here - see /usr/platform/SUNW,*/lib/*
56
done | sort -u | while read libpath other
58
[ "$libpath" = "#" ] && echo "$libpath $other" && continue # error message
59
set -- `grep "^$libpath[ =]" /var/sadm/install/contents | head -1`
63
shift 9 # first package
66
shift 3 # first package
69
echo "# $prog: $libpath is not associated with any package"
72
*) # dubious file type
73
echo "# $prog: path $1 has dubious file type $2"
77
set -- `echo $1 | tr : ' '`
78
echo $1 # strip off classes
79
done | sort -u | while read pkg other
81
if [ "$pkg" = "#" ] ; then # error message
82
echo 1>&2 "$other" # goes to stderr
85
eval `pkgparam -v $pkg PKG NAME`
86
printf "P %-15s%s\n" "$PKG" "$NAME"