PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/rpm-4.10.0/autodeps/irix6.prov

#
Korn Shell | 201 lines | 120 code | 4 blank | 77 comment | 3 complexity | e619763042fa76ca4aceeec936afa2c1 MD5 | raw file
Possible License(s): LGPL-2.0
  1. #! /usr/bin/ksh
  2. # Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
  3. # $Id: irix6.prov,v 1.7 2001/09/15 13:49:11 jbj Exp $
  4. #
  5. # This file is distributed under the terms of the GNU Public License
  6. #
  7. # find-provides is part of RPM, the Red Hat Package Manager. find-provides
  8. # reads a list of full pathnames (in a package) on stdin, and outputs all
  9. # shared libraries provided by (contained in) the package.
  10. #
  11. # NOTE: IRIX libraries (even system libraries) have "version information"
  12. # in both the soname and the internal version field, so it's important to
  13. # be able to separate the soname and internal version fields. As has
  14. # become the case on other platforms, the soname/iversion delimiters have
  15. # become the `(' and `)' characters.
  16. #
  17. # On IRIX, use `elfdump -L' to find what libraries a package provides
  18. #
  19. # Example `elfdump -L' output:
  20. #
  21. #$elfdump -L /usr/lib/libc.so
  22. #
  23. #
  24. #/usr/lib/libc.so:
  25. #
  26. # **** DYNAMIC SECTION INFORMATION ****
  27. #.dynamic :
  28. #[INDEX] Tag Value
  29. #[0] HASH 0xfa099d0
  30. #[1] STRTAB 0xfa0027c
  31. #[2] SYMTAB 0xfa10e3c
  32. #[3] STRSZ 0x9751
  33. #[4] SYMENT 0x10
  34. #[5] INIT 0
  35. #[6] FINI 0
  36. #[7] RLDVERS 0x1
  37. #[8] FLAGS 0x1411
  38. #[9] BASEADDR 0xfa00000
  39. #[10] LOCGOTNO 0x3c
  40. #[11] PROTECT 0x3c
  41. #[12] HIDDEN 0x12
  42. #[13] CNFLCTNO 0
  43. #[14] LBLISTNO 0
  44. #[15] SYMTABNO 0xd19
  45. #[16] UNREFEXT 0x8
  46. #[17] GOTSYM 0x8b3
  47. #[18] LOCAL 0x12
  48. #[19] LOCALPG 0x1
  49. #[20] LOCALPG 0x10
  50. #[21] PLTGOT 0xfb483b0
  51. #[22] RLDTXT_ADR0xfb6b580
  52. #[23] OPTIONS 0xfa000f4
  53. #[24] SONAME libc.so.1
  54. #[25] TIMSTAMP Jun 16 18:23:15 1997
  55. #[26] CHECKSUM 0x92321a0c
  56. #[27] IVERSION sgi1.0
  57. #[28] REL 0xfa1dfcc
  58. #[29] RELSZ 0x1988
  59. #[30] RELENT 0x8
  60. #[31] MSYM 0xfa1f954
  61. #[32] COMPCTSIZE0xc60c
  62. #No Library List Section in /usr/lib/libc.so
  63. #
  64. PATH=/usr/bin:/usr/sbin
  65. export PATH
  66. #
  67. # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
  68. # like `file', et. al. and expect the output to be what we see in the
  69. # C/POSIX locale. Make sure it is so.
  70. #
  71. LANG=C
  72. export LANG
  73. #
  74. # Use `while read ...' instead of `for f in ...', because there may be too
  75. # many files to stuff into one shell variable.
  76. #
  77. IFS=""
  78. while read f
  79. do
  80. #
  81. # If it's a shared library, run elfdump on it.
  82. #
  83. maybe_shared_lib=`file $f | grep -E 'ELF.*dynamic lib'`
  84. if test X"$maybe_shared_lib" != X ; then
  85. elfdump -L $f 2>/dev/null | awk '
  86. #
  87. # Since this entire awk script is enclosed in single quotes,
  88. # you need to be careful to not use single quotes, even in awk
  89. # comments, if you modify this script.
  90. #
  91. BEGIN {
  92. FS = " ";
  93. RS = "\n";
  94. OFS = "";
  95. found_soname = 0;
  96. found_iversion = 0;
  97. }
  98. # Uncomment the next line for some debugging info.
  99. #{ print NR , ":", $0 }
  100. /[ ]+SONAME .*[ ]*$/ {
  101. found_soname = 1;
  102. numfields = split($0, internal_name)
  103. if (numfields == 3) {
  104. soname = $3
  105. } else {
  106. #
  107. # Should never be here.
  108. #
  109. print "Really odd looking soname:", $0 | "cat 1>&2"
  110. exit
  111. }
  112. }
  113. /[ ]+IVERSION .*[ ]*$/ {
  114. if (found_soname == 1) {
  115. numfields = split($0, iversion)
  116. if (numfields == 3) {
  117. version = $3
  118. #
  119. # handle libraries with multiple versions, like
  120. # 1.1:1.2. Since they really provide both versions,
  121. # we need to generate output for each version.
  122. #
  123. numfields = split(version, versions, ":")
  124. if (numfields > 1) {
  125. for (i = 1; i < numfields; i++) {
  126. print soname, "(", versions[i], ")"
  127. }
  128. #
  129. # let our END routine print out the *last* version
  130. # provided
  131. #
  132. version = versions[numfields]
  133. }
  134. #
  135. # stick a fork in us.
  136. #
  137. found_iversion = 1;
  138. exit
  139. } else {
  140. #
  141. # handle libraries with comments and other junk in
  142. # the version field. IRIX has a number of system libraries
  143. # with whitespace and other junk in the version field!
  144. #
  145. # we discard the whitespace and keep the identifier after
  146. # the # sign.
  147. #
  148. version = iversion[numfields]
  149. numfields = split(version, version_junk, "#")
  150. if (numfields > 1) {
  151. version = version_junk[numfields]
  152. found_iversion = 1;
  153. }
  154. }
  155. } else {
  156. #
  157. # found an iversion without an soname. Is that possible?
  158. #
  159. print "Found version but no soname:", $0 | "cat 1>&2"
  160. exit
  161. }
  162. }
  163. #
  164. # we could probably watch for some other token (like RELSZ)
  165. # that *generally* occurs later in the input than the stuff we watch
  166. # for, and exit if we see it, but it is just as easy to read all
  167. # the output, even after we have seen what we are looking for.
  168. #
  169. END {
  170. # Uncomment the next line for debugging info
  171. #{ print "END: NR: ", NR }
  172. if ( (found_soname == 1) && (found_iversion == 1) ) {
  173. print soname, "(", version, ")"
  174. exit
  175. } else if ( (found_soname == 1) && (found_iversion == 0) ) {
  176. #
  177. # no library version information *BUT* any programs linked
  178. # against this library will pick up a dependency on version 0
  179. # of this library, so we output that.
  180. #
  181. print soname, "(", 0, ")"
  182. }
  183. # else do nothing
  184. }
  185. ' # end of awk
  186. fi # end of the 'if test X"$maybe_shared_lib != X ; then' clause
  187. done | sort -u
  188. #comment out the previous line and uncomment the next line when debugging
  189. #done