- merge sparc64/ia64 fiddles back into linux.{req,prov}.
[platform/upstream/rpm.git] / scripts / find-requires.perl
1 #!/bin/sh
2
3 # note this works for both a.out and ELF executables
4 # it also auto-generates requirment lines for shell scripts
5
6 ulimit -c 0
7
8 filelist=`sed "s/['\"]/\\\&/g"`
9 scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) " | cut -d: -f1 `
10
11 perllist=
12 for f in $scriptlist; do
13     [ -x $f ] || continue
14     interp=`head -1 $f | sed -e 's/^\#\![       ]*//' | cut -d" " -f1 `
15     case $interp in
16     */perl) perllist="$perllist $f" ;;
17     esac
18 done | sort -u
19
20 for f in $filelist; do
21     [ -r $f ] || continue
22     if echo $f | grep -q '\.pm$'
23     then
24         modules="$modules $f"
25     fi
26 done
27
28 [ -n "$modules" ] && perllist="$perllist $modules"
29
30 #
31 # Generate perl module dependencies, if any.
32 set -x
33 [ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \
34         echo $perllist | tr [:blank:] \\n | /usr/lib/rpm/perl.req | sort -u
35
36 #
37 # Then process the files as usual.
38 set +x
39 echo $filelist | /usr/lib/rpm/find-requires