*** empty log message ***
[platform/upstream/rpm.git] / autodeps / hpux.prov
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney (mooney@plains.nodak.edu)
4 # $Id: hpux.prov,v 1.3 1998/06/14 16:03:14 ewt 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 #
13 # On HP-UX, use `chatr' to find what libraries a package provides
14 #
15 # Example chatr output:
16 #
17 #$chatr /usr/lib/libc.sl
18 #
19 #/usr/lib/libc.sl: 
20 #         shared library 
21 #         shared library dynamic path search:
22 #             SHLIB_PATH     disabled  second 
23 #             embedded path  disabled  first  Not Defined
24 #         internal name:
25 #             libc.1
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
33 #         data page size: 4K
34 #         instruction page size: 4K
35 #
36
37 PATH=/usr/bin:/usr/sbin:/usr/ccs/bin
38 export PATH
39
40 for f in `cat -`
41 do
42         chatr $f 2>/dev/null | awk '
43
44                 BEGIN { 
45                         FS = " ";
46                         RS = "\n";
47
48                         in_internal_name = 0;
49
50                         #
51                         # We have seen the internal name: section (yet)?
52                         #
53                         found_internal_name = 0;
54
55                         #
56                         # assume it is a shared library, until record 2 proves us wrong.
57                         #
58                         isa_shared_library = 1;
59                 }
60
61                 # Uncomment the next line for some debugging info.
62                 #{ print NR , ":", $0  }
63
64                 #
65                 # save the first line in case there is no internal name built
66                 # into this object.
67                 #
68                 NR == 1 {
69                         my_name = $0
70                         opened_something = 1;
71                 }
72
73                 #
74                 # Check the second line (record).  Clear the flag if it is not a
75                 # shared library.
76                 #
77                 NR == 2 && $0 !~ /^[    ]+shared library[       ]*$/ {
78                         # It is not a shared library.  Bow out early
79                         isa_shared_library = 0;
80                         exit
81                 }
82
83                 #
84                 # If we see this, we know we have passed all the information we care
85                 # about, so exit.
86                 #
87                 /^ +shared library list: *$/ || /^ +static branch prediction/ {
88                         in_internal_name = 0
89                         exit
90                 }
91
92                 in_internal_name == 1 {
93                 
94                         # We found the library internal name.  If it does not contain
95                         # a path, print it.  At least a couple of the system libraries
96                         # have a full path as the internal name (this is probably a bug).
97
98                         if ( $0 ~ /\// ) {
99                                 numfields = split($0, internal_name, "/")
100                                 print internal_name[numfields]
101                         } else {
102                                 print $1
103                         }
104
105                         #
106                         # Set a flag for the EXIT section, to indicate that we found
107                         # an internal name
108                         #
109                         found_internal_name = 1;
110                 }
111
112                 #
113                 # we have hit the internal name section.  Set the flag
114                 #
115                 /^ +internal name: *$/ {
116                         in_internal_name = 1
117                 }
118
119                 END {
120                         # Uncomment the next line for debugging info
121                         #{ print "END: NR: ", NR }
122                         if ( (isa_shared_library == 0) || (NR < 2) ) {
123                                 # both of these indicate error conditions, for which we
124                                 # should not generate any output.
125                                 exit;
126                         } else {
127                                 if (found_internal_name == 1) {
128                                         exit;
129                                 } else {
130                                         #
131                                         # chop the : off the end of the line
132                                         #
133                                         colon = index(my_name, ":")
134                                         colon = colon - 1
135                                         temp = substr(my_name, 1, colon)
136                                         #
137                                         # get the basename
138                                         #
139                                         numfields = split(temp, basename, "/")
140                                         # Uncomment the next line for debugging info
141                                         #print "In END:",  numfields, ":", temp
142                                         print basename[numfields]
143                                         exit
144                                 }
145                         }
146                 }
147         ' # end of awk
148 done | sort -u
149 #comment out the previous line and uncomment the next line when debugging
150 #done