3 # Original Author: Ralph Goers(rgoer@Candle.Com)
4 # Borrowed heavily from Tim Mooney's HP version.
5 # This file is distributed under the terms of the GNU General Public License
7 # find-requires is part of RPM, the RedHat 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 run correctly.
14 # On AIX Power, use `dump -H' to find the library dependencies
17 # Example dump output:
19 #$dump -H /usr/bin/dump
23 # ***Loader Section***
24 # Loader Header Information
25 #VERSION# #SYMtableENT #RELOCent LENidSTR
26 #0x00000001 0x00000021 0x0000006c 0x0000002f
28 ##IMPfilID OFFidSTR LENstrTBL OFFstrTBL
29 #0x00000002 0x00000848 0x00000049 0x00000877
32 # ***Import File Strings***
33 #INDEX PATH BASE MEMBER
34 #0 /usr/lib:/lib:/usr/lpp/xlC/lib
42 # Find the required symbols in executables and the required shells in
44 LANG=C /usr/bin/file $f | /usr/bin/grep -q -e ":.*shell script"
46 if [ $? -ne 0 ] # Use dump to examine executables
48 LANG=C /usr/bin/dump -H $f 2>/dev/null | awk '
51 # Since this entire awk script is enclosed in single quotes,
52 # you need to be careful to not use single quotes, even in awk
53 # comments, if you modify this script.
63 in_shlib_list == 1 && /^$/ {
70 numfields = split($0, fields, " ")
78 if (namevar < numfields) {
79 printf("%s(%s)\n", fields[namevar], fields[namevar+1])
82 if ((fields[namevar] != ".") && (fields[namevar] != "..")) {
88 in_file_strings == 1 && $1 == "0" {
92 /\*Import File Strings\*/ {
98 /usr/bin/head -1 $f | /usr/bin/sed -e 's/^\#\![ ]*//' | /usr/bin/cut -d" " -f1
106 # On AIX IA64, use `dump -Lv' to find the library dependencies
109 # Example dump output:
111 #$dump -Lv /usr/bin/dump
116 # **** DYNAMIC SECTION INFORMATION ****
120 #[1] NEEDED libC.so.1
121 #[2] NEEDED libelf.so
122 #[3] NEEDED /usr/lib/ia64l32/libc.so.1
126 #[7] STRTAB 0x10000914
127 #[8] SYMTAB 0x10000364
130 #[11] PLTGOT 0x20018994
131 #[12] PLT_RESERVE 0x20018a00
134 #[15] JMPREL 0x100024bc
143 # Find the required symbols in executables and the required shells in
145 LANG=C /usr/bin/file $f | /usr/bin/grep -q -e ":.*shell script"
147 if [ $? -ne 0 ] # Use dump to examine executables
149 LANG=C /usr/bin/dump -Lv $f 2>/dev/null | \
150 awk '$2=="NEEDED" {print $3}' | xargs -i basename {}
152 else # Extract the exec module from shell scripts
154 head -1 $f | sed -e 's/^\#\![ ]*//' | cut -d" " -f1
160 machinetype=`uname -m`
161 if [[ $machinetype = "ia64" ]]
163 /usr/bin/sed "s/['\"]/\\\&/g" | LANG=C /usr/bin/xargs /usr/bin/file | \
164 /usr/bin/grep -e ":.*executable" -e ":.*archive" -e ":.*shell script" | /usr/bin/cut -d: -f1 |
167 /usr/bin/sed "s/['\"]/\\\&/g" | LANG=C /usr/bin/xargs /usr/bin/file | \
168 /usr/bin/grep -e ":.*executable" -e ":.*archive" -e ":.*shell script" | /usr/bin/cut -d: -f1 |