3 # Current Maintainer: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
5 # Original Author: Ralph Goers(rgoer@Candle.Com)
6 # Borrowed heavily from H10 version created by Tim Mooney.
7 # This file is distributed under the terms of the GNU Public License
9 # find-provides is part of RPM, the RedHat Package Manager. find-provides
10 # reads a list of full pathnames (in a package) on stdin, and outputs all
11 # shared libraries provided by (contained in) the package.
13 # On AIX, use `dump -o' to find what the library provides, if anything.
18 # Executables are skipped because, by convention, shared libraries
19 # which are not dynamically loaded are packaged as archives. Also,
20 # it is impossible to tell the difference between an executable
21 # program and a dynamically loaded shared library.
23 # Because archives can contain any number of things, including
24 # apparently, multiple shared libraries, dependencies in archives
25 # will be specified as file[member]. Any member in an archive which
26 # has a loader section will be listed as provided.
28 # Tim's (subsequent) comments:
30 # Based on discussions on the rpm-list in mid-March of 2000, I've modified
31 # the copy of find-provides that Ralph provided me to use `dump -o' instead
32 # of `dump -H', and I've followed Brandon S. Allbery's suggestions and modified
33 # the awk script to look for a modtype of `RE', which is what constitutes a
34 # shared member of a library. Just like everything else on AIX, libraries are
37 # I've followed Ralph's convention of generating provides in the form of
38 # `filebasename(member-object)' *if* there is a member object, or just
39 # `filebasename' if there isn't (such as in the case of certain perl modules,
40 # locally built shared libraries, etc.).
42 # Example dump output:
44 #$dump -o /usr/lpp/X11/lib/R6/libX11.a
46 #/usr/lpp/X11/lib/R6/libX11.a[shr4.o]:
48 # ***Object Module Header***
49 ## Sections Symbol Ptr # Symbols Opt Hdr Len Flags
50 # 4 0x00126c28 14557 72 0x3002
51 #Timestamp = 920377624
54 # ***Optional Header***
55 #Tsize Dsize Bsize Tstart Dstart
56 #0x000bcc20 0x00024bd4 0x00000e0c 0x00000000 0x00000000
58 #SNloader SNentry SNtext SNtoc SNdata
59 #0x0004 0x0000 0x0001 0x0002 0x0002
61 #TXTalign DATAalign TOC vstamp entry
62 #0x0005 0x0003 0x00023d74 0x0001 0xffffffff
64 #maxSTACK maxDATA SNbss magic modtype
65 #0x00000000 0x00000000 0x0003 0x010b RE
67 #/usr/lpp/X11/lib/R6/libX11.a[shr4net.o]:
69 # ***Object Module Header***
70 ## Sections Symbol Ptr # Symbols Opt Hdr Len Flags
71 # 7 0x000006fb 22 72 0x3002
72 #Timestamp = 774732998
75 # ***Optional Header***
76 #Tsize Dsize Bsize Tstart Dstart
77 #0x00000084 0x00000088 0x00000000 0x00000200 0x00000000
79 #SNloader SNentry SNtext SNtoc SNdata
80 #0x0007 0x0000 0x0002 0x0004 0x0004
82 #TXTalign DATAalign TOC vstamp entry
83 #0x0002 0x0003 0x00000080 0x0001 0xffffffff
85 #maxSTACK maxDATA SNbss magic modtype
86 #0x00000000 0x00000000 0x0005 0x010b RE
88 PATH=/usr/bin:/usr/ccs/bin
92 # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
93 # like `file', et. al. and expect the output to be what we see in the
94 # C/POSIX locale. Make sure it is so.
100 # TVM: Because AIX libraries don't have the equivalent of a SONAME, if you do
102 # ln -s /usr/lib/libc.a /tmp/libmy_libc_link.a
104 # and then link your program with `-L/tmp -lmy_libc_link', that's the name
105 # that will be recorded as the BASE in the Import File Strings area.
106 # This means we need to include "symbolic link" in the list of files to check
109 filelist=`sed "s/['\"]/\\\&/g" | xargs file \
110 | grep -E 'archive|executable|symbolic link' | cut -d: -f1`
115 # Uncomment the next line for some additional debugging info:
117 dump -o $f 2>/dev/null | awk '
119 # TVM: be careful to not use any single quotes, even in comments,
120 # since this entire awk script is enclosed in single quotes.
125 # our flag to indicate we found a filename[membername] or
127 found_file_or_member = 0
128 # our flag to indicate we found the modtype tag. If so,
129 # we want to look for RE on the next line.
132 # number of times gsub substituted, used twice below
136 # Uncomment the next line for some debugging info.
137 # { print NR , ":", $0 }
139 found_modtype == 1 && found_file_or_member == 1 {
142 # we have seen a filename, we have seen a modtype line, and now
143 # we know that the modtype is RE. Print out the member name.
145 # Note that member names generally look like foo[bar.o], and
146 # since the RPM standard has become to use parens, we will
147 # translate the [ and ] into ( and ) in the output stream.
148 # awk on AIX 4 has sub() and gsub(), so we can use them to do
149 # it. If this script is adapted for use on some other platform
150 # make sure that awk on that platform has sub/gsub. If not,
151 # you will need to postprocess the output stream (probably before
152 # the sort -u) with tr or sed.
153 nsub = gsub(/\[/, "(", member)
155 print "substituted too many times for [:", member | "cat 1>&2"
157 nsub = gsub(/\]/, ")", member)
159 print "substituted too many times for ]:", member | "cat 1>&2"
163 # In any case, reset our flags to zero, to indicate we are done
164 # with this member, so we are ready to handle additional members
166 found_file_or_member = 0
170 found_file_or_member == 1 && /magic *modtype/ {
171 # we have seen a filename, and now we have seen the modtype
172 # line. Set the found_modtype flag. The next line of input
173 # will be caught by the rule above, and we will print out
174 # the member if the modtype is RE.
179 numfields = split($0,fields, "/")
180 # chop off the trailing colon
181 fieldlen = length(fields[numfields])-1
182 member= substr(fields[numfields], 1, fieldlen)
183 # Set the flat to indicate we found a file or a file(member).
184 found_file_or_member = 1
188 #comment out the previous line and uncomment the next line when debugging