new find req/prov scripts for non-linux platforms (Tim Mooney).
[platform/upstream/rpm.git] / autodeps / irix6.prov
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney (mooney@plains.nodak.edu)
4 # $Id: irix6.prov,v 1.5 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-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 # NOTE: I use `:' as the delimiter (by default) between the library soname
13 # and any library version info.  This is because IRIX libraries (even
14 # system libraries) have "version information" in both the soname and the
15 # internal version field, so it's important to be able to separate those
16 # fields.  If we just used `.', we wouldn't know where the soname ends and
17 # the version infromation begins.
18 #
19 #
20 # On IRIX, use `elfdump -L' to find what libraries a package provides
21 #
22 # Example `elfdump -L' output:
23 #
24 #$elfdump -L /usr/lib/libc.so
25 #
26 #
27 #/usr/lib/libc.so:
28 #
29 #  **** DYNAMIC SECTION INFORMATION ****
30 #.dynamic :
31 #[INDEX]        Tag      Value
32 #[0]    HASH     0xfa099d0
33 #[1]    STRTAB   0xfa0027c
34 #[2]    SYMTAB   0xfa10e3c
35 #[3]    STRSZ    0x9751
36 #[4]    SYMENT   0x10
37 #[5]    INIT     0
38 #[6]    FINI     0
39 #[7]    RLDVERS  0x1
40 #[8]    FLAGS    0x1411
41 #[9]    BASEADDR 0xfa00000
42 #[10]   LOCGOTNO 0x3c
43 #[11]   PROTECT  0x3c
44 #[12]   HIDDEN   0x12
45 #[13]   CNFLCTNO 0
46 #[14]   LBLISTNO 0
47 #[15]   SYMTABNO 0xd19
48 #[16]   UNREFEXT 0x8
49 #[17]   GOTSYM   0x8b3
50 #[18]   LOCAL    0x12
51 #[19]   LOCALPG  0x1
52 #[20]   LOCALPG  0x10
53 #[21]   PLTGOT   0xfb483b0
54 #[22]   RLDTXT_ADR0xfb6b580
55 #[23]   OPTIONS  0xfa000f4
56 #[24]   SONAME   libc.so.1
57 #[25]   TIMSTAMP Jun 16 18:23:15 1997   
58 #[26]   CHECKSUM 0x92321a0c
59 #[27]   IVERSION sgi1.0
60 #[28]   REL      0xfa1dfcc
61 #[29]   RELSZ    0x1988
62 #[30]   RELENT   0x8
63 #[31]   MSYM     0xfa1f954
64 #[32]   COMPCTSIZE0xc60c
65 #No Library List Section in /usr/lib/libc.so
66 #
67
68 PATH=/usr/bin:/usr/sbin
69 export PATH
70
71 #
72 # Use `while read ...' instead of `for f in ...', because there may be too
73 # many files to stuff into one shell variable.
74 #
75 IFS=""
76 while read f
77 do
78         #
79         # If it's a shared library, run elfdump on it.
80         #
81         maybe_shared_lib=`file $f | egrep 'ELF.*dynamic lib'` 
82         if test X"$maybe_shared_lib" != X ; then
83                 elfdump -L $f 2>/dev/null | awk '
84
85                 BEGIN { 
86                         FS = " ";
87                         RS = "\n";
88                         OFS = "";
89
90                         # The character that should separate the soname from
91                         # the version information.  If you change this, you
92                         # should also change the same variable in the IRIX
93                         # find-requires script
94                         soname_version_delimiter=":"
95
96                         found_soname = 0;
97                         found_iversion = 0;
98                 }
99
100                 # Uncomment the next line for some debugging info.
101                 #{ print NR , ":", $0  }
102
103                 /[       ]+SONAME .*[   ]*$/ {
104                         found_soname = 1;
105                         numfields = split($0, internal_name)
106                         if (numfields == 3) {
107                                 soname = $3
108                         } else {
109                                 #
110                                 # Should never be here.
111                                 #
112                                 print "Really odd looking soname:", $0 | "cat 1>&2"
113                                 exit
114                         }
115                 }
116
117                 /[      ]+IVERSION .*[  ]*$/ {
118                         if (found_soname == 1) {
119                                 numfields = split($0, iversion)
120                                 if (numfields == 3) {
121                                         version = $3
122                                         #
123                                         # handle libraries with multiple versions, like
124                                         # 1.1:1.2.  Since they really provide both versions,
125                                         # we need to generate output for each version.
126                                         #
127                                         numfields = split(version, versions, ":")
128                                         if (numfields > 1) {
129                                                 for (i = 1; i < numfields; i++) {
130                                                         print soname, soname_version_delimiter, versions[i]
131                                                 }
132                                                 #
133                                                 # let our END routine print out the *last* version
134                                                 # provided
135                                                 #
136                                                 version = versions[numfields]
137                                         }
138                                         #
139                                         # stick a fork in us.
140                                         #
141                                         found_iversion = 1;
142                                         exit
143                                 } else {
144                                         #
145                                         # handle libraries with comments and other junk in
146                                         # the version field.  IRIX has a number of system libraries
147                                         # with whitespace and other junk in the version field!
148                                         #
149                                         # we discard the whitespace and keep the identifier after
150                                         # the # sign.
151                                         #
152                                         version = iversion[numfields]
153                                         numfields = split(version, version_junk, "#")
154                                         if (numfields > 1) {
155                                                 version = version_junk[numfields]
156                                                 found_iversion = 1;
157                                         }
158                                 }
159                         } else {
160                                 #
161                                 # found an iversion without an soname.  Is that possible?
162                                 #
163                                 print "Found version but no soname:", $0 | "cat 1>&2"
164                                 exit
165                         }
166                 }
167
168                 #
169                 # we could probably watch for some other token (like RELSZ)
170                 # that *generally* occurs later in the input than the stuff we watch
171                 # for, and exit if we see it, but it is just as easy to read all
172                 # the output, even after we have seen what we are looking for.
173                 #
174
175                 END {
176                         # Uncomment the next line for debugging info
177                         #{ print "END: NR: ", NR }
178                         if ( (found_soname == 1) && (found_iversion == 1) ) {
179                                 print soname, soname_version_delimiter, version
180                                 exit
181                         } else if ( (found_soname == 1) && (found_iversion == 0) ) {
182                                 #
183                                 # no library version information *BUT* any programs linked
184                                 # against this library will pick up a dependency on version 0
185                                 # of this library, so we output that.
186                                 #
187                                 print soname, soname_version_delimiter, 0
188                         }
189                         # else do nothing
190                 }
191         ' # end of awk
192         fi # end of the 'if test X"$maybe_shared_lib != X ; then' clause
193 done | sort -u
194 #comment out the previous line and uncomment the next line when debugging
195 #done