]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find-requires
- sync X/non-X: added Applications/Science
[packages/rpm.git] / rpm-find-requires
1 #!/bin/sh
2
3 cd `rpm --eval %{_builddir}`
4
5 # note this works for both a.out and ELF executables
6 # it also auto-generates requirment lines for shell scripts
7
8 ulimit -c 0
9
10 filelist=`sed "s/['\"]/\\\&/g"`
11 for i in /examples/ /doc/; do
12 filelist=`echo $filelist | sed "s!\<[^[:space:]]*$i[^[:space:]]*[[:space:]]*!!g"`
13 done
14 if [ -f __rpm_noautoreqfiles ] ; then
15         for i in `cat __rpm_noautoreqfiles`; do
16                 filelist=`echo $filelist | sed "s![[:space:]]*$i[[:space:]]*!!g"`
17         done
18 fi
19 exelist=`echo $filelist | xargs -r file | grep ":.*executable" |grep -v ":.*script"| cut -d: -f1 `
20 elfexelist=`echo $exelist | xargs -r file | egrep  ":.* ELF" | cut -d: -f1 `
21 aoutexelist=`echo $exelist | xargs -r file | egrep  -v ":.* ELF" | cut -d: -f1 `
22 scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) .*executable" | cut -d: -f1 `
23 liblist=`echo $filelist | xargs -r file | grep ":.*shared object" | cut -d : -f1 `
24 elfliblist=`echo $liblist | xargs -r file | egrep  ":.* ELF" | cut -d: -f1 `
25 aoutliblist=`echo $liblist | xargs -r file | egrep  -v ":.* ELF" | cut -d: -f1 `
26
27 aoutexerequires=`for f in $aoutexelist; do
28         ldd $f | awk '/=>/ { print $1 }'
29 done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
30 `
31
32 elfexerequires=`for f in $elfexelist; do 
33         objdump -p $f|awk '/NEEDED/ {print $2}'
34 done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
35 `
36                 
37 aoutlibrequires=`for f in $aoutliblist; do
38     ldd $f | awk '/=>/ { print $1 }'
39 done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
40 `
41
42 elflibrequires=`for f in $elfliblist; do
43         objdump -p $f|awk '/NEEDED/ {print $2}'
44 done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
45 `
46
47 scriptrequires=`for f in $scriptlist; do
48     if [ -x $f ]; then
49         head -1 $f | sed -ne '/^\#\!/p' | sed -e 's/^\#\![      ]*//' | cut -d" " -f1
50     fi
51 done | sort -u
52 `
53
54 elflibverrequires=`for f in $liblist $exelist ; do
55     objdump -p $f | awk '
56         BEGIN { START=0; LIBNAME=""; }
57         /Version References:/ { START=1; }
58         /required from/ && (START==1) {
59             sub(/:/, "", $3);
60             LIBNAME=$3;
61         }
62         (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) { print LIBNAME "(" $4 ")"; }
63         /^$/ { START=0; }
64     '
65 done | sort -u
66 `
67 # Generate name of rpm package provides library
68
69 allrequires="$aoutexerequires
70 $elfexerequires
71 $aoutlibrequires
72 $elflibrequires
73 $elflibverrequires"
74
75 if [ -f __rpm_noautoreq ] ; then
76         for i in `cat __rpm_noautoreq`; do
77                 scriptrequires=`echo $scriptrequires | sed "s!\<$i[[:space:]]*!!g"`
78                 allrequires=`echo $allrequires | sed "s!\<$i[[:space:]]*!!g"`
79         done
80 fi
81
82 # omit autoreqdep for scriptrequires
83 echo "$scriptrequires"
84
85 # Delete all the provided stuff
86
87 echo $filelist|/usr/lib/rpm/find-provides|awk '
88 {
89         if (FNR!=1)
90                 printf "&& "
91         printf "$0 !~ \"^" $0 "$\" "
92 }
93 END {
94         print "{ print $0 }"
95 }' > .findreq_delprovs_$$
96 notprovreqs=`echo "$allrequires"|awk -f .findreq_delprovs_$$`
97 rm .findreq_delprovs_$$
98 echo "$notprovreqs" | sort -u
99
100 if [ -f __rpm_noautoreqdep ] ; then
101         for i in `cat __rpm_noautoreqdep`; do
102                 notprovreqs=`echo $notprovreqs | sed "s!\<$i[[:space:]]*!!g"`
103         done
104 fi
105
106 echo "$notprovreqs" | LC_ALL=C xargs -r -- rpm -q --whatprovides --qf "%{NAME}\n"  2>/dev/null \
107         | grep -v "no package provides" | sort -u
This page took 0.039777 seconds and 3 git commands to generate.