4 # Auto-generate requirements for executables (both ELF and a.out) and library
5 # sonames, script interpreters, and perl modules.
11 # --- Set needed to 0 for traditional find-requires behavior.
12 if [ X"$1" = Xldd ]; then
19 # --- Grab the file manifest and classify files.
20 filelist=`sed "s/['\"]/\\\&/g"`
21 exelist=`echo $filelist | xargs -r file | egrep -v ":.* (commands|script) " | \
22 grep ":.*executable" | cut -d: -f1`
23 scriptlist=`echo $filelist | xargs -r file | \
24 egrep ":.* (commands|script) " | cut -d: -f1`
25 liblist=`echo $filelist | xargs -r file | \
26 grep ":.*shared object" | cut -d : -f1`
34 # --- Alpha does not mark 64bit dependencies
37 *) mark64="()(64bit)" ;;
40 if [ "$needed" -eq 0 ]; then
42 # --- Executable dependency sonames.
44 [ -r $f -a -x $f ] || continue
45 lib64=`if file -L $f 2>/dev/null | \
46 grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
48 if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) {
49 gsub(/'\''"/,"\\&",$1);
50 printf "%s'$lib64'\n", $1
53 done | xargs -r -n 1 basename | sort -u
56 # --- Library dependency sonames.
59 lib64=`if file -L $f 2>/dev/null | \
60 grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
62 if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) {
63 gsub(/'\''"/,"\\&",$1);
64 printf "%s'$lib64'\n", $1
67 done | xargs -r -n 1 basename | sort -u
71 # --- Script interpreters.
72 for f in $scriptlist; do
73 [ -r $f -a -x $f ] || continue
74 interp=`head -1 $f | sed -e 's/^\#\![ ]*//' | cut -d" " -f1`
75 interplist="$interplist $interp"
77 */perl) perllist="$perllist $f" ;;
80 [ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; }
83 # --- Add perl module files to perllist.
84 for f in $filelist; do
85 [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f"
89 # --- Weak symbol versions (from glibc).
90 [ -n "$mark64" ] && mark64="(64bit)"
91 for f in $liblist $exelist ; do
93 lib64=`if file -L $f 2>/dev/null | \
94 grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
95 objdump -p $f | awk 'BEGIN { START=0; LIBNAME=""; needed='$needed'; }
97 /^Dynamic Section:$/ { START=1; }
98 (START==1) && /NEEDED/ {
99 if (needed) { print $2 ; }
101 /^Version References:$/ { START=2; }
102 (START==2) && /required from/ {
106 (START==2) && (LIBNAME!="") && ($4!="") && (($4~/^GLIBC_*/) || ($4~/^GCC_*/)) {
107 print LIBNAME "(" $4 ")'$lib64'";
114 [ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \
115 echo $perllist | tr '[:blank:]' \\n | /usr/lib/rpm/perl.req | sort -u
118 # --- Python modules.
119 [ -x /usr/lib/rpm/python.req -a -n "$pythonlist" ] && \
120 echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/python.req | sort -u
124 [ -x /usr/lib/rpm/tcl.req -a -n "$tcllist" ] && \
125 echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/tcl.req | sort -u