summaryrefslogtreecommitdiff
path: root/autodeps/osf.req
blob: c25a4eaade190e4b332a9a47c6d0fee8441aa820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#! /usr/bin/ksh

# Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
# $Id: osf.req,v 1.8 2000/12/02 16:52:14 jbj Exp $
#
# This file is distributed under the terms of the GNU Public License
#
# find-requires is part of RPM, the Red Hat Package Manager.  find-requires
# reads a list of full pathnames (in a package) on stdin, and outputs all
# shared libraries the package requires to execute.
#
# On Digital/Tru64 Unix (OSF1), use `odump -Dl' to find the library
# dependencies for an executable.  `odump -D' does most of what we need,
# but it doesn't give us library version information, so you must use
# `odump -Dl'.  Note that Tru64 5.x and on have `ldd', but this works just
# as well, and works on older versions of the OS.
#
# Example `odump -Dl' output:
#
#$odump -Dl /usr/bin/X11/xterm
# 
#
#
#
#			***LIBRARY LIST SECTION***
#	Name             Time-Stamp        CheckSum   Flags Version
#/usr/bin/X11/xterm:
#	libXaw.so    Dec  9 00:15:35 1997 0x285006d0     0 6.0
#	libXmu.so    Dec  9 00:13:36 1997 0x3bf3a33d     0 
#	libXt.so     Dec  9 00:12:18 1997 0x10dd9a17     0 
#	libSM.so     Dec  9 00:08:11 1997 0xb64c7082     0 
#	libICE.so    Dec  9 00:07:52 1997 0x1199be32     0 
#	libXext.so   Dec  9 00:08:51 1997 0xafcb84d5     0 
#	libX11.so    Dec  9 00:06:05 1997 0xaa1bf091     0 
#	libc.so      Dec  8 18:41:11 1997 0x5e955f9b     0 osf.1

PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin
export PATH

#
# TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
# like `file', et. al. and expect the output to be what we see in the
# C/POSIX locale.  Make sure it is so.
#
LANG=C
export LANG

#
# TVM: switch to using `while read ...' instead of `for f in ...', because
# packages with a large number of files could be too big for one shell variable
# to hold.
#
IFS=""
while read f
do

	#
	# Uncomment the next line for addtional debugging:
	# echo "read ->$f<-"

	#
	# Only run file once per file:
	#
	file_output=`file $f`

	#
	# handle shell scripts first
	#
	is_shell_script=`echo "$file_output" | grep 'shell script' | \
		cut -d: -f 2 | awk '{ print $1 }'`

	#
	# If it's a script...
	#
	if test X"$is_shell_script" != X ; then
		echo "$is_shell_script"
		#
		# use `continue' to skip back up to the top of the loop.
		# We have already done as much as we need to for this
		# file, and this saves me from having to have an else,
		# and another indent level... ;-)
		#
		continue
	fi

	#
	# The `else' here is implied by the `continue' above...
	#

	#
	# it might be a shared library.
	#

	maybe_shared_lib=`echo "$file_output" | grep 'executable'`
	if test X"$maybe_shared_lib" != X ; then

		odump -Dl $f 2>/dev/null \
		| awk '

			#
			# Since this entire awk script is enclosed in single quotes,
			# you need to be careful to not use single quotes, even in awk
			# comments, if you modify this script.
			#

			BEGIN { 
				found_program_name = 0;
				FS = " ";
				RS = "\n";
				OFS="";
			}

			# uncomment the next line for debugging information
			#{ print "Saw input:", $0 }

			found_program_name == 1 && $0 !~ /^$/ {

				# uncomment for debugging information
				#print "found shared library: $0"

				# get the library name (field 1) and the library version
				# (field 8) if present.
				numfields = split($0,fields)
				if (numfields == 7) {
					print fields[1]
				} else if (numfields == 8) {
					print fields[1], "(", fields[8], ")"
				}
			}

			/^.*: *$/ {
				found_program_name = 1
				#
				# uncomment the next line for debugging information
				#print "found the program name: ", $1
			}

		' # end of awk
	fi
done | sort -u
# comment out the previous line and uncomment the next when debugging
# done