blob: bdd7af5be3c160b6b47803f159b097934d08d634 (
plain)
1 #!/bin/bash
2 # Find dependency of files in /usr/lib and /usr/bin of a port by looking at
3 # the output of ldd
4 #
5 # Johannes Winkelmann <jw at tks6 dot net>
6 # awk stuff by Juergen Daubert <jue at jue dot li>
7
8 version=1.9.1
9 pkgdb="/var/lib/pkg/db"
10
11 export LD_LIBRARY_PATH=/lib:/usr/lib:/lib32:/usr/lib32:$LD_LIBRARY_PATH
12
13 function printDep() {
14 deps=()
15 files=(`awk -v p="$1" -v RS="" '$1==p' $pkgdb | awk '/(sbin|bin|lib|lib32|libexec)\//'`)
16 for f in ${files[*]}; do
17 if [ -f "/$f" ]; then
18 deps=(${deps[*]} `ldd /$f 2> /dev/null | awk '!/(linux-gate)|( dynamic)|(not found)/ {print $3}'`)
19 fi
20 done
21
22 deps=(`for t in ${deps[*]}; do realpath $t; done|sort|uniq`)
23
24 for d in ${deps[*]}; do
25 awk -v s="$d" -v RS="" '$0 ~ substr(s,2) {print $1}' $pkgdb
26 done
27 }
28
29
30 if [ "$1" = "" ]; then
31 echo "Usage: ${0##*/} <port>"
32 exit -1
33 fi
34
35 pkgName=${1##*/}
36
37 prt-get isinst $pkgName &> /dev/null
38 if [ $? -ne 0 ]; then
39 echo "$pkgName is not installed"
40 exit -3
41 fi
42
43 depPkg=`printDep $pkgName |sort|uniq|grep -v "\<$pkgName\>"`
44
45 for p in $depPkg; do
46 echo -n $p
47 coll=`prt-get printf "%p" --filter=$p|sed -e 's|.*/||'`
48 if [ "$coll" != "" ]; then
49 echo -n " ($coll)"
50 fi
51 echo ""
52 done|sort -k 2
|