annotate misc/debian-dependencies.sh @ 378:84fd4bb8d656

* Add misc/ directory from SVN repo
author Chris Cannam
date Mon, 18 Oct 2010 13:44:25 +0100
parents
children f84413dd5a7a
rev   line source
Chris@378 1 #!/bin/bash
Chris@378 2
Chris@378 3 target=$1
Chris@378 4
Chris@378 5 if [ ! -f "$target" ]; then
Chris@378 6 echo "Usage: $0 target-executable"
Chris@378 7 exit 1
Chris@378 8 fi
Chris@378 9
Chris@378 10 pfile=/tmp/packages_$$
Chris@378 11 rfile=/tmp/redundant_$$
Chris@378 12
Chris@378 13 trap "rm -f $pfile $rfile" 0
Chris@378 14 echo
Chris@378 15
Chris@378 16 ldd "$target" | awk '{ print $3; }' | while read lib; do
Chris@378 17 if test -n "$lib" ; then
Chris@378 18 dpkg-query -S "$lib"
Chris@378 19 fi
Chris@378 20 done | grep ': ' | awk -F: '{ print $1 }' | sort | uniq > $pfile
Chris@378 21
Chris@378 22 echo "Packages providing required libraries:"
Chris@378 23 cat $pfile
Chris@378 24 echo
Chris@378 25
Chris@378 26 for p in `cat $pfile`; do
Chris@378 27 apt-cache showpkg "$p" | grep '^ ' | grep ',' | awk -F, '{ print $1; }' | \
Chris@378 28 while read d; do
Chris@378 29 if grep -q '^'$d'$' $pfile; then
Chris@378 30 echo $p
Chris@378 31 fi
Chris@378 32 done
Chris@378 33 done | sort | uniq > $rfile
Chris@378 34
Chris@378 35 echo "Packages that can be eliminated because other packages depend on them:"
Chris@378 36 cat $rfile
Chris@378 37 echo
Chris@378 38
Chris@378 39 echo "Remaining required packages:"
Chris@378 40 cat $pfile $rfile | sort | uniq -u
Chris@378 41