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