1998-03-24 00:26:10 +08:00
|
|
|
#! /usr/bin/ksh
|
|
|
|
|
2000-12-03 00:52:14 +08:00
|
|
|
# Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
|
2001-09-15 21:49:11 +08:00
|
|
|
# $Id: hpux.req,v 1.7 2001/09/15 13:49:11 jbj Exp $
|
1998-05-26 21:28:48 +08:00
|
|
|
#
|
1999-09-30 08:22:15 +08:00
|
|
|
# This file is distributed under the terms of the GNU Public License
|
1998-03-24 00:26:10 +08:00
|
|
|
#
|
1998-05-26 21:28:48 +08:00
|
|
|
# find-requires is part of RPM, the Red Hat Package Manager. find-requires
|
1998-03-24 00:26:10 +08:00
|
|
|
# reads a list of full pathnames (in a package) on stdin, and outputs all
|
|
|
|
# shared libraries the package requires to run correctly.
|
|
|
|
#
|
|
|
|
# On HP-UX, use `chatr' to find the library dependencies for an executable
|
|
|
|
#
|
|
|
|
# Example chatr output:
|
|
|
|
#
|
|
|
|
#$chatr /usr/bin/chatr
|
|
|
|
#/usr/bin/chatr:
|
|
|
|
# shared executable
|
|
|
|
# shared library dynamic path search:
|
|
|
|
# SHLIB_PATH disabled second
|
|
|
|
# embedded path disabled first Not Defined
|
|
|
|
# internal name:
|
|
|
|
# chatr
|
|
|
|
# shared library list:
|
|
|
|
# dynamic /usr/lib/libc.1
|
|
|
|
# shared library binding:
|
|
|
|
# deferred
|
|
|
|
# static branch prediction disabled
|
|
|
|
# kernel assisted branch predictionenabled
|
|
|
|
# lazy swap allocationdisabled
|
|
|
|
# text segment lockingdisabled
|
|
|
|
# data segment lockingdisabled
|
|
|
|
# data page size: 4K
|
|
|
|
# instruction page size: 4K
|
|
|
|
|
1998-05-26 21:28:48 +08:00
|
|
|
PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin
|
|
|
|
export PATH
|
|
|
|
|
2000-12-03 00:52:14 +08:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
1999-09-30 08:22:15 +08:00
|
|
|
IFS=""
|
|
|
|
while read f
|
1998-03-24 00:26:10 +08:00
|
|
|
do
|
1998-05-26 21:28:48 +08:00
|
|
|
# uncomment the next line if debugging
|
|
|
|
# echo "### processing $f"
|
|
|
|
|
1999-09-30 08:22:15 +08:00
|
|
|
#
|
|
|
|
# Only run the file command once per file:
|
|
|
|
#
|
|
|
|
file_output=`file $f`
|
|
|
|
|
|
|
|
#
|
|
|
|
# First, check to see if it's a script, and try figure out what
|
|
|
|
# intpreter it requires. This is more work on HP-UX, since `file'
|
|
|
|
# doesn't tell us what interpreter the script uses, or even if it
|
|
|
|
# really is a script.
|
|
|
|
#
|
|
|
|
is_shell_script=`od -N 2 -t c $f 2>/dev/null | grep '0000000 # !'`
|
|
|
|
if test X"$is_shell_script" != X ; then
|
|
|
|
#
|
|
|
|
# it's a shell script. Now figure out what interpreter it needs
|
|
|
|
# Look at me! I'm good with sed. ;-)
|
|
|
|
interp=`head -1 $f | sed -e 's/^#! \{0,1\}\([^ ]*\).*$/\1/'`
|
|
|
|
if test X"$interp" != X ; then
|
|
|
|
echo "$interp"
|
|
|
|
#
|
|
|
|
# We've found what we need for this file. Skip back to the
|
|
|
|
# top of the loop. This saves me an `else' and another indent
|
|
|
|
# level! ;-)
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# The `else' is implied here by the `continue' above
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Is it a shared library?
|
|
|
|
#
|
|
|
|
maybe_shared_lib=`echo "$file_output" | egrep '(executable|library)'`
|
|
|
|
if test X"$maybe_shared_lib" != X ; then
|
|
|
|
chatr $f 2>/dev/null \
|
|
|
|
| awk '
|
1998-03-24 00:26:10 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# For you non-awk-ers, no single quotes in comments -- the shell
|
|
|
|
# sees them and things get hosed.
|
|
|
|
#
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
in_shlib_list = 0;
|
|
|
|
FS = " ";
|
|
|
|
RS = "\n";
|
|
|
|
}
|
|
|
|
|
1998-05-26 21:28:48 +08:00
|
|
|
# uncomment the next line for debugging information
|
|
|
|
#{ print NR, ": ", $0 }
|
|
|
|
|
|
|
|
|
1998-06-15 00:03:14 +08:00
|
|
|
in_shlib_list == 1 && /dynamic[ ]+[\/\.]/ {
|
1998-03-24 00:26:10 +08:00
|
|
|
|
|
|
|
# split the line on "/" and print out the last element
|
|
|
|
numfields = split($0,fields,"/")
|
|
|
|
print fields[numfields]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/^ +shared library list: *$/ {
|
|
|
|
in_shlib_list = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
/^ +shared library binding: *$/ {
|
|
|
|
exit
|
|
|
|
}
|
1999-09-30 08:22:15 +08:00
|
|
|
' # end of awk
|
|
|
|
fi # end of shared library if.
|
1998-03-24 00:26:10 +08:00
|
|
|
done | sort -u
|
1998-05-26 21:28:48 +08:00
|
|
|
#comment out the previous line and uncomment the next one if debugging.
|
|
|
|
#done
|