doxygen cleanup.
[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 # --- Alpha does not mark 64bit dependencies
25 case `uname -m` in
26   alpha*)       mark64="" ;;
27   *)            mark64="()(64bit)" ;;
28 esac
29
30 #
31 # --- Executable sonames.
32 for f in $exelist; do
33     [ -r $f -a -x $f ] || continue
34     lib64=`if file -L $f 2>/dev/null | \
35         grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
36     ldd $f | awk '/=>/ {
37         if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) {
38             gsub(/'\''"/,"\\&",$1);
39             printf "%s'$lib64'\n", $1
40         }
41     }'
42 done | xargs -r -n 1 basename | sort -u
43
44 #
45 # --- Library sonames.
46 for f in $liblist; do
47     [ -r $f ] || continue
48     lib64=`if file -L $f 2>/dev/null | \
49         grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
50     ldd $f | awk '/=>/ {
51         if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) {
52             gsub(/'\''"/,"\\&",$1);
53             printf "%s'$lib64'\n", $1
54         }
55     }'
56 done | xargs -r -n 1 basename | sort -u
57
58 #
59 # --- Script interpreters.
60 for f in $scriptlist; do
61     [ -r $f -a -x $f ] || continue
62     interp=`head -1 $f | sed -e 's/^\#\![       ]*//' | cut -d" " -f1`
63     interplist="$interplist $interp"
64     case $interp in
65     */perl)     perllist="$perllist $f" ;;
66     esac
67 done
68 [ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; }
69
70 #
71 # --- Find perl module files.
72 for f in $filelist; do
73     [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f"
74 done
75
76 #
77 # --- Weak symbol versions (from glibc).
78 [ -n "$mark64" ] && mark64="(64bit)"
79 for f in $liblist $exelist ; do
80     [ -r $f ] || continue
81     lib64=`if file -L $f 2>/dev/null | \
82         grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
83     objdump -p $f | awk '
84         BEGIN { START=0; LIBNAME=""; }
85         /Version References:/ { START=1; }
86         /required from/ && (START==1) {
87             sub(/:/, "", $3);
88             LIBNAME=$3;
89         }
90         (START==1) && (LIBNAME!="") && ($4!="") && (($4~/^GLIBC_*/) || ($4~/^GCC_*/)) {
91             print LIBNAME "(" $4 ")'$lib64'";
92         }
93         /^$/ { START=0; }
94     '
95 done | sort -u
96
97 #
98 # --- Perl modules.
99 [ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \
100     echo $perllist | tr '[:blank:]' \\n | /usr/lib/rpm/perl.req | sort -u
101
102 #
103 # --- Python modules.
104 [ -x /usr/lib/rpm/python.req -a -n "$pythonlist" ] && \
105     echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/python.req | sort -u
106
107 #
108 # --- Tcl modules.
109 [ -x /usr/lib/rpm/tcl.req -a -n "$tcllist" ] && \
110     echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/tcl.req | sort -u
111
112 exit 0