2001-06-02 03:27:33 +08:00
|
|
|
#!/bin/bash
|
1996-11-22 05:58:50 +08:00
|
|
|
|
2001-06-02 03:27:33 +08:00
|
|
|
#
|
|
|
|
# Auto-generate requirements for executables (both ELF and a.out) and library
|
|
|
|
# sonames, script interpreters, and perl modules.
|
|
|
|
#
|
1996-11-22 05:58:50 +08:00
|
|
|
|
1996-11-22 06:06:06 +08:00
|
|
|
ulimit -c 0
|
|
|
|
|
2002-04-10 05:36:47 +08:00
|
|
|
#
|
|
|
|
# --- Set needed to 0 for traditional find-requires behavior.
|
|
|
|
if [ X"$1" = Xldd ]; then
|
|
|
|
needed=0
|
|
|
|
else
|
|
|
|
needed=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# --- Grab the file manifest and classify files.
|
1997-09-01 23:55:56 +08:00
|
|
|
filelist=`sed "s/['\"]/\\\&/g"`
|
2001-06-02 03:27:33 +08:00
|
|
|
exelist=`echo $filelist | xargs -r file | egrep -v ":.* (commands|script) " | \
|
|
|
|
grep ":.*executable" | cut -d: -f1`
|
|
|
|
scriptlist=`echo $filelist | xargs -r file | \
|
|
|
|
egrep ":.* (commands|script) " | cut -d: -f1`
|
|
|
|
liblist=`echo $filelist | xargs -r file | \
|
|
|
|
grep ":.*shared object" | cut -d : -f1`
|
1996-11-22 05:58:50 +08:00
|
|
|
|
2001-06-02 03:27:33 +08:00
|
|
|
interplist=
|
|
|
|
perllist=
|
|
|
|
pythonlist=
|
|
|
|
tcllist=
|
|
|
|
|
2001-06-16 00:01:10 +08:00
|
|
|
#
|
|
|
|
# --- Alpha does not mark 64bit dependencies
|
|
|
|
case `uname -m` in
|
|
|
|
alpha*) mark64="" ;;
|
|
|
|
*) mark64="()(64bit)" ;;
|
|
|
|
esac
|
|
|
|
|
2002-04-10 05:36:47 +08:00
|
|
|
if [ "$needed" -eq 0 ]; then
|
2001-06-02 03:27:33 +08:00
|
|
|
#
|
2002-04-10 05:36:47 +08:00
|
|
|
# --- Executable dependency sonames.
|
|
|
|
for f in $exelist; do
|
2001-06-02 03:27:33 +08:00
|
|
|
[ -r $f -a -x $f ] || continue
|
|
|
|
lib64=`if file -L $f 2>/dev/null | \
|
2001-06-16 00:01:10 +08:00
|
|
|
grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
|
2001-06-02 03:27:33 +08:00
|
|
|
ldd $f | awk '/=>/ {
|
2002-04-09 02:56:01 +08:00
|
|
|
if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) {
|
2001-06-02 03:27:33 +08:00
|
|
|
gsub(/'\''"/,"\\&",$1);
|
|
|
|
printf "%s'$lib64'\n", $1
|
|
|
|
}
|
|
|
|
}'
|
2002-04-10 05:36:47 +08:00
|
|
|
done | xargs -r -n 1 basename | sort -u
|
1996-11-22 06:16:00 +08:00
|
|
|
|
2001-06-02 03:27:33 +08:00
|
|
|
#
|
2002-04-10 05:36:47 +08:00
|
|
|
# --- Library dependency sonames.
|
|
|
|
for f in $liblist; do
|
2001-06-02 03:27:33 +08:00
|
|
|
[ -r $f ] || continue
|
|
|
|
lib64=`if file -L $f 2>/dev/null | \
|
2001-06-16 00:01:10 +08:00
|
|
|
grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
|
2001-06-02 03:27:33 +08:00
|
|
|
ldd $f | awk '/=>/ {
|
2002-04-09 02:56:01 +08:00
|
|
|
if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) {
|
2001-06-02 03:27:33 +08:00
|
|
|
gsub(/'\''"/,"\\&",$1);
|
|
|
|
printf "%s'$lib64'\n", $1
|
|
|
|
}
|
|
|
|
}'
|
2002-04-10 05:36:47 +08:00
|
|
|
done | xargs -r -n 1 basename | sort -u
|
|
|
|
fi
|
1998-04-02 00:02:05 +08:00
|
|
|
|
2001-06-02 03:27:33 +08:00
|
|
|
#
|
|
|
|
# --- Script interpreters.
|
1997-09-01 23:55:56 +08:00
|
|
|
for f in $scriptlist; do
|
2001-06-02 03:27:33 +08:00
|
|
|
[ -r $f -a -x $f ] || continue
|
|
|
|
interp=`head -1 $f | sed -e 's/^\#\![ ]*//' | cut -d" " -f1`
|
|
|
|
interplist="$interplist $interp"
|
|
|
|
case $interp in
|
|
|
|
*/perl) perllist="$perllist $f" ;;
|
|
|
|
esac
|
|
|
|
done
|
2001-08-06 19:27:27 +08:00
|
|
|
[ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; }
|
1999-02-16 02:26:09 +08:00
|
|
|
|
2002-01-23 08:58:47 +08:00
|
|
|
#
|
2002-04-10 05:36:47 +08:00
|
|
|
# --- Add perl module files to perllist.
|
2002-01-23 08:58:47 +08:00
|
|
|
for f in $filelist; do
|
|
|
|
[ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f"
|
|
|
|
done
|
2001-06-16 09:49:10 +08:00
|
|
|
|
2001-06-02 03:27:33 +08:00
|
|
|
#
|
|
|
|
# --- Weak symbol versions (from glibc).
|
2001-06-16 09:49:10 +08:00
|
|
|
[ -n "$mark64" ] && mark64="(64bit)"
|
1999-02-16 02:26:09 +08:00
|
|
|
for f in $liblist $exelist ; do
|
2001-06-02 03:27:33 +08:00
|
|
|
[ -r $f ] || continue
|
|
|
|
lib64=`if file -L $f 2>/dev/null | \
|
2001-06-16 00:01:10 +08:00
|
|
|
grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
|
2002-04-10 05:36:47 +08:00
|
|
|
objdump -p $f | awk 'BEGIN { START=0; LIBNAME=""; needed='$needed'; }
|
|
|
|
/^$/ { START=0; }
|
|
|
|
/^Dynamic Section:$/ { START=1; }
|
|
|
|
(START==1) && /NEEDED/ {
|
|
|
|
if (needed) { print $2 ; }
|
|
|
|
}
|
|
|
|
/^Version References:$/ { START=2; }
|
|
|
|
(START==2) && /required from/ {
|
1999-02-16 02:26:09 +08:00
|
|
|
sub(/:/, "", $3);
|
|
|
|
LIBNAME=$3;
|
|
|
|
}
|
2002-04-10 05:36:47 +08:00
|
|
|
(START==2) && (LIBNAME!="") && ($4!="") && (($4~/^GLIBC_*/) || ($4~/^GCC_*/)) {
|
2001-06-02 03:27:33 +08:00
|
|
|
print LIBNAME "(" $4 ")'$lib64'";
|
|
|
|
}
|
1999-02-16 02:26:09 +08:00
|
|
|
'
|
1999-06-18 04:18:08 +08:00
|
|
|
done | sort -u
|
2001-06-02 03:27:33 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# --- Perl modules.
|
|
|
|
[ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \
|
2001-08-06 19:27:27 +08:00
|
|
|
echo $perllist | tr '[:blank:]' \\n | /usr/lib/rpm/perl.req | sort -u
|
2001-06-02 03:27:33 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# --- Python modules.
|
|
|
|
[ -x /usr/lib/rpm/python.req -a -n "$pythonlist" ] && \
|
2001-08-06 19:27:27 +08:00
|
|
|
echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/python.req | sort -u
|
2001-06-02 03:27:33 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# --- Tcl modules.
|
|
|
|
[ -x /usr/lib/rpm/tcl.req -a -n "$tcllist" ] && \
|
2001-08-06 19:27:27 +08:00
|
|
|
echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/tcl.req | sort -u
|
2001-06-16 05:52:47 +08:00
|
|
|
|
|
|
|
exit 0
|