]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find-requires
- include --x-libraries=/usr/X11R6/%{_lib} in %configure macros
[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
20 # --- Alpha does not mark 64bit dependencies
21 case `uname -m` in
22     alpha*)       mark64="" ;;
23     *)            mark64="()(64bit)" ;;
24 esac
25     
26 exelist=`echo $filelist | xargs -r file | grep ":.*executable" |grep -v ":.*script"| cut -d: -f1 `
27 elfexelist=`echo $exelist | xargs -r file | egrep  ":.* ELF" | cut -d: -f1 `
28 aoutexelist=`echo $exelist | xargs -r file | egrep  -v ":.* ELF" | cut -d: -f1 `
29 scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) .*executable" | cut -d: -f1 `
30 liblist=`echo $filelist | xargs -r file | grep ":.*shared object" | cut -d : -f1 `
31 elfliblist=`echo $liblist | xargs -r file | egrep  ":.* ELF" | cut -d: -f1 `
32 aoutliblist=`echo $liblist | xargs -r file | egrep  -v ":.* ELF" | cut -d: -f1 `
33
34 aoutexerequires=`for f in $aoutexelist; do
35         ldd $f | awk '/=>/ { print $1 }'
36 done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
37 `
38
39 elfexerequires=`for f in $elfexelist; do 
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}'
43 done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
44 `
45                 
46 aoutlibrequires=`for f in $aoutliblist; do
47     ldd $f | awk '/=>/ { print $1 }'
48 done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
49 `
50
51 elflibrequires=`for f in $elfliblist; do
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}'
55 done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u
56 `
57
58 scriptrequires=`for f in $scriptlist; do
59     if [ -x $f ]; then
60         head -1 $f | sed -ne '/^\#\!/p' | sed -e 's/^\#\![      ]*//' | cut -d" " -f1
61     fi
62 done | sort -u
63 `
64
65 elflibverrequires=`for f in $liblist $exelist ; do
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     '
76 done | sort -u
77 `
78 # Generate name of rpm package provides library
79
80 allrequires="$aoutexerequires
81 $elfexerequires
82 $aoutlibrequires
83 $elflibrequires
84 $elflibverrequires"
85
86 if [ -f __rpm_noautoreq ] ; then
87         for i in `cat __rpm_noautoreq`; do
88                 scriptrequires=`echo $scriptrequires | sed "s!\<$i[[:space:]]*!!g"`
89                 allrequires=`echo $allrequires | sed "s!\<$i[[:space:]]*!!g"`
90         done
91 fi
92
93 # omit autoreqdep for scriptrequires
94 echo "$scriptrequires"
95
96 # Delete all the provided stuff
97
98 echo $filelist|/usr/lib/rpm/find-provides|awk '
99 {
100         if (FNR!=1)
101                 printf "&& "
102         printf "$0 !~ \"^" $0 "$\" "
103 }
104 END {
105         print "{ print $0 }"
106 }' > .findreq_delprovs_$$
107 notprovreqs=`echo "$allrequires"|awk -f .findreq_delprovs_$$`
108 rm .findreq_delprovs_$$
109 echo "$notprovreqs" | sort -u
110
111 if [ -f __rpm_noautoreqdep ] ; then
112         for i in `cat __rpm_noautoreqdep`; do
113                 notprovreqs=`echo $notprovreqs | sed "s!\<$i[[:space:]]*!!g"`
114         done
115 fi
116
117 echo "$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.037422 seconds and 3 git commands to generate.