- fix typos in linux.{req,prov}.
[platform/upstream/rpm.git] / autodeps / linux.req
1 #!/bin/bash
2
3 #
4 # Auto-generate requirements for executables (both ELF and a.out) and library
5 # sonames, script interpreters, and perl modules.
6 #
7
8 ulimit -c 0
9
10 filelist=`sed "s/['\"]/\\\&/g"`
11 exelist=`echo $filelist | xargs -r file | egrep -v ":.* (commands|script) " | \
12         grep ":.*executable" | cut -d: -f1`
13 scriptlist=`echo $filelist | xargs -r file | \
14         egrep ":.* (commands|script) " | cut -d: -f1`
15 liblist=`echo $filelist | xargs -r file | \
16         grep ":.*shared object" | cut -d : -f1`
17
18 interplist=
19 perllist=
20 pythonlist=
21 tcllist=
22
23 #
24 # --- Executable sonames.
25 for f in $exelist; do
26     [ -r $f -a -x $f ] || continue
27     lib64=`if file -L $f 2>/dev/null | \
28         grep "ELF 64-bit" >/dev/null; then echo "()(64bit)"; fi`
29     ldd $f | awk '/=>/ {
30         if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/) {
31             gsub(/'\''"/,"\\&",$1);
32             printf "%s'$lib64'\n", $1
33         }
34     }'
35 done | xargs -r -n 1 basename | sort -u
36
37 #
38 # --- Library sonames.
39 for f in $liblist; do
40     [ -r $f ] || continue
41     lib64=`if file -L $f 2>/dev/null | \
42         grep "ELF 64-bit" >/dev/null; then echo "()(64bit)"; fi`
43     ldd $f | awk '/=>/ {
44         if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/) {
45             gsub(/'\''"/,"\\&",$1);
46             printf "%s'$lib64'\n", $1
47         }
48     }'
49 done | xargs -r -n 1 basename | sort -u
50
51 #
52 # --- Script interpreters.
53 for f in $scriptlist; do
54     [ -r $f -a -x $f ] || continue
55     interp=`head -1 $f | sed -e 's/^\#\![       ]*//' | cut -d" " -f1`
56     interplist="$interplist $interp"
57     case $interp in
58     */perl)     perllist="$perllist $f" ;;
59     *)          [ "${f%.pm}" != "${f}" ] && perllist="$perllist $f" ;;
60     esac
61 done
62 [ -n "$interplist" ] && { echo "$interplist" | sort -u ; }
63
64 #
65 # --- Weak symbol versions (from glibc).
66 for f in $liblist $exelist ; do
67     [ -r $f ] || continue
68     lib64=`if file -L $f 2>/dev/null | \
69         grep "ELF 64-bit" >/dev/null; then echo "()(64bit)"; fi`
70     objdump -p $f | awk '
71         BEGIN { START=0; LIBNAME=""; }
72         /Version References:/ { START=1; }
73         /required from/ && (START==1) {
74             sub(/:/, "", $3);
75             LIBNAME=$3;
76         }
77         (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) {
78             print LIBNAME "(" $4 ")'$lib64'";
79         }
80         /^$/ { START=0; }
81     '
82 done | sort -u
83
84 #
85 # --- Perl modules.
86 [ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \
87     echo $perllist | tr [:blank:] \\n | /usr/lib/rpm/perl.req | sort -u
88
89 #
90 # --- Python modules.
91 [ -x /usr/lib/rpm/python.req -a -n "$pythonlist" ] && \
92     echo $pythonlist | tr [:blank:] \\n | /usr/lib/rpm/python.req | sort -u
93
94 #
95 # --- Tcl modules.
96 [ -x /usr/lib/rpm/tcl.req -a -n "$tcllist" ] && \
97     echo $tcllist | tr [:blank:] \\n | /usr/lib/rpm/tcl.req | sort -u