3 # Original Author: Tim Mooney (mooney@plains.nodak.edu)
4 # This file is distributed under the terms of the GNU Public License
6 # find-requires is part of RPM, the RedHat Package Manager. find-requires
7 # reads a list of full pathnames (in a package) on stdin, and outputs all
8 # shared libraries the package requires to execute.
10 # On Digital Unix (OSF1), use `odump -Dl' to find the library dependencies
11 # for an executable. `odump -D' does most of what we need, but it doesn't
12 # give us library version information, so you must use `odump -Dl'
14 # Example `odump -Dl' output:
16 #$odump -Dl /usr/bin/X11/xterm
21 # ***LIBRARY LIST SECTION***
22 # Name Time-Stamp CheckSum Flags Version
24 # libXaw.so Dec 9 00:15:35 1997 0x285006d0 0 6.0
25 # libXmu.so Dec 9 00:13:36 1997 0x3bf3a33d 0
26 # libXt.so Dec 9 00:12:18 1997 0x10dd9a17 0
27 # libSM.so Dec 9 00:08:11 1997 0xb64c7082 0
28 # libICE.so Dec 9 00:07:52 1997 0x1199be32 0
29 # libXext.so Dec 9 00:08:51 1997 0xafcb84d5 0
30 # libX11.so Dec 9 00:06:05 1997 0xaa1bf091 0
31 # libc.so Dec 8 18:41:11 1997 0x5e955f9b 0 osf.1
34 # TVM: it might be better to re-write this so that `file' isn't used, since
35 # it can all be done with `odump', but this works.
37 filelist=`sed "s/['\"]/\\\&/g" | xargs file | grep executable | cut -d: -f1`
41 odump -Dl $f 2>/dev/null | awk '
44 # For you non-awk-ers, no single quotes in comments -- the shell
45 # sees them and things get hosed.
49 seen_program_name = 0;
55 # uncomment the next line for debugging information
56 #{ print "Got input:", $0 }
58 seen_program_name == 1 && $0 !~ /^$/ {
60 # uncomment for debugging information
61 #print "found shared library: $0"
63 # get the library name (field 1) and the library version (field 8)
65 numfields = split($0,fields)
68 } else if (numfields == 8) {
70 # Note that if a library contains a number as the last
71 # part of the soname *and* it contains version information,
72 # we have a problem because it is impossible to tell where
73 # the soname ends and the version info begins. Digital Unix
74 # shared libraries should *not* be built with any version info
75 # in the soname. That info should be in the version field
77 # If we used a separator character of a - or something else,
78 # instead of a ., we would not have this problem.
80 print fields[1], ".", fields[8]
87 # uncomment the next line for debugging information
88 #print "found the program name: $1"