]>
Commit | Line | Data |
---|---|---|
8723ea95 SZ |
1 | #!/bin/sh |
2 | ||
3 | # note this works for both a.out and ELF executables | |
4 | # it also auto-generates requirment lines for shell scripts | |
5 | ||
6 | ulimit -c 0 | |
7 | ||
8 | filelist=`sed "s/['\"]/\\\&/g"` | |
73f676da SZ |
9 | for i in /examples/ /doc/; do |
10 | filelist=`echo $filelist | sed "s!\<[^[:space:]]*$i[^[:space:]]*[[:space:]]*!!g"` | |
8723ea95 SZ |
11 | done |
12 | exelist=`echo $filelist | xargs -r file | grep ":.*executable" | cut -d: -f1 ` | |
13 | elfexelist=`echo $exelist | xargs -r file | egrep ":.* ELF" | cut -d: -f1 ` | |
14 | aoutexelist=`echo $exelist | xargs -r file | egrep -v ":.* ELF" | cut -d: -f1 ` | |
15 | scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) " | cut -d: -f1 ` | |
16 | liblist=`echo $filelist | xargs -r file | grep ":.*shared object" | cut -d : -f1 ` | |
17 | elfliblist=`echo $liblist | xargs -r file | egrep ":.* ELF" | cut -d: -f1 ` | |
18 | aoutliblist=`echo $liblist | xargs -r file | egrep -v ":.* ELF" | cut -d: -f1 ` | |
19 | ||
20 | aoutexerequires=`for f in $aoutexelist; do | |
21 | if [ -x $f ]; then | |
22 | ldd $f | awk '/=>/ { print $1 }' | |
23 | fi | |
24 | done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u | |
25 | ` | |
26 | ||
27 | elfexerequires=`for f in $elfexelist; do | |
28 | if [ -x $f ]; then | |
29 | objdump -p $f|awk '/NEEDED/ {print $2}' | |
30 | fi | |
31 | done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u | |
32 | ` | |
33 | ||
34 | aoutlibrequires=`for f in $aoutliblist; 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 | elflibrequires=`for f in $elfliblist; do | |
40 | objdump -p $f|awk '/NEEDED/ {print $2}' | |
41 | done | sed "s/['\"]/\\\&/g" | grep -v 'libNoVersion.so' | sort -u | |
42 | ` | |
43 | ||
44 | for f in $scriptlist; do | |
45 | if [ -x $f ]; then | |
46 | head -1 $f | sed -ne '/^\#\!/p' | sed -e 's/^\#\![ ]*//' | cut -d" " -f1 | |
47 | fi | |
48 | done | sort -u | |
49 | ||
50 | for f in $liblist $exelist ; do | |
51 | objdump -p $f | awk ' | |
52 | BEGIN { START=0; LIBNAME=""; } | |
53 | /Version References:/ { START=1; } | |
54 | /required from/ && (START==1) { | |
55 | sub(/:/, "", $3); | |
56 | LIBNAME=$3; | |
57 | } | |
58 | (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) { print LIBNAME "(" $4 ")"; } | |
59 | /^$/ { START=0; } | |
60 | ' | |
61 | done | sort -u | |
62 | # Generate name of rpm package provides library | |
63 | ||
64 | ||
65 | echo "$aoutexerequires | |
66 | $elfexerequires | |
67 | $aoutlibrequires | |
68 | $elflibrequires" \ | |
69 | | sort -u | |
70 | ||
71 | echo "$aoutexerequires | |
72 | $elfexerequires | |
73 | $aoutlibrequires | |
74 | $elflibrequires" \ | |
75 | | xargs -r -- rpm -q --whatprovides --qf "%{NAME}\n" 2>/dev/null \ | |
76 | | sort -u |