summaryrefslogtreecommitdiff
path: root/autodeps/irix6.prov
blob: 87ee4e1a135ca18c4bebae6990ae58f4a05ac85a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#! /usr/bin/ksh

# Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
# $Id: irix6.prov,v 1.7 2001/09/15 13:49:11 jbj Exp $
#
# This file is distributed under the terms of the GNU Public License
#
# find-provides is part of RPM, the Red Hat Package Manager.  find-provides
# reads a list of full pathnames (in a package) on stdin, and outputs all
# shared libraries provided by (contained in) the package.
#
# NOTE: IRIX libraries (even system libraries) have "version information"
# in both the soname and the internal version field, so it's important to
# be able to separate the soname and internal version fields.  As has
# become the case on other platforms, the soname/iversion delimiters have
# become the `(' and `)' characters.
#
# On IRIX, use `elfdump -L' to find what libraries a package provides
#
# Example `elfdump -L' output:
#
#$elfdump -L /usr/lib/libc.so
#
#
#/usr/lib/libc.so:
#
#  **** DYNAMIC SECTION INFORMATION ****
#.dynamic :
#[INDEX]	Tag	 Value
#[0]	HASH     0xfa099d0
#[1]	STRTAB   0xfa0027c
#[2]	SYMTAB   0xfa10e3c
#[3]	STRSZ    0x9751
#[4]	SYMENT   0x10
#[5]	INIT     0
#[6]	FINI     0
#[7]	RLDVERS  0x1
#[8]	FLAGS    0x1411
#[9]	BASEADDR 0xfa00000
#[10]	LOCGOTNO 0x3c
#[11]	PROTECT  0x3c
#[12]	HIDDEN   0x12
#[13]	CNFLCTNO 0
#[14]	LBLISTNO 0
#[15]	SYMTABNO 0xd19
#[16]	UNREFEXT 0x8
#[17]	GOTSYM   0x8b3
#[18]	LOCAL    0x12
#[19]	LOCALPG  0x1
#[20]	LOCALPG  0x10
#[21]	PLTGOT   0xfb483b0
#[22]	RLDTXT_ADR0xfb6b580
#[23]	OPTIONS  0xfa000f4
#[24]	SONAME   libc.so.1
#[25]	TIMSTAMP Jun 16 18:23:15 1997	
#[26]	CHECKSUM 0x92321a0c
#[27]	IVERSION sgi1.0
#[28]	REL      0xfa1dfcc
#[29]	RELSZ    0x1988
#[30]	RELENT   0x8
#[31]	MSYM     0xfa1f954
#[32]	COMPCTSIZE0xc60c
#No Library List Section in /usr/lib/libc.so
#

PATH=/usr/bin:/usr/sbin
export PATH

#
# TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
# like `file', et. al. and expect the output to be what we see in the
# C/POSIX locale.  Make sure it is so.
#
LANG=C
export LANG

#
# Use `while read ...' instead of `for f in ...', because there may be too
# many files to stuff into one shell variable.
#
IFS=""
while read f
do
	#
	# If it's a shared library, run elfdump on it.
	#
	maybe_shared_lib=`file $f | grep -E 'ELF.*dynamic lib'` 
	if test X"$maybe_shared_lib" != X ; then
		elfdump -L $f 2>/dev/null | awk '

		#
		# Since this entire awk script is enclosed in single quotes,
		# you need to be careful to not use single quotes, even in awk
		# comments, if you modify this script.
		#

		BEGIN { 
			FS = " ";
			RS = "\n";
			OFS = "";

			found_soname = 0;
			found_iversion = 0;
		}

		# Uncomment the next line for some debugging info.
		#{ print NR , ":", $0  }

		/[	 ]+SONAME .*[ 	]*$/ {
			found_soname = 1;
			numfields = split($0, internal_name)
			if (numfields == 3) {
				soname = $3
			} else {
				#
				# Should never be here.
				#
				print "Really odd looking soname:", $0 | "cat 1>&2"
				exit
			}
		}

		/[ 	]+IVERSION .*[ 	]*$/ {
			if (found_soname == 1) {
				numfields = split($0, iversion)
				if (numfields == 3) {
					version = $3
					#
					# handle libraries with multiple versions, like
					# 1.1:1.2.  Since they really provide both versions,
					# we need to generate output for each version.
					#
					numfields = split(version, versions, ":")
					if (numfields > 1) {
						for (i = 1; i < numfields; i++) {
							print soname, "(", versions[i], ")"
						}
						#
						# let our END routine print out the *last* version
						# provided
						#
						version = versions[numfields]
					}
					#
					# stick a fork in us.
					#
					found_iversion = 1;
					exit
				} else {
					#
					# handle libraries with comments and other junk in
					# the version field.  IRIX has a number of system libraries
					# with whitespace and other junk in the version field!
					#
					# we discard the whitespace and keep the identifier after
					# the # sign.
					#
					version = iversion[numfields]
					numfields = split(version, version_junk, "#")
					if (numfields > 1) {
						version = version_junk[numfields]
						found_iversion = 1;
					}
				}
			} else {
				#
				# found an iversion without an soname.  Is that possible?
				#
				print "Found version but no soname:", $0 | "cat 1>&2"
				exit
			}
		}

		#
		# we could probably watch for some other token (like RELSZ)
		# that *generally* occurs later in the input than the stuff we watch
		# for, and exit if we see it, but it is just as easy to read all
		# the output, even after we have seen what we are looking for.
		#

		END {
			# Uncomment the next line for debugging info
			#{ print "END: NR: ", NR }
			if ( (found_soname == 1) && (found_iversion == 1) ) {
				print soname, "(", version, ")"
				exit
			} else if ( (found_soname == 1) && (found_iversion == 0) ) {
				#
				# no library version information *BUT* any programs linked
				# against this library will pick up a dependency on version 0
				# of this library, so we output that.
				#
				print soname, "(", 0, ")"
			}
			# else do nothing
		}
	' # end of awk
	fi # end of the 'if test X"$maybe_shared_lib != X ; then' clause
done | sort -u
#comment out the previous line and uncomment the next line when debugging
#done