Preparing for 4.11.1 final
[platform/upstream/rpm.git] / autodeps / freebsdelf.req
1 #!/bin/sh
2
3 # note this works for both a.out and ELF executables
4 # it also auto-generates requirement lines for shell scripts
5
6 ulimit -c 0
7
8 filelist=`sed "s/['\"]/\\\&/g"`
9 exelist=`if test "x$filelist" != x; then echo $filelist | xargs file | grep ":.*executable" | cut -d: -f1; fi`
10 scriptlist=`if test "x$filelist" != x; then echo $filelist | xargs file | grep -E ":.* (commands|script) " | cut -d: -f1; fi`
11 liblist=`if test "x$filelist" != x; then echo $filelist | xargs file | grep ":.*shared object" | cut -d : -f1; fi`
12
13 LDDLIST=`for f in $exelist; do
14     if [ -x $f ]; then
15         ldd $f | awk '/=>/ { print $1 }'
16     fi
17 done | sort -u | sed "s/['\"]/\\\&/g"`
18 if test "x$LDDLIST" != x; then
19     echo $LDDLIST | xargs -n 1 basename | grep -v 'libNoVersion.so' | sort -u
20 fi
21
22 LDDLIST=`for f in $liblist; do
23     ldd $f | awk '/=>/ { print $1 }'
24 done | sort -u | sed "s/['\"]/\\\&/g"`
25 if test "x$LDDLIST" != x; then
26     echo $LDDLIST | xargs -n 1 basename | grep -v 'libNoVersion.so' | sort -u
27 fi
28
29 for f in $scriptlist; do
30     if [ -x $f ]; then
31         head -1 $f | sed -e 's/^\#\![   ]*//' | cut -d" " -f1
32     fi
33 done | sort -u
34
35 for f in $liblist $exelist ; do
36     objdump -p $f | awk '
37         BEGIN { START=0; LIBNAME=""; }
38         /Version References:/ { START=1; }
39         /required from/ && (START==1) {
40             sub(/:/, "", $3);
41             LIBNAME=$3;
42         }
43         (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) { print LIBNAME "(" $4 ")"; }
44         /^$/ { START=0; }
45     '
46 done | sort -u