PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/rpm-4.10.0/autodeps/osf.req

#
Korn Shell | 142 lines | 60 code | 12 blank | 70 comment | 5 complexity | 1dc41e178929b32bd1459c4f87969b2f 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: osf.req,v 1.9 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. # On Digital/Tru64 Unix (OSF1), use `odump -Dl' to find the library
  12. # dependencies for an executable. `odump -D' does most of what we need,
  13. # but it doesn't give us library version information, so you must use
  14. # `odump -Dl'. Note that Tru64 5.x and on have `ldd', but this works just
  15. # as well, and works on older versions of the OS.
  16. #
  17. # Example `odump -Dl' output:
  18. #
  19. #$odump -Dl /usr/bin/X11/xterm
  20. #
  21. #
  22. #
  23. #
  24. # ***LIBRARY LIST SECTION***
  25. # Name Time-Stamp CheckSum Flags Version
  26. #/usr/bin/X11/xterm:
  27. # libXaw.so Dec 9 00:15:35 1997 0x285006d0 0 6.0
  28. # libXmu.so Dec 9 00:13:36 1997 0x3bf3a33d 0
  29. # libXt.so Dec 9 00:12:18 1997 0x10dd9a17 0
  30. # libSM.so Dec 9 00:08:11 1997 0xb64c7082 0
  31. # libICE.so Dec 9 00:07:52 1997 0x1199be32 0
  32. # libXext.so Dec 9 00:08:51 1997 0xafcb84d5 0
  33. # libX11.so Dec 9 00:06:05 1997 0xaa1bf091 0
  34. # libc.so Dec 8 18:41:11 1997 0x5e955f9b 0 osf.1
  35. PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin
  36. export PATH
  37. #
  38. # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
  39. # like `file', et. al. and expect the output to be what we see in the
  40. # C/POSIX locale. Make sure it is so.
  41. #
  42. LANG=C
  43. export LANG
  44. #
  45. # TVM: switch to using `while read ...' instead of `for f in ...', because
  46. # packages with a large number of files could be too big for one shell variable
  47. # to hold.
  48. #
  49. IFS=""
  50. while read f
  51. do
  52. #
  53. # Uncomment the next line for addtional debugging:
  54. # echo "read ->$f<-"
  55. #
  56. # Only run file once per file:
  57. #
  58. file_output=`file $f`
  59. #
  60. # handle shell scripts first
  61. #
  62. is_shell_script=`echo "$file_output" | grep 'shell script' | \
  63. cut -d: -f 2 | awk '{ print $1 }'`
  64. #
  65. # If it's a script...
  66. #
  67. if test X"$is_shell_script" != X ; then
  68. echo "$is_shell_script"
  69. #
  70. # use `continue' to skip back up to the top of the loop.
  71. # We have already done as much as we need to for this
  72. # file, and this saves me from having to have an else,
  73. # and another indent level... ;-)
  74. #
  75. continue
  76. fi
  77. #
  78. # The `else' here is implied by the `continue' above...
  79. #
  80. #
  81. # it might be a shared library.
  82. #
  83. maybe_shared_lib=`echo "$file_output" | grep 'executable'`
  84. if test X"$maybe_shared_lib" != X ; then
  85. odump -Dl $f 2>/dev/null \
  86. | awk '
  87. #
  88. # Since this entire awk script is enclosed in single quotes,
  89. # you need to be careful to not use single quotes, even in awk
  90. # comments, if you modify this script.
  91. #
  92. BEGIN {
  93. found_program_name = 0;
  94. FS = " ";
  95. RS = "\n";
  96. OFS="";
  97. }
  98. # uncomment the next line for debugging information
  99. #{ print "Saw input:", $0 }
  100. found_program_name == 1 && $0 !~ /^$/ {
  101. # uncomment for debugging information
  102. #print "found shared library: $0"
  103. # get the library name (field 1) and the library version
  104. # (field 8) if present.
  105. numfields = split($0,fields)
  106. if (numfields == 7) {
  107. print fields[1]
  108. } else if (numfields == 8) {
  109. print fields[1], "(", fields[8], ")"
  110. }
  111. }
  112. /^.*: *$/ {
  113. found_program_name = 1
  114. #
  115. # uncomment the next line for debugging information
  116. #print "found the program name: ", $1
  117. }
  118. ' # end of awk
  119. fi
  120. done | sort -u
  121. # comment out the previous line and uncomment the next when debugging
  122. # done