]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find-requires
5e3c8db9d1d875640e6f04ae1880846f09600fe5
[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     if [ -x $f ]; then
29         ldd $f | awk '/=>/ { print $1 }'
30     fi
31 done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
32 `
33
34 elfexerequires=`for f in $elfexelist; do 
35     if [ -x $f ]; then
36         objdump -p $f|awk '/NEEDED/ {print $2}'
37     fi
38 done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
39 `
40                 
41 aoutlibrequires=`for f in $aoutliblist; do
42     ldd $f | awk '/=>/ { print $1 }'
43 done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
44 `
45
46 elflibrequires=`for f in $elfliblist; do
47         objdump -p $f|awk '/NEEDED/ {print $2}'
48 done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
49 `
50
51 scriptrequires=`for f in $scriptlist; do
52     if [ -x $f ]; then
53         head -1 $f | sed -ne '/^\#\!/p' | sed -e 's/^\#\![      ]*//' | cut -d" " -f1
54     fi
55 done | sort -u
56 `
57
58 elflibverrequires=`for f in $liblist $exelist ; do
59     objdump -p $f | awk '
60         BEGIN { START=0; LIBNAME=""; }
61         /Version References:/ { START=1; }
62         /required from/ && (START==1) {
63             sub(/:/, "", $3);
64             LIBNAME=$3;
65         }
66         (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) { print LIBNAME "(" $4 ")"; }
67         /^$/ { START=0; }
68     '
69 done | sort -u
70 `
71 # Generate name of rpm package provides library
72
73 allrequires="$aoutexerequires
74 $elfexerequires
75 $aoutlibrequires
76 $elflibrequires
77 $scriptrequires
78 $elflibverrequires"
79
80 if [ -f __rpm_noautoreq ] ; then
81         for i in `cat __rpm_noautoreq`; do
82                 allrequires=`echo $allrequires | sed "s!\<$i[[:space:]]*!!g"`
83         done
84 fi
85
86 # Delete all the provided stuff
87
88 echo $filelist|/usr/lib/rpm/find-provides|awk '
89 {
90         if (FNR!=1)
91                 printf "&& "
92         printf "$0 !~ \"^" $0 "$\" "
93 }
94 END {
95         print "{ print $0 }"
96 }' > .findreq_delprovs_$$
97 notprovreqs=`echo "$allrequires"|awk -f .findreq_delprovs_$$`
98 rm .findreq_delprovs_$$
99 echo "$notprovreqs" | sort -u
100
101 if [ -f __rpm_noautoreqdep ] ; then
102         for i in `cat __rpm_noautoreqdep`; do
103                 notprovreqs=`echo $notprovreqs | sed "s!\<$i[[:space:]]*!!g"`
104         done
105 fi
106
107 echo "$notprovreqs" | LC_ALL=C xargs -r -- rpm -q --whatprovides --qf "%{NAME}\n"  2>/dev/null \
108         | grep -v "no package provides" | sort -u
This page took 0.026103 seconds and 3 git commands to generate.