more updates from Tim Mooney
[platform/upstream/rpm.git] / autodeps / osf.prov
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney (mooney@plains.nodak.edu)
4 # $Id: osf.prov,v 1.2 1998/05/29 16:34:27 mooney Exp $
5 #
6 # This file is distributed under the terms of the GNU Public License
7 #
8 # find-provides is part of RPM, the Red Hat Package Manager.  find-provides
9 # reads a list of full pathnames (in a package) on stdin, and outputs all
10 # shared libraries provided by (contained in) the package.
11 #
12 #
13 # On Digital Unix (OSF1), use `odump -D' to find what libraries a package
14 # provides
15 #
16 # Example `odump -D' output:
17 #
18 #$odump -D /usr/shlib/libc.so
19 #
20 #
21 #
22 #
23 #                       ***DYNAMIC SECTION***
24 #                Tag            Value
25 #
26 #/usr/shlib/libc.so:
27 #                 UNREFEXTNO: 14.
28 #                LOCAL_GOTNO: 521.
29 #                     GOTSYM: 2205.
30 #                LOCAL_GOTNO: 1606.
31 #                     GOTSYM: 3289.
32 #                     SONAME: libc.so
33 #                 TIME_STAMP: (0x34a82daa) Mon Dec 29 17:09:30 1997
34 #
35 #                  ICHECKSUM: 0x5e955f9b
36 #                   IVERSION: osf.1
37 #                 CONFLICTNO: 0.
38 #                RLD_VERSION: 2.
39 #                       HASH: 0x000003ff800a82e0
40 #                     STRTAB: 0x000003ff8008aad0
41 #                     SYMTAB: 0x000003ff80094ab0
42 #                       MSYM: 0x000003ff800842c0
43 #                      STRSZ: 40922.
44 #                     SYMENT: 24.
45 #                     PLTGOT: 0x000003ffc008f240
46 #                   SYMTABNO: 3330.
47 #               BASE_ADDRESS: 0x000003ff80080000
48 #                   HIPAGENO: 0.
49 #                      RELSZ: 15296.
50 #                     RELENT: 16.
51 #                        REL: 0x000003ff80080700
52 #                  LIBLISTNO: 0.
53 #                       INIT: 0x000003ff8019c520
54 #                       FINI: 0x000003ff8019c570
55 #                      FLAGS: 0x00000001
56 #
57
58 PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin
59 export PATH
60
61 for f in `cat -`
62 do
63         odump -D $f 2>/dev/null | awk '
64
65                 BEGIN { 
66                         FS = " ";
67                         RS = "\n";
68                         OFS = "";
69
70                         found_soname = 0;
71                         found_iversion = 0;
72
73                         #
74                         # what character should be used to separate the soname from any
75                         # version info?  Using a . is actually a bad idea, since some
76                         # free/3rd party libraries may be built so that the library
77                         # soname may have version info in it too.  If we use . as the
78                         # separator, it may not be possible to tell where the soname
79                         # ends and the internal version info begins.  It might be
80                         # better to use a - or a : here.  If you do so, be sure to
81                         # change this setting in find-requires, too.
82                         #
83                         soname_version_delimiter=".";
84                 }
85
86                 # Uncomment the next line for some debugging info.
87                 #{ print NR , ":", $0  }
88
89                 /^[      ]+SONAME: .*[  ]*$/ {
90                         found_soname = 1;
91                         numfields = split($0, internal_name)
92                         if (numfields == 2) {
93                                 soname = $2
94                                 #
95                                 # we should probably check to see if the soname ends with
96                                 # a number (indicating that it contains versioning info,
97                                 # possibly in addition to the versioning info in the versions
98                                 # field) and generate a warning here.  Shared libraries should
99                                 # not be built with version info in the soname on Digital Unix.
100                                 #
101                         } else {
102                                 #
103                                 # Should never be here.
104                                 #
105                                 print "Really odd looking soname:", $0 | "cat 1>&2"
106                                 exit
107                         }
108                 }
109
110                 /^[     ]+IVERSION: .*[         ]*$/ {
111                         if (found_soname == 1) {
112                                 numfields = split($0, iversion)
113                                 if (numfields == 2) {
114                                         version = $2
115                                         #
116                                         # handle libraries with multiple versions, like
117                                         # 1.1:1.2.  Since they really provide both versions,
118                                         # we need to generate output for each version.
119                                         #
120                                         numfields = split(version, versions, ":")
121                                         if (numfields > 1) {
122                                                 for (i = 1; i < numfields; i++) {
123                                                         print soname, soname_version_delimiter, versions[i]
124                                                 }
125                                                 #
126                                                 # let our END routine print out the *last* version
127                                                 # provided
128                                                 #
129                                                 version = versions[numfields]
130                                         }
131                                         #
132                                         # stick a fork in us.
133                                         #
134                                         found_iversion = 1;
135                                         exit
136                                 } else {
137                                         #
138                                         # Should never be here.
139                                         #
140                                         print "Odd looking library version:", $0 | "cat 1>&2"
141                                         exit
142                                 }
143                         } else {
144                                 #
145                                 # found an iversion without an soname.  Is that possible?
146                                 #
147                                 print "Found version but no soname:", $0 | "cat 1>&2"
148                                 exit
149                         }
150                 }
151
152                 #
153                 # we could probably watch for some other token (like RLD_VERSION)
154                 # that *generally* occurs later in the input than the stuff we watch
155                 # for, and exit if we see it, but it is just as easy to read all
156                 # the output, even after we have seen what we are looking for.
157                 #
158
159                 END {
160                         # Uncomment the next line for debugging info
161                         #{ print "END: NR: ", NR }
162                         if ( (found_soname == 1) && (found_iversion == 1) ) {
163                                 print soname, soname_version_delimiter, version
164                                 exit
165                         } else if (found_soname == 1) {
166                                 #
167                                 # no library version information
168                                 #
169                                 print soname
170                         }
171                         # else do nothing
172                 }
173         ' # end of awk
174 done | sort -u
175 #comment out the previous line and uncomment the next line when debugging
176 #done