PageRenderTime 21ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/rpm-4.10.0/autodeps/irix6.req

#
Korn Shell | 164 lines | 74 code | 12 blank | 78 comment | 5 complexity | 051ed25dffb14a34f09e99a210dcea35 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.req,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-requires is part of RPM, the Red Hat Package Manager. find-requires
  8. # reads a list of full pathnames (in a package) on stdin, and outputs all
  9. # shared libraries the package requires to execute.
  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 -Dl' to find what libraries are required by
  18. # an executable. `elfdump -L' does what we need too, but it gives us more
  19. # than we really need.
  20. #
  21. # Example `elfdump -Dl' output:
  22. #
  23. #$elfdump -Dl /usr/bin/X11/xterm
  24. #
  25. #
  26. #
  27. #/usr/bin/X11/xterm:
  28. #
  29. # **** MIPS LIBLIST INFORMATION ****
  30. #.liblist :
  31. #[INDEX] Timestamp Checksum Flags Name Version
  32. #[1] Nov 23 15:39:02 1997 0x4da65893 ----- libXaw.so.2 sgi2.0
  33. #[2] Nov 23 15:39:02 1997 0x414eece6 ----- libXmu.so sgi1.0
  34. #[3] Nov 23 15:39:02 1997 0x6f314e69 ----- libXt.so sgi1.0
  35. #[4] Nov 23 15:39:02 1997 0xcbe81fff ----- libXext.so sgi1.0
  36. #[5] Nov 23 15:39:02 1997 0x89ae8e98 ----- libX11.so.1 sgi1.0
  37. #[6] Oct 27 01:00:29 1997 0x99b27890 ----- libcurses.so sgi1.0
  38. #[7] Jun 16 18:23:15 1997 0x92321a0c ----- libc.so.1 sgi1.0
  39. #
  40. #
  41. # TVM: it might be better to re-write this so that `file' isn't used, since
  42. # it can all be done with `elfdump', but this works.
  43. #
  44. PATH=/usr/bin:/usr/sbin
  45. export PATH
  46. #
  47. # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
  48. # like `file', et. al. and expect the output to be what we see in the
  49. # C/POSIX locale. Make sure it is so.
  50. #
  51. LANG=C
  52. export LANG
  53. #
  54. # TVM: switch to using `while read ...' instead of `for f in ...', because
  55. # packages with a large number of files could be too big for one shell
  56. # variable to hold.
  57. #
  58. IFS=""
  59. while read f
  60. do
  61. #
  62. # Uncomment the next line for additional debugging:
  63. #echo "read ->$f<-"
  64. #
  65. # Only run file once per file:
  66. #
  67. file_output=`file $f`
  68. #
  69. # Handle scripts first
  70. #
  71. is_shell_script=`echo "$file_output" | grep 'script text' | \
  72. cut -d: -f 2 | awk '{ print $1 }'`
  73. #
  74. # If it's a script...
  75. #
  76. if test X"$is_shell_script" != X ; then
  77. echo "$is_shell_script"
  78. #
  79. # use `continue' to skip back up to the top of the loop. We've
  80. # already done as much as we need to, and this saves me from having
  81. # to have an else, and another indent level... ;-)
  82. #
  83. continue
  84. fi
  85. #
  86. # the `else' is implied here, since we used `continue' in the test above
  87. #
  88. #
  89. # It might be a shared library.
  90. #
  91. maybe_shared_lib=`echo "$file_output" | grep -E 'executable|lib'`
  92. if test X"$maybe_shared_lib" != X ; then
  93. elfdump -Dl $f 2>/dev/null \
  94. | awk '
  95. #
  96. # Since this entire awk script is enclosed in single quotes,
  97. # you need to be careful to not use single quotes, even in awk
  98. # comments, if you modify this script.
  99. #
  100. BEGIN {
  101. found_column_headers = 0;
  102. FS = " ";
  103. RS = "\n";
  104. OFS="";
  105. }
  106. # uncomment the next line for debugging information
  107. #{ print "Saw input:", $0 }
  108. found_column_headers == 1 && $0 !~ /^$/ {
  109. # get the library name (field 15) and the library version (field 16)
  110. # if present.
  111. numfields = split($0,fields)
  112. if (numfields == 8) {
  113. print fields[8]
  114. } else if (numfields == 9) {
  115. #
  116. print fields[8], "(", fields[9], ")"
  117. } else if (numfields > 9) {
  118. #
  119. # SGI has this annoying habit of putting comments, complete
  120. # with whitespace, in their library IVERSION field. Yuck.
  121. #
  122. # Handle libraries like this gracefully.
  123. #
  124. verfields = split(fields[NF], junk, "#")
  125. if (verfields == 2) {
  126. print fields[8], "(", junk[2], ")"
  127. } else if (verfields > 2) {
  128. print fields[8], "(", junk[verfields], ")"
  129. } else {
  130. print "Cannot find version:", fields[numfields] | "cat 2>&1"
  131. }
  132. }
  133. }
  134. /^\[INDEX\].Timestamp.*Checksum.*Flags.*Name.*Version$/ {
  135. # we better start paying attention now.
  136. found_column_headers = 1
  137. #
  138. # uncomment the next line for debugging information
  139. #print "found the column headers: ", $0
  140. }
  141. ' # end of awk
  142. fi
  143. done | sort -u
  144. # comment out the previous line and uncomment the next when debugging
  145. #done