Clarify licensing: "GNU General Public License" not s/General //.
[platform/upstream/rpm.git] / autodeps / osf.req
1 #!/bin/sh
2
3 # Original Author: Tim Mooney (mooney@plains.nodak.edu)
4 # $Id: osf.req,v 1.5 1999/08/04 18:07:18 jbj Exp $
5 #
6 # This file is distributed under the terms of the GNU General Public License
7 #
8 # find-requires is part of RPM, the Red Hat Package Manager.  find-requires
9 # reads a list of full pathnames (in a package) on stdin, and outputs all
10 # shared libraries the package requires to execute.
11 #
12 # On Digital Unix (OSF1), use `odump -Dl' to find the library dependencies
13 # for an executable.  `odump -D' does most of what we need, but it doesn't
14 # give us library version information, so you must use `odump -Dl'
15 #
16 # Example `odump -Dl' output:
17 #
18 #$odump -Dl /usr/bin/X11/xterm
19
20 #
21 #
22 #
23 #                       ***LIBRARY LIST SECTION***
24 #       Name             Time-Stamp        CheckSum   Flags Version
25 #/usr/bin/X11/xterm:
26 #       libXaw.so    Dec  9 00:15:35 1997 0x285006d0     0 6.0
27 #       libXmu.so    Dec  9 00:13:36 1997 0x3bf3a33d     0 
28 #       libXt.so     Dec  9 00:12:18 1997 0x10dd9a17     0 
29 #       libSM.so     Dec  9 00:08:11 1997 0xb64c7082     0 
30 #       libICE.so    Dec  9 00:07:52 1997 0x1199be32     0 
31 #       libXext.so   Dec  9 00:08:51 1997 0xafcb84d5     0 
32 #       libX11.so    Dec  9 00:06:05 1997 0xaa1bf091     0 
33 #       libc.so      Dec  8 18:41:11 1997 0x5e955f9b     0 osf.1
34
35 PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin
36 export PATH
37
38 filelist=`cat -`
39
40 #
41 # Handle shell scripts first
42 #
43 for f in `echo $filelist | xargs file | grep 'shell script' | cut -d: -f 2 \
44         | awk '{ print $1 }'`
45 do
46     echo $f
47 done | sort -u
48
49 #
50 # TVM: it might be better to re-write this so that `file' isn't used, since
51 # it could all be done with `odump', but this works.
52 #
53
54 for f in `echo $filelist | xargs file | grep executable | cut -d: -f1`
55 do
56         odump -Dl $f 2>/dev/null | awk '
57
58                 #
59                 # For you non-awk-ers, no single quotes in comments -- the shell
60                 # sees them and things get hosed.
61                 #
62
63                 BEGIN { 
64                         found_program_name = 0;
65                         FS = " ";
66                         RS = "\n";
67                         OFS="";
68                         #
69                         # what character should be used to separate the soname from any
70                         # version info?  Using a . is actually a bad idea, since some
71                         # free/3rd party libraries may be built so that the library
72                         # soname may have version info in it too.  If we use . as the
73                         # separator, it may not be possible to tell where the soname
74                         # ends and the internal version info begins.  It might be
75                         # better to use a - or a : here.  If you do so, be sure to
76                         # change this setting in find-provides, too.
77                         #
78                         soname_version_delimiter=".";
79                 }
80
81                 # uncomment the next line for debugging information
82                 #{ print "Saw input:", $0 }
83
84                 found_program_name == 1 && $0 !~ /^$/ {
85
86                         # uncomment for debugging information
87                         #print "found shared library: $0"
88                 
89                         # get the library name (field 1) and the library version (field 8)
90                         # if present.
91                         numfields = split($0,fields)
92                         if (numfields == 7) {
93                                 print fields[1]
94                         } else if (numfields == 8) {
95                                 #
96                                 # Note that if a library contains a number as the last
97                                 # part of the soname *and* it contains version information,
98                                 # we have a problem because it is impossible to tell where
99                                 # the soname ends and the version info begins.  Digital Unix
100                                 # shared libraries should *not* be built with any version info
101                                 # in the soname.  That info should be in the version field
102                                 # only.
103                                 #
104                                 # If we used a separator character of a - or something else,
105                                 # instead of a ., we would not have this problem.
106                                 #
107                                 print fields[1], soname_version_delimiter, fields[8]
108                         }
109                 }
110
111                 /^.*: *$/ {
112                         found_program_name = 1
113                         #
114                         # uncomment the next line for debugging information
115                         #print "found the program name: ", $1
116                 }
117
118         ' # end of awk
119 done | sort -u
120 # comment out the previous line and uncomment the next when debugging
121 # done