Chris@700: #!/bin/bash Chris@700: Chris@700: target=$1 Chris@700: Chris@700: if [ ! -f "$target" ]; then Chris@700: echo "Usage: $0 target-executable" Chris@700: exit 1 Chris@700: fi Chris@700: Chris@700: set -eu Chris@700: Chris@700: pfile=/tmp/packages_$$ Chris@700: rfile=/tmp/redundant_$$ Chris@700: Chris@700: trap "rm -f $pfile $rfile" 0 Chris@700: echo 1>&2 Chris@700: Chris@700: ldd "$target" | awk '{ print $3; }' | grep '^/' | while read lib; do Chris@700: if test -n "$lib" ; then Chris@700: dpkg-query -S "$lib" Chris@700: fi Chris@700: done | grep ': ' | awk -F: '{ print $1 }' | sort | uniq > $pfile Chris@700: Chris@700: echo "Packages providing required libraries:" 1>&2 Chris@700: cat $pfile 1>&2 Chris@700: echo 1>&2 Chris@700: Chris@700: for p in `cat $pfile`; do Chris@700: echo Looking at $p 1>&2 Chris@700: apt-cache showpkg "$p" | grep '^ ' | grep ',' | awk -F, '{ print $1; }' | \ Chris@700: while read d; do Chris@700: if grep -q '^'$d'$' $pfile; then Chris@700: echo $p Chris@700: fi Chris@700: done Chris@700: done | sort | uniq > $rfile Chris@700: Chris@700: echo "Packages that can be eliminated because other packages depend on them:" 1>&2 Chris@700: cat $rfile 1>&2 Chris@700: echo 1>&2 Chris@700: Chris@713: echo "Remaining packages:" 1>&2 Chris@713: cat $pfile $rfile | sort | uniq -u 1>&2 Chris@713: echo 1>&2 Chris@713: Chris@714: cat $pfile $rfile | sort | uniq -u | sed 's/$/,/' | fmt -1000 | sed 's/^/Depends: /' | sed 's/,$/, mercurial, libc6/' | sed 's/libjack0,/jackd,/' Chris@700: Chris@700: