1 #! /bin/bash 2 basepath=$(cd `dirname $0`; pwd) 3 pkg="$*" 4 5 function getDepends() 6 { 7 ret=`apt-cache depends $1 |grep -i Depends |cut -d: -f2 |tr -d "<>"` 8 if [[ -z $ret ]]; then 9 # echo '$1 No depends' 10 echo -n 11 else 12 for i in $ret 13 do 14 if [[ `echo $pkg |grep -e "$i "` ]]; then 15 # echo "$i already in set" 16 echo -n 17 else 18 pkg="$pkg $i" 19 echo "Download $i ing" 20 getDepends $i 21 fi 22 done 23 fi 24 } 25 26 for j in $@ 27 do 28 getDepends $j 29 done 30 31 echo $pkg 32 #apt install $pkg --reinstall -d -y 33 apt-get download $pkg -d -y