comparison deploy/linux/debian-dependencies.sh @ 864:d47aa2977d7a

Auto dependencies
author Chris Cannam
date Wed, 24 Sep 2014 12:15:58 +0100
parents misc/debian-dependencies.sh@ac805901f02a
children 8215909b74d2
comparison
equal deleted inserted replaced
863:ac805901f02a 864:d47aa2977d7a
1 #!/bin/bash
2
3 target=$1
4
5 if [ ! -f "$target" ]; then
6 echo "Usage: $0 target-executable"
7 exit 1
8 fi
9
10 pfile=/tmp/packages_$$
11 rfile=/tmp/redundant_$$
12
13 trap "rm -f $pfile $rfile" 0
14 echo 1>&2
15
16 ldd "$target" | awk '{ print $3; }' | grep '^/' | while read lib; do
17 if test -n "$lib" ; then
18 dpkg-query -S "$lib"
19 fi
20 done | grep ': ' | awk -F: '{ print $1 }' | sort | uniq > $pfile
21
22 echo "Packages providing required libraries:" 1>&2
23 cat $pfile 1>&2
24 echo 1>&2
25
26 for p in `cat $pfile`; do
27 echo Looking at $p 1>&2
28 apt-cache showpkg "$p" | grep '^ ' | grep ',' | awk -F, '{ print $1; }' | \
29 while read d; do
30 if grep -q '^'$d'$' $pfile; then
31 echo $p 1>&2
32 fi
33 done
34 done | sort | uniq > $rfile
35
36 echo "Packages that can be eliminated because other packages depend on them:" 1>&2
37 cat $rfile 1>&2
38 echo 1>&2
39
40 cat $pfile $rfile | sort | uniq -u | sed 's/$/,/' | fmt -1000 | sed 's/^/Depends: /'
41
42