]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-find-requires
- include --x-libraries=/usr/X11R6/%{_lib} in %configure macros
[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
b449f897
AM
19
20# --- Alpha does not mark 64bit dependencies
21case `uname -m` in
22 alpha*) mark64="" ;;
23 *) mark64="()(64bit)" ;;
24esac
25
edb85bf4
JK
26exelist=`echo $filelist | xargs -r file | grep ":.*executable" |grep -v ":.*script"| cut -d: -f1 `
27elfexelist=`echo $exelist | xargs -r file | egrep ":.* ELF" | cut -d: -f1 `
28aoutexelist=`echo $exelist | xargs -r file | egrep -v ":.* ELF" | cut -d: -f1 `
29scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) .*executable" | cut -d: -f1 `
30liblist=`echo $filelist | xargs -r file | grep ":.*shared object" | cut -d : -f1 `
31elfliblist=`echo $liblist | xargs -r file | egrep ":.* ELF" | cut -d: -f1 `
32aoutliblist=`echo $liblist | xargs -r file | egrep -v ":.* ELF" | cut -d: -f1 `
33
34aoutexerequires=`for f in $aoutexelist; do
edb85bf4 35 ldd $f | awk '/=>/ { print $1 }'
edb85bf4
JK
36done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
37`
38
39elfexerequires=`for f in $elfexelist; do
b449f897
AM
40 lib64=`if file -L $f 2>/dev/null | \
41 grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
42 objdump -p $f | awk -v lib64="$lib64" '/NEEDED/ {print $2 lib64}'
edb85bf4
JK
43done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
44`
45
46aoutlibrequires=`for f in $aoutliblist; do
47 ldd $f | awk '/=>/ { print $1 }'
48done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
49`
50
51elflibrequires=`for f in $elfliblist; do
b449f897
AM
52 lib64=`if file -L $f 2>/dev/null | \
53 grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
54 objdump -p $f | awk -v lib64="$lib64" '/NEEDED/ {print $2 lib64}'
edb85bf4
JK
55done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
56`
22628fea 57
3673867c 58scriptrequires=`for f in $scriptlist; do
edb85bf4
JK
59 if [ -x $f ]; then
60 head -1 $f | sed -ne '/^\#\!/p' | sed -e 's/^\#\![ ]*//' | cut -d" " -f1
61 fi
62done | sort -u
3673867c 63`
edb85bf4 64
3673867c 65elflibverrequires=`for f in $liblist $exelist ; do
edb85bf4
JK
66 objdump -p $f | awk '
67 BEGIN { START=0; LIBNAME=""; }
68 /Version References:/ { START=1; }
69 /required from/ && (START==1) {
70 sub(/:/, "", $3);
71 LIBNAME=$3;
72 }
73 (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) { print LIBNAME "(" $4 ")"; }
74 /^$/ { START=0; }
75 '
76done | sort -u
3673867c 77`
edb85bf4
JK
78# Generate name of rpm package provides library
79
80allrequires="$aoutexerequires
81$elfexerequires
82$aoutlibrequires
3673867c 83$elflibrequires
3673867c 84$elflibverrequires"
edb85bf4
JK
85
86if [ -f __rpm_noautoreq ] ; then
87 for i in `cat __rpm_noautoreq`; do
f60604a3 88 scriptrequires=`echo $scriptrequires | sed "s!\<$i[[:space:]]*!!g"`
edb85bf4
JK
89 allrequires=`echo $allrequires | sed "s!\<$i[[:space:]]*!!g"`
90 done
91fi
92
f60604a3
JB
93# omit autoreqdep for scriptrequires
94echo "$scriptrequires"
95
22628fea 96# Delete all the provided stuff
edb85bf4 97
22628fea 98echo $filelist|/usr/lib/rpm/find-provides|awk '
99{
100 if (FNR!=1)
101 printf "&& "
102 printf "$0 !~ \"^" $0 "$\" "
103}
104END {
105 print "{ print $0 }"
106}' > .findreq_delprovs_$$
107notprovreqs=`echo "$allrequires"|awk -f .findreq_delprovs_$$`
108rm .findreq_delprovs_$$
109echo "$notprovreqs" | sort -u
110
514971e5
JB
111if [ -f __rpm_noautoreqdep ] ; then
112 for i in `cat __rpm_noautoreqdep`; do
113 notprovreqs=`echo $notprovreqs | sed "s!\<$i[[:space:]]*!!g"`
114 done
115fi
116
22628fea 117echo "$notprovreqs" | LC_ALL=C xargs -r -- rpm -q --whatprovides --qf "%{NAME}\n" 2>/dev/null \
118 | grep -v "no package provides" | sort -u
This page took 0.068317 seconds and 4 git commands to generate.