Tru64: avoid find-requires variable size limit (Tim Mooney).
[platform/upstream/rpm.git] / autodeps / osf.req
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney (mooney@plains.nodak.edu)
4 # $Id: osf.req,v 1.6 1999/09/07 19:53:10 jbj Exp $
5 #
6 # This file is distributed under the terms of the GNU 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 #
39 # TVM: switch to using `while read ...' instead of `for f in ...', because
40 # packages with a large number of files could be too big for one shell variable
41 # to hold.
42 #
43 IFS=""
44 while read f
45 do
46
47         #
48         # Uncomment the next line for addtional debugging:
49         # echo "read ->$f<-"
50
51         #
52         # Only run file once per file:
53         #
54         file_output=`file $f`
55
56         #
57         # handle shell scripts first
58         #
59         is_shell_script=`echo "$file_output" | grep 'shell script' | \
60                 cut -d: -f 2 | awk '{ print $1 }'`
61
62         #
63         # it's a script
64         #
65         if test X"$is_shell_script" != X ; then
66                 echo $is_shell_script
67
68         else
69
70                 #
71                 # it might be a shared library.
72                 #
73
74                 maybe_shared_lib=`echo "$file_output" | grep 'executable'`
75                 if test X"$maybe_shared_lib" != X ; then
76
77                         odump -Dl $f 2>/dev/null | awk '
78
79                         #
80                         # For you non-awk-ers, no single quotes in comments -- the shell
81                         # sees them and things get hosed.
82                         #
83
84                         BEGIN { 
85                                 found_program_name = 0;
86                                 FS = " ";
87                                 RS = "\n";
88                                 OFS="";
89                                 #
90                                 # what character should be used to separate the soname from any
91                                 # version info?  Using a . is actually a bad idea, since some
92                                 # free/3rd party libraries may be built so that the library
93                                 # soname may have version info in it too.  If we use . as the
94                                 # separator, it may not be possible to tell where the soname
95                                 # ends and the internal version info begins.  It might be
96                                 # better to use a - or a : here.  If you do so, be sure to
97                                 # change this setting in find-provides, too.
98                                 #
99                                 soname_version_delimiter=".";
100                         }
101
102                         # uncomment the next line for debugging information
103                         #{ print "Saw input:", $0 }
104
105                         found_program_name == 1 && $0 !~ /^$/ {
106
107                                 # uncomment for debugging information
108                                 #print "found shared library: $0"
109
110                                 # get the library name (field 1) and the library version
111                                 # (field 8) if present.
112                                 numfields = split($0,fields)
113                                 if (numfields == 7) {
114                                         print fields[1]
115                                 } else if (numfields == 8) {
116                                         #
117                                         # Note that if a library contains a number as the last
118                                         # part of the soname *and* it contains version information,
119                                         # we have a problem because it is impossible to tell where
120                                         # the soname ends and the version info begins.  Digital
121                                         # Unix shared libraries should *not* be built with any
122                                         # version info in the soname.  That info should be in
123                                         # the version field only.
124                                         #
125                                         # If we used a separator character of a - or something else,
126                                         # instead of a ., we would not have this problem.
127                                         #
128                                         print fields[1], soname_version_delimiter, fields[8]
129                                 }
130                         }
131
132                         /^.*: *$/ {
133                                 found_program_name = 1
134                                 #
135                                 # uncomment the next line for debugging information
136                                 #print "found the program name: ", $1
137                         }
138
139                         ' # end of awk
140                 fi
141         fi
142 done | sort -u
143 # comment out the previous line and uncomment the next when debugging
144 # done