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
|
#! /usr/bin/ksh
# Original Author: Tim Mooney (mooney@plains.nodak.edu)
# $Id: hpux.prov,v 1.5 1999/09/30 00:22:15 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.
#
#
# On HP-UX, use `chatr' to find what libraries a package provides
#
# Example chatr output:
#
#$chatr /usr/lib/libc.sl
#
#/usr/lib/libc.sl:
# shared library
# shared library dynamic path search:
# SHLIB_PATH disabled second
# embedded path disabled first Not Defined
# internal name:
# libc.1
# shared library list:
# dynamic /usr/lib/libdld.1
# static branch prediction disabled
# kernel assisted branch predictionenabled
# lazy swap allocationdisabled
# text segment lockingdisabled
# data segment lockingdisabled
# data page size: 4K
# instruction page size: 4K
#
PATH=/usr/bin:/usr/sbin:/usr/ccs/bin
export PATH
#
# TVM: 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
chatr $f 2>/dev/null \
| awk '
BEGIN {
FS = " ";
RS = "\n";
in_internal_name = 0;
#
# We have seen the internal name: section (yet)?
#
found_internal_name = 0;
#
# assume it is a shared library, until record 2 proves us wrong.
#
isa_shared_library = 1;
}
# Uncomment the next line for some debugging info.
#{ print NR , ":", $0 }
#
# save the first line in case there is no internal name built
# into this object.
#
NR == 1 {
my_name = $0
opened_something = 1;
}
#
# Check the second line (record). Clear the flag if it is not a
# shared library.
#
NR == 2 && $0 !~ /^[ ]+shared library[ ]*$/ {
# It is not a shared library. Bow out early
isa_shared_library = 0;
exit
}
#
# If we see this, we know we have passed all the information we care
# about, so exit.
#
/^ +shared library list: *$/ || /^ +static branch prediction/ {
in_internal_name = 0
exit
}
in_internal_name == 1 {
# We found the library internal name. If it does not contain
# a path, print it. At least a couple of the system libraries
# have a full path as the internal name (this is probably a bug).
if ( $0 ~ /\// ) {
numfields = split($0, internal_name, "/")
print internal_name[numfields]
} else {
print $1
}
#
# Set a flag for the EXIT section, to indicate that we found
# an internal name
#
found_internal_name = 1;
}
#
# we have hit the internal name section. Set the flag
#
/^ +internal name: *$/ {
in_internal_name = 1
}
END {
# Uncomment the next line for debugging info
#{ print "END: NR: ", NR }
if ( (isa_shared_library == 0) || (NR < 2) ) {
# both of these indicate error conditions, for which we
# should not generate any output.
exit;
} else {
if (found_internal_name == 1) {
exit;
} else {
#
# chop the : off the end of the line
#
colon = index(my_name, ":")
colon = colon - 1
temp = substr(my_name, 1, colon)
#
# get the basename
#
numfields = split(temp, basename, "/")
# Uncomment the next line for debugging info
#print "In END:", numfields, ":", temp
print basename[numfields]
exit
}
}
}
' # end of awk
done | sort -u
#comment out the previous line and uncomment the next line when debugging
#done
|