1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
#! /usr/bin/ksh
# Original Author: Tim Mooney (mooney@plains.nodak.edu)
# $Id: irix6.req,v 1.2 1998/06/14 16:03:14 ewt Exp $
#
# This file is distributed under the terms of the GNU Public License
#
# find-requires is part of RPM, the Red Hat Package Manager. find-requires
# reads a list of full pathnames (in a package) on stdin, and outputs all
# shared libraries the package requires to execute.
#
# NOTE: I use `:' as the delimiter (by default) between the library soname
# and any library version info. This is because IRIX libraries (even
# system libraries) have "version information" in both the soname and the
# internal version field, so it's important to be able to separate those
# fields. If we just used `.', we wouldn't know where the soname ends and
# the version infromation begins.
#
# On IRIX, use `elfdump -Dl' to find what libraries are required by
# an executable. `elfdump -L' does what we need too, but it gives us more
# than we really need.
#
# Example `elfdump -Dl' output:
#
#$elfdump -Dl /usr/bin/X11/xterm
#
#
#
#/usr/bin/X11/xterm:
#
# **** MIPS LIBLIST INFORMATION ****
#.liblist :
#[INDEX] Timestamp Checksum Flags Name Version
#[1] Nov 23 15:39:02 1997 0x4da65893 ----- libXaw.so.2 sgi2.0
#[2] Nov 23 15:39:02 1997 0x414eece6 ----- libXmu.so sgi1.0
#[3] Nov 23 15:39:02 1997 0x6f314e69 ----- libXt.so sgi1.0
#[4] Nov 23 15:39:02 1997 0xcbe81fff ----- libXext.so sgi1.0
#[5] Nov 23 15:39:02 1997 0x89ae8e98 ----- libX11.so.1 sgi1.0
#[6] Oct 27 01:00:29 1997 0x99b27890 ----- libcurses.so sgi1.0
#[7] Jun 16 18:23:15 1997 0x92321a0c ----- libc.so.1 sgi1.0
#
#
# TVM: it might be better to re-write this so that `file' isn't used, since
# it can all be done with `elfdump', but this works.
#
PATH=/usr/bin:/usr/sbin
export PATH
filelist=`cat -`
#
# Handle scripts first
#
for f in `echo $filelist | xargs file | grep 'script text' | cut -d: -f 2 \
| awk '{ print $1 }'`
do
print $f
done | sort -u
for f in `echo $filelist | xargs file | egrep 'executable|lib' | cut -d: -f1`
do
#echo "Working on $f"
elfdump -Dl $f 2>/dev/null | awk '
#
# For you non-awk-ers, no single quotes in comments -- the shell
# sees them and things get hosed.
#
BEGIN {
found_column_headers = 0;
FS = " ";
RS = "\n";
OFS="";
soname_version_delimiter=":";
}
# uncomment the next line for debugging information
#{ print "Saw input:", $0 }
found_column_headers == 1 && $0 !~ /^$/ {
# get the library name (field 15) and the library version (field 16)
# if present.
numfields = split($0,fields)
if (numfields == 8) {
print fields[8]
} else if (numfields == 9) {
#
print fields[8], soname_version_delimiter, fields[9]
} else if (numfields > 9) {
#
# SGI has this annoying habit of putting comments, complete
# with whitespace, in their library IVERSION field. Yuck.
#
# Handle libraries like this gracefully.
#
verfields = split(fields[NF], junk, "#")
if (verfields == 2) {
print fields[8], soname_version_delimiter, junk[2]
} else if (verfields > 2) {
print fields[8], soname_version_delimiter, junk[verfields]
} else {
print "Cannot find version:", fields[numfields] | "cat 2>&1"
}
}
}
/^\[INDEX\].Timestamp.*Checksum.*Flags.*Name.*Version$/ {
# we better start paying attention now.
found_column_headers = 1
#
# uncomment the next line for debugging information
#print "found the column headers: ", $0
}
' # end of awk
done | sort -u
# comment out the previous line and uncomment the next when debugging
#done
#! /usr/bin/ksh
# Original Author: Tim Mooney (mooney@plains.nodak.edu)
# $Id: irix6.req,v 1.2 1998/06/14 16:03:14 ewt Exp $
#
# This file is distributed under the terms of the GNU Public License
#
# find-requires is part of RPM, the Red Hat Package Manager. find-requires
# reads a list of full pathnames (in a package) on stdin, and outputs all
# shared libraries the package requires to execute.
#
# NOTE: I use `:' as the delimiter (by default) between the library soname
# and any library version info. This is because IRIX libraries (even
# system libraries) have "version information" in both the soname and the
# internal version field, so it's important to be able to separate those
# fields. If we just used `.', we wouldn't know where the soname ends and
# the version infromation begins.
#
# On IRIX, use `elfdump -Dl' to find what libraries are required by
# an executable. `elfdump -L' does what we need too, but it gives us more
# than we really need.
#
# Example `elfdump -Dl' output:
#
#$elfdump -Dl /usr/bin/X11/xterm
#
#
#
#/usr/bin/X11/xterm:
#
# **** MIPS LIBLIST INFORMATION ****
#.liblist :
#[INDEX] Timestamp Checksum Flags Name Version
#[1] Nov 23 15:39:02 1997 0x4da65893 ----- libXaw.so.2 sgi2.0
#[2] Nov 23 15:39:02 1997 0x414eece6 ----- libXmu.so sgi1.0
#[3] Nov 23 15:39:02 1997 0x6f314e69 ----- libXt.so sgi1.0
#[4] Nov 23 15:39:02 1997 0xcbe81fff ----- libXext.so sgi1.0
#[5] Nov 23 15:39:02 1997 0x89ae8e98 ----- libX11.so.1 sgi1.0
#[6] Oct 27 01:00:29 1997 0x99b27890 ----- libcurses.so sgi1.0
#[7] Jun 16 18:23:15 1997 0x92321a0c ----- libc.so.1 sgi1.0
#
#
# TVM: it might be better to re-write this so that `file' isn't used, since
# it can all be done with `elfdump', but this works.
#
PATH=/usr/bin:/usr/sbin
export PATH
filelist=`cat -`
#
# Handle scripts first
#
for f in `echo $filelist | xargs file | grep 'script text' | cut -d: -f 2 \
| awk '{ print $1 }'`
do
print $f
done | sort -u
for f in `echo $filelist | xargs file | egrep 'executable|lib' | cut -d: -f1`
do
#echo "Working on $f"
elfdump -Dl $f 2>/dev/null | awk '
#
# For you non-awk-ers, no single quotes in comments -- the shell
# sees them and things get hosed.
#
BEGIN {
found_column_headers = 0;
FS = " ";
RS = "\n";
OFS="";
soname_version_delimiter=":";
}
# uncomment the next line for debugging information
#{ print "Saw input:", $0 }
found_column_headers == 1 && $0 !~ /^$/ {
# get the library name (field 15) and the library version (field 16)
# if present.
numfields = split($0,fields)
if (numfields == 8) {
print fields[8]
} else if (numfields == 9) {
#
print fields[8], soname_version_delimiter, fields[9]
} else if (numfields > 9) {
#
# SGI has this annoying habit of putting comments, complete
# with whitespace, in their library IVERSION field. Yuck.
#
# Handle libraries like this gracefully.
#
verfields = split(fields[NF], junk, "#")
if (verfields == 2) {
print fields[8], soname_version_delimiter, junk[2]
} else if (verfields > 2) {
print fields[8], soname_version_delimiter, junk[verfields]
} else {
print "Cannot find version:", fields[numfields] | "cat 2>&1"
}
}
}
/^\[INDEX\].Timestamp.*Checksum.*Flags.*Name.*Version$/ {
# we better start paying attention now.
found_column_headers = 1
#
# uncomment the next line for debugging information
#print "found the column headers: ", $0
}
' # end of awk
done | sort -u
# comment out the previous line and uncomment the next when debugging
#done
|