]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-find-requires
- fixed
[packages/rpm.git] / rpm-find-requires
CommitLineData
edb85bf4
JK
1#!/bin/sh
2
3cd `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
8ulimit -c 0
9
10filelist=`sed "s/['\"]/\\\&/g"`
11for i in /examples/ /doc/; do
12filelist=`echo $filelist | sed "s!\<[^[:space:]]*$i[^[:space:]]*[[:space:]]*!!g"`
13done
14if [ -f __rpm_noautoreqfiles ] ; then
15 for i in `cat __rpm_noautoreqfiles`; do
16 filelist=`echo $filelist | sed "s![[:space:]]*$i[[:space:]]*!!g"`
17 done
18fi
19exelist=`echo $filelist | xargs -r file | grep ":.*executable" |grep -v ":.*script"| cut -d: -f1 `
20elfexelist=`echo $exelist | xargs -r file | egrep ":.* ELF" | cut -d: -f1 `
21aoutexelist=`echo $exelist | xargs -r file | egrep -v ":.* ELF" | cut -d: -f1 `
22scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) .*executable" | cut -d: -f1 `
23liblist=`echo $filelist | xargs -r file | grep ":.*shared object" | cut -d : -f1 `
24elfliblist=`echo $liblist | xargs -r file | egrep ":.* ELF" | cut -d: -f1 `
25aoutliblist=`echo $liblist | xargs -r file | egrep -v ":.* ELF" | cut -d: -f1 `
26
27aoutexerequires=`for f in $aoutexelist; do
28 if [ -x $f ]; then
29 ldd $f | awk '/=>/ { print $1 }'
30 fi
31done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
32`
33
34elfexerequires=`for f in $elfexelist; do
35 if [ -x $f ]; then
36 objdump -p $f|awk '/NEEDED/ {print $2}'
37 fi
38done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
39`
40
41aoutlibrequires=`for f in $aoutliblist; do
42 ldd $f | awk '/=>/ { print $1 }'
43done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
44`
45
46elflibrequires=`for f in $elfliblist; do
47 objdump -p $f|awk '/NEEDED/ {print $2}'
48done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
49`
22628fea 50
3673867c 51scriptrequires=`for f in $scriptlist; do
edb85bf4
JK
52 if [ -x $f ]; then
53 head -1 $f | sed -ne '/^\#\!/p' | sed -e 's/^\#\![ ]*//' | cut -d" " -f1
54 fi
55done | sort -u
3673867c 56`
edb85bf4 57
3673867c 58elflibverrequires=`for f in $liblist $exelist ; do
edb85bf4
JK
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 '
69done | sort -u
3673867c 70`
edb85bf4
JK
71# Generate name of rpm package provides library
72
73allrequires="$aoutexerequires
74$elfexerequires
75$aoutlibrequires
3673867c 76$elflibrequires
3673867c 77$elflibverrequires"
edb85bf4
JK
78
79if [ -f __rpm_noautoreq ] ; then
80 for i in `cat __rpm_noautoreq`; do
f60604a3 81 scriptrequires=`echo $scriptrequires | sed "s!\<$i[[:space:]]*!!g"`
edb85bf4
JK
82 allrequires=`echo $allrequires | sed "s!\<$i[[:space:]]*!!g"`
83 done
84fi
85
f60604a3
JB
86# omit autoreqdep for scriptrequires
87echo "$scriptrequires"
88
22628fea 89# Delete all the provided stuff
edb85bf4 90
22628fea 91echo $filelist|/usr/lib/rpm/find-provides|awk '
92{
93 if (FNR!=1)
94 printf "&& "
95 printf "$0 !~ \"^" $0 "$\" "
96}
97END {
98 print "{ print $0 }"
99}' > .findreq_delprovs_$$
100notprovreqs=`echo "$allrequires"|awk -f .findreq_delprovs_$$`
101rm .findreq_delprovs_$$
102echo "$notprovreqs" | sort -u
103
514971e5
JB
104if [ -f __rpm_noautoreqdep ] ; then
105 for i in `cat __rpm_noautoreqdep`; do
106 notprovreqs=`echo $notprovreqs | sed "s!\<$i[[:space:]]*!!g"`
107 done
108fi
109
22628fea 110echo "$notprovreqs" | LC_ALL=C xargs -r -- rpm -q --whatprovides --qf "%{NAME}\n" 2>/dev/null \
111 | grep -v "no package provides" | sort -u
This page took 0.037996 seconds and 4 git commands to generate.