annotate deploy/linux/debian-dependencies.sh @ 737:4f3a8aa8d384 tip

Markdown
author Chris Cannam
date Wed, 28 Aug 2019 17:40:54 +0100
parents 1d0a0fce4021
children
rev   line source
Chris@700 1 #!/bin/bash
Chris@700 2
Chris@728 3 targets="$@"
Chris@700 4
Chris@728 5 if [ t"$targets" = "" ]; then
Chris@700 6 echo "Usage: $0 target-executable"
Chris@728 7 exit 2
Chris@700 8 fi
Chris@700 9
Chris@728 10 for target in $targets ; do
Chris@728 11 if [ ! -f "$target" ]; then
Chris@728 12 echo "Error: target executable ./$target not found"
Chris@728 13 exit 1
Chris@728 14 fi
Chris@728 15 done
Chris@728 16
Chris@700 17 set -eu
Chris@700 18
Chris@700 19 pfile=/tmp/packages_$$
Chris@700 20 rfile=/tmp/redundant_$$
Chris@700 21
Chris@700 22 trap "rm -f $pfile $rfile" 0
Chris@700 23 echo 1>&2
Chris@700 24
Chris@728 25 ldd $targets | awk '{ print $3; }' | grep '^/' | while read lib; do
Chris@700 26 if test -n "$lib" ; then
Chris@700 27 dpkg-query -S "$lib"
Chris@700 28 fi
Chris@700 29 done | grep ': ' | awk -F: '{ print $1 }' | sort | uniq > $pfile
Chris@700 30
Chris@700 31 echo "Packages providing required libraries:" 1>&2
Chris@700 32 cat $pfile 1>&2
Chris@700 33 echo 1>&2
Chris@700 34
Chris@700 35 for p in `cat $pfile`; do
Chris@700 36 echo Looking at $p 1>&2
Chris@700 37 apt-cache showpkg "$p" | grep '^ ' | grep ',' | awk -F, '{ print $1; }' | \
Chris@700 38 while read d; do
Chris@700 39 if grep -q '^'$d'$' $pfile; then
Chris@700 40 echo $p
Chris@700 41 fi
Chris@700 42 done
Chris@700 43 done | sort | uniq > $rfile
Chris@700 44
Chris@700 45 echo "Packages that can be eliminated because other packages depend on them:" 1>&2
Chris@700 46 cat $rfile 1>&2
Chris@700 47 echo 1>&2
Chris@700 48
Chris@713 49 echo "Remaining packages:" 1>&2
Chris@713 50 cat $pfile $rfile | sort | uniq -u 1>&2
Chris@713 51 echo 1>&2
Chris@713 52
Chris@715 53 cat $pfile $rfile | sort | uniq -u | sed 's/$/,/' | fmt -1000 | sed 's/^/Depends: /' | sed 's/,$/, mercurial, python-pyqt5, python-crypto, libc6/'
Chris@700 54
Chris@700 55