new find req/prov scripts for non-linux platforms (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.7 1999/09/30 00:22:15 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         # If it's a script...
64         #
65         if test X"$is_shell_script" != X ; then
66                 echo "$is_shell_script"
67                 #
68                 # use `continue' to skip back up to the top of the loop.
69                 # We have already done as much as we need to for this
70                 # file, and this saves me from having to have an else,
71                 # and another indent level... ;-)
72                 #
73                 continue
74         fi
75
76         #
77         # The `else' here is implied by the `continue' above...
78         #
79
80         #
81         # it might be a shared library.
82         #
83
84         maybe_shared_lib=`echo "$file_output" | grep 'executable'`
85         if test X"$maybe_shared_lib" != X ; then
86
87                 odump -Dl $f 2>/dev/null \
88                 | awk '
89
90                         #
91                         # For you non-awk-ers, no single quotes in comments -- the shell
92                         # sees them and things get hosed.
93                         #
94
95                         BEGIN { 
96                                 found_program_name = 0;
97                                 FS = " ";
98                                 RS = "\n";
99                                 OFS="";
100                                 #
101                                 # what character should be used to separate the soname from any
102                                 # version info?  Using a . is actually a bad idea, since some
103                                 # free/3rd party libraries may be built so that the library
104                                 # soname may have version info in it too.  If we use . as the
105                                 # separator, it may not be possible to tell where the soname
106                                 # ends and the internal version info begins.  It might be
107                                 # better to use a - or a : here.  If you do so, be sure to
108                                 # change this setting in find-provides, too.
109                                 #
110                                 soname_version_delimiter=".";
111                         }
112
113                         # uncomment the next line for debugging information
114                         #{ print "Saw input:", $0 }
115
116                         found_program_name == 1 && $0 !~ /^$/ {
117
118                                 # uncomment for debugging information
119                                 #print "found shared library: $0"
120
121                                 # get the library name (field 1) and the library version
122                                 # (field 8) if present.
123                                 numfields = split($0,fields)
124                                 if (numfields == 7) {
125                                         print fields[1]
126                                 } else if (numfields == 8) {
127                                         #
128                                         # Note that if a library contains a number as the last
129                                         # part of the soname *and* it contains version information,
130                                         # we have a problem because it is impossible to tell where
131                                         # the soname ends and the version info begins.  Digital
132                                         # Unix shared libraries should *not* be built with any
133                                         # version info in the soname.  That info should be in
134                                         # the version field only.
135                                         #
136                                         # If we used a separator character of a - or something else,
137                                         # instead of a ., we would not have this problem.
138                                         #
139                                         print fields[1], soname_version_delimiter, fields[8]
140                                 }
141                         }
142
143                         /^.*: *$/ {
144                                 found_program_name = 1
145                                 #
146                                 # uncomment the next line for debugging information
147                                 #print "found the program name: ", $1
148                         }
149
150                 ' # end of awk
151         fi
152 done | sort -u
153 # comment out the previous line and uncomment the next when debugging
154 # done