]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-find-requires
- sync X/non-X: added Applications/Science
[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
edb85bf4 28 ldd $f | awk '/=>/ { print $1 }'
edb85bf4
JK
29done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
30`
31
32elfexerequires=`for f in $elfexelist; do
edb85bf4 33 objdump -p $f|awk '/NEEDED/ {print $2}'
edb85bf4
JK
34done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
35`
36
37aoutlibrequires=`for f in $aoutliblist; do
38 ldd $f | awk '/=>/ { print $1 }'
39done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
40`
41
42elflibrequires=`for f in $elfliblist; do
43 objdump -p $f|awk '/NEEDED/ {print $2}'
44done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
45`
22628fea 46
3673867c 47scriptrequires=`for f in $scriptlist; do
edb85bf4
JK
48 if [ -x $f ]; then
49 head -1 $f | sed -ne '/^\#\!/p' | sed -e 's/^\#\![ ]*//' | cut -d" " -f1
50 fi
51done | sort -u
3673867c 52`
edb85bf4 53
3673867c 54elflibverrequires=`for f in $liblist $exelist ; do
edb85bf4
JK
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 '
65done | sort -u
3673867c 66`
edb85bf4
JK
67# Generate name of rpm package provides library
68
69allrequires="$aoutexerequires
70$elfexerequires
71$aoutlibrequires
3673867c 72$elflibrequires
3673867c 73$elflibverrequires"
edb85bf4
JK
74
75if [ -f __rpm_noautoreq ] ; then
76 for i in `cat __rpm_noautoreq`; do
f60604a3 77 scriptrequires=`echo $scriptrequires | sed "s!\<$i[[:space:]]*!!g"`
edb85bf4
JK
78 allrequires=`echo $allrequires | sed "s!\<$i[[:space:]]*!!g"`
79 done
80fi
81
f60604a3
JB
82# omit autoreqdep for scriptrequires
83echo "$scriptrequires"
84
22628fea 85# Delete all the provided stuff
edb85bf4 86
22628fea 87echo $filelist|/usr/lib/rpm/find-provides|awk '
88{
89 if (FNR!=1)
90 printf "&& "
91 printf "$0 !~ \"^" $0 "$\" "
92}
93END {
94 print "{ print $0 }"
95}' > .findreq_delprovs_$$
96notprovreqs=`echo "$allrequires"|awk -f .findreq_delprovs_$$`
97rm .findreq_delprovs_$$
98echo "$notprovreqs" | sort -u
99
514971e5
JB
100if [ -f __rpm_noautoreqdep ] ; then
101 for i in `cat __rpm_noautoreqdep`; do
102 notprovreqs=`echo $notprovreqs | sed "s!\<$i[[:space:]]*!!g"`
103 done
104fi
105
22628fea 106echo "$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.045878 seconds and 4 git commands to generate.