3 # Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
4 # $Id: hpux.prov,v 1.8 2001/09/15 13:49:11 jbj Exp $
6 # This file is distributed under the terms of the GNU Public License
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.
13 # On HP-UX, use `chatr' to find what libraries a package provides
15 # Example chatr output:
17 #$chatr /usr/lib/libc.sl
21 # shared library dynamic path search:
22 # SHLIB_PATH disabled second
23 # embedded path disabled first Not Defined
26 # shared library list:
27 # dynamic /usr/lib/libdld.1
28 # static branch prediction disabled
29 # kernel assisted branch predictionenabled
30 # lazy swap allocationdisabled
31 # text segment lockingdisabled
32 # data segment lockingdisabled
34 # instruction page size: 4K
38 # Implementation notes: some of the system libraries are built without an
39 # `internal name' (HP-UX's equivalent to a SONAME), so I need to track what
40 # chatr outputs as its first line. We'll use the basename of that line in
41 # the event of no internal name.
44 PATH=/usr/bin:/usr/sbin:/usr/ccs/bin
48 # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
49 # like `file', et. al. and expect the output to be what we see in the
50 # C/POSIX locale. Make sure it is so.
56 # TVM: use `while read ...' instead of `for f in ...', because there may
57 # be too many files to stuff into one shell variable.
62 # It's possible that I should be testing to make sure that the file
63 # we're trying isn't a symlink, and skipping it if it is, because of
64 # the possible odd situation where we could have a link to a library
65 # with no internal name. This would need more investigation, though.
66 chatr $f 2>/dev/null \
73 # This flag signfies that we have seen the internal name:
74 # marker. Once we see that, we set the flag to 1. The next
75 # line we read should contain the library internal name, the
76 # SOM equivalent of an soname. At that point we set the flag
77 # found_internal_name to 1 and exit
78 # the main body of the awk script, going through the END
82 # We have seen the internal name: section (yet)?
84 found_internal_name = 0;
87 # assume it is a shared library, until record 2 proves us wrong.
89 isa_shared_library = 1;
92 # Uncomment the next line for some debugging info.
93 #{ print NR , ":", $0 }
96 # save the first line in case there is no internal name built
101 opened_something = 1;
105 # Check the second line (record). Clear the flag if it is not a
108 NR == 2 && $0 !~ /^[ ]+shared library[ ]*$/ {
109 # It is not a shared library. Bow out early
110 isa_shared_library = 0;
114 in_internal_name == 1 {
116 # We found the library internal name. If it does not contain
117 # a path, print it. At least a couple of the system libraries
118 # have a full path as the internal name (this is probably a bug).
121 numfields = split($0, internal_name, "/")
122 print internal_name[numfields]
128 # Set a flag for the EXIT section, to indicate that we found
131 found_internal_name = 1;
137 # we have hit the internal name section. Set the flag. The next
138 # line should be what we are looking for.
140 /^ +internal name: *$/ {
145 # Uncomment the next line for debugging info
146 #{ print "END: NR: ", NR }
147 if ( (isa_shared_library == 0) || (NR < 2) ) {
148 # both of these indicate error conditions, for which we
149 # should not generate any output.
152 if (found_internal_name == 1) {
156 # chop the : off the end of the line
158 colon = index(my_name, ":")
160 temp = substr(my_name, 1, colon)
164 numfields = split(temp, basename, "/")
165 # Uncomment the next line for debugging info
166 #print "In END:", numfields, ":", temp
167 print basename[numfields]
174 #comment out the previous line and uncomment the next line when debugging